Skip to content

Commit

Permalink
databasemanager: support more frequency meta term bank formats
Browse files Browse the repository at this point in the history
  • Loading branch information
precondition authored and ripose-jp committed Aug 29, 2024
1 parent 3f5e599 commit 271c657
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions src/dict/databasemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,21 +757,52 @@ int DatabaseManager::addFrequencies(
{
continue;
}
obj = obj[OBJ_FREQ_KEY].toObject();
}

/* Check for the type that should be shown */
if (obj[OBJ_DISPLAY_KEY].isString())
/* First scenario:
* [
* "<term>","freq",{"reading":"<reading>","frequency":<number>}
* ]
*/
if (obj[OBJ_FREQ_KEY].isDouble())
{
freqStr = obj[OBJ_DISPLAY_KEY].toString();
freqStr = QString::number(obj[OBJ_FREQ_KEY].toInt());
}
else if (obj[OBJ_VALUE_KEY].isDouble())

/* Second scenario:
* [
* "<term>","freq",{"reading":"<reading>","frequency": "<frequency string>">}
* ]
*/
else if (obj[OBJ_FREQ_KEY].isString())
{
freqStr = QString::number(obj[OBJ_VALUE_KEY].toInt());
freqStr = obj[OBJ_FREQ_KEY].toString();
}
else

/* Third scenario:
* [
* "<term>","freq",
* {"reading":"<reading>",
* "frequency": {"value": <number>, "displayValue": "<stylized frequency string>"}
* }
* ]
*/
else if (obj[OBJ_FREQ_KEY].isObject())
{
continue;
obj = obj[OBJ_FREQ_KEY].toObject();
/* Check for the type that should be shown */
if (obj[OBJ_DISPLAY_KEY].isString())
{
freqStr = obj[OBJ_DISPLAY_KEY].toString();
}
else if (obj[OBJ_VALUE_KEY].isDouble())
{
freqStr = QString::number(obj[OBJ_VALUE_KEY].toInt());
}
else
{
continue;
}
}
break;
}
Expand Down

0 comments on commit 271c657

Please sign in to comment.