Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Oct 12, 2024
1 parent 7108f21 commit c6ab4e6
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 55 deletions.
14 changes: 7 additions & 7 deletions JL.Core/Dicts/EPWING/Nazeka/EpwingNazekaDBManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ INSERT INTO record_search_key(record_id, search_key)
_ = insertRecordCommand.Parameters["@id"].Value = id;
_ = insertRecordCommand.Parameters["@primary_spelling"].Value = record.PrimarySpelling;
_ = insertRecordCommand.Parameters["@reading"].Value = record.Reading is not null ? record.Reading : DBNull.Value;
_ = insertRecordCommand.Parameters["@alternative_spellings"].Value = record.AlternativeSpellings is not null ? JsonSerializer.Serialize(record.AlternativeSpellings, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_jsoNotIgnoringNull);
_ = insertRecordCommand.Parameters["@alternative_spellings"].Value = record.AlternativeSpellings is not null ? JsonSerializer.Serialize(record.AlternativeSpellings, Utils.s_defaultJso) : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_defaultJso);
_ = insertRecordCommand.ExecuteNonQuery();

_ = insertSearchKeyCommand.Parameters["@record_id"].Value = id;
Expand Down Expand Up @@ -170,10 +170,10 @@ INSERT INTO record_search_key(record_id, search_key)
string[]? alternativeSpellings = null;
if (dataReader[nameof(alternativeSpellings)] is string alternativeSpellingsFromDB)
{
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_jsoNotIgnoringNull);
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_defaultJso);
}

string[] definitions = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(definitions)), Utils.s_jsoNotIgnoringNull)!;
string[] definitions = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(definitions)), Utils.s_defaultJso)!;

if (results.TryGetValue(searchKey, out IList<IDictRecord>? result))
{
Expand Down Expand Up @@ -234,7 +234,7 @@ FROM record r
while (dataReader.Read())
{
EpwingNazekaRecord record = GetRecord(dataReader);
string[] searchKeys = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(searchKeys)), Utils.s_jsoNotIgnoringNull)!;
string[] searchKeys = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(searchKeys)), Utils.s_defaultJso)!;
for (int i = 0; i < searchKeys.Length; i++)
{
string searchKey = searchKeys[i];
Expand Down Expand Up @@ -270,10 +270,10 @@ private static EpwingNazekaRecord GetRecord(SqliteDataReader dataReader)
string[]? alternativeSpellings = null;
if (dataReader[nameof(alternativeSpellings)] is string alternativeSpellingsFromDB)
{
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_jsoNotIgnoringNull);
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_defaultJso);
}

string[] definitions = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(definitions)), Utils.s_jsoNotIgnoringNull)!;
string[] definitions = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(definitions)), Utils.s_defaultJso)!;

return new EpwingNazekaRecord(primarySpelling, reading, alternativeSpellings, definitions);
}
Expand Down
14 changes: 7 additions & 7 deletions JL.Core/Dicts/EPWING/Yomichan/EpwingYomichanDBManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ INSERT INTO record_search_key(record_id, search_key)
_ = insertRecordCommand.Parameters["@id"].Value = id;
_ = insertRecordCommand.Parameters["@primary_spelling"].Value = record.PrimarySpelling;
_ = insertRecordCommand.Parameters["@reading"].Value = record.Reading is not null ? record.Reading : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_jsoNotIgnoringNull);
_ = insertRecordCommand.Parameters["@part_of_speech"].Value = record.WordClasses is not null ? JsonSerializer.Serialize(record.WordClasses, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary_tags"].Value = record.DefinitionTags is not null ? JsonSerializer.Serialize(record.DefinitionTags, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_defaultJso);
_ = insertRecordCommand.Parameters["@part_of_speech"].Value = record.WordClasses is not null ? JsonSerializer.Serialize(record.WordClasses, Utils.s_defaultJso) : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary_tags"].Value = record.DefinitionTags is not null ? JsonSerializer.Serialize(record.DefinitionTags, Utils.s_defaultJso) : DBNull.Value;
_ = insertRecordCommand.ExecuteNonQuery();

_ = insertSearchKeyCommand.Parameters["@record_id"].Value = id;
Expand Down Expand Up @@ -221,7 +221,7 @@ FROM record r
while (dataReader.Read())
{
EpwingYomichanRecord record = GetRecord(dataReader);
string[] searchKeys = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(searchKeys)), Utils.s_jsoNotIgnoringNull)!;
string[] searchKeys = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(searchKeys)), Utils.s_defaultJso)!;
for (int i = 0; i < searchKeys.Length; i++)
{
string searchKey = searchKeys[i];
Expand Down Expand Up @@ -255,18 +255,18 @@ private static EpwingYomichanRecord GetRecord(SqliteDataReader dataReader)
reading = readingFromDB;
}

string[] definitions = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(definitions)), Utils.s_jsoNotIgnoringNull)!;
string[] definitions = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(definitions)), Utils.s_defaultJso)!;

string[]? wordClasses = null;
if (dataReader[nameof(wordClasses)] is string wordClassesFromDB)
{
wordClasses = JsonSerializer.Deserialize<string[]>(wordClassesFromDB, Utils.s_jsoNotIgnoringNull);
wordClasses = JsonSerializer.Deserialize<string[]>(wordClassesFromDB, Utils.s_defaultJso);
}

string[]? definitionTags = null;
if (dataReader[nameof(definitionTags)] is string definitionTagsFromDB)
{
definitionTags = JsonSerializer.Deserialize<string[]>(definitionTagsFromDB, Utils.s_jsoNotIgnoringNull);
definitionTags = JsonSerializer.Deserialize<string[]>(definitionTagsFromDB, Utils.s_defaultJso);
}

return new EpwingYomichanRecord(primarySpelling, reading, definitions, wordClasses, definitionTags);
Expand Down
22 changes: 11 additions & 11 deletions JL.Core/Dicts/JMdict/JmdictDBManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ INSERT INTO record_search_key(record_id, search_key)
insertRecordCommand.Parameters["@id"].Value = id;
insertRecordCommand.Parameters["@edict_id"].Value = record.Id;
insertRecordCommand.Parameters["@primary_spelling"].Value = record.PrimarySpelling;
insertRecordCommand.Parameters["@primary_spelling_orthography_info"].Value = record.PrimarySpellingOrthographyInfo is not null ? JsonSerializer.Serialize(record.PrimarySpellingOrthographyInfo, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@alternative_spellings"].Value = record.AlternativeSpellings is not null ? JsonSerializer.Serialize(record.AlternativeSpellings, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@primary_spelling_orthography_info"].Value = record.PrimarySpellingOrthographyInfo is not null ? JsonSerializer.Serialize(record.PrimarySpellingOrthographyInfo, Utils.s_defaultJso) : DBNull.Value;
insertRecordCommand.Parameters["@alternative_spellings"].Value = record.AlternativeSpellings is not null ? JsonSerializer.Serialize(record.AlternativeSpellings, Utils.s_defaultJso) : DBNull.Value;
insertRecordCommand.Parameters["@alternative_spellings_orthography_info"].Value = record.AlternativeSpellingsOrthographyInfo is not null ? JsonSerializer.Serialize(record.AlternativeSpellingsOrthographyInfo, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@readings"].Value = record.Readings is not null ? JsonSerializer.Serialize(record.Readings, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@readings"].Value = record.Readings is not null ? JsonSerializer.Serialize(record.Readings, Utils.s_defaultJso) : DBNull.Value;
insertRecordCommand.Parameters["@readings_orthography_info"].Value = record.ReadingsOrthographyInfo is not null ? JsonSerializer.Serialize(record.ReadingsOrthographyInfo, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@reading_restrictions"].Value = record.ReadingRestrictions is not null ? JsonSerializer.Serialize(record.ReadingRestrictions, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_jsoNotIgnoringNull);
insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_defaultJso);
insertRecordCommand.Parameters["@glossary_info"].Value = record.DefinitionInfo is not null ? JsonSerializer.Serialize(record.DefinitionInfo, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@part_of_speech"].Value = JsonSerializer.Serialize(record.WordClasses, Utils.s_jsoNotIgnoringNull);
insertRecordCommand.Parameters["@part_of_speech"].Value = JsonSerializer.Serialize(record.WordClasses, Utils.s_defaultJso);
insertRecordCommand.Parameters["@spelling_restrictions"].Value = record.SpellingRestrictions is not null ? JsonSerializer.Serialize(record.SpellingRestrictions, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@fields"].Value = record.Fields is not null ? JsonSerializer.Serialize(record.Fields, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
insertRecordCommand.Parameters["@misc"].Value = record.Misc is not null ? JsonSerializer.Serialize(record.Misc, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
Expand Down Expand Up @@ -272,7 +272,7 @@ FROM record r
{
JmdictRecord record = GetRecord(dataReader);

string[] searchKeys = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(searchKeys)), Utils.s_jsoNotIgnoringNull)!;
string[] searchKeys = JsonSerializer.Deserialize<string[]>(dataReader.GetString(nameof(searchKeys)), Utils.s_defaultJso)!;
for (int i = 0; i < searchKeys.Length; i++)
{
string searchKey = searchKeys[i];
Expand Down Expand Up @@ -303,7 +303,7 @@ private static JmdictRecord GetRecord(SqliteDataReader dataReader)
string[]? primarySpellingOrthographyInfo = null;
if (dataReader[nameof(primarySpellingOrthographyInfo)] is string primarySpellingOrthographyInfoFromDB)
{
primarySpellingOrthographyInfo = JsonSerializer.Deserialize<string[]>(primarySpellingOrthographyInfoFromDB, Utils.s_jsoNotIgnoringNull);
primarySpellingOrthographyInfo = JsonSerializer.Deserialize<string[]>(primarySpellingOrthographyInfoFromDB, Utils.s_defaultJso);
}

string[]?[]? spellingRestrictions = null;
Expand All @@ -315,7 +315,7 @@ private static JmdictRecord GetRecord(SqliteDataReader dataReader)
string[]? alternativeSpellings = null;
if (dataReader[nameof(alternativeSpellings)] is string alternativeSpellingsFromDB)
{
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_jsoNotIgnoringNull);
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_defaultJso);
}

string[]?[]? alternativeSpellingsOrthographyInfo = null;
Expand All @@ -327,7 +327,7 @@ private static JmdictRecord GetRecord(SqliteDataReader dataReader)
string[]? readings = null;
if (dataReader[nameof(readings)] is string readingsFromDB)
{
readings = JsonSerializer.Deserialize<string[]>(readingsFromDB, Utils.s_jsoNotIgnoringNull);
readings = JsonSerializer.Deserialize<string[]>(readingsFromDB, Utils.s_defaultJso);
}

string[]?[]? readingRestrictions = null;
Expand All @@ -342,8 +342,8 @@ private static JmdictRecord GetRecord(SqliteDataReader dataReader)
readingsOrthographyInfo = JsonSerializer.Deserialize<string[]?[]>(readingsOrthographyInfoFromDB, Utils.s_jsoNotIgnoringNull);
}

string[][] definitions = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(definitions)), Utils.s_jsoNotIgnoringNull)!;
string[][] wordClasses = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(wordClasses)), Utils.s_jsoNotIgnoringNull)!;
string[][] definitions = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(definitions)), Utils.s_defaultJso)!;
string[][] wordClasses = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(wordClasses)), Utils.s_defaultJso)!;

string[]?[]? fields = null;
if (dataReader[nameof(fields)] is string fieldsFromDB)
Expand Down
16 changes: 8 additions & 8 deletions JL.Core/Dicts/JMnedict/JmnedictDBManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ INSERT INTO record (id, jmnedict_id, primary_spelling, primary_spelling_in_hirag
_ = insertRecordCommand.Parameters["@jmnedict_id"].Value = record.Id;
_ = insertRecordCommand.Parameters["@primary_spelling"].Value = record.PrimarySpelling;
_ = insertRecordCommand.Parameters["@primary_spelling_in_hiragana"].Value = JapaneseUtils.KatakanaToHiragana(record.PrimarySpelling);
_ = insertRecordCommand.Parameters["@readings"].Value = record.Readings is not null ? JsonSerializer.Serialize(record.Readings, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
_ = insertRecordCommand.Parameters["@alternative_spellings"].Value = record.AlternativeSpellings is not null ? JsonSerializer.Serialize(record.AlternativeSpellings, Utils.s_jsoNotIgnoringNull) : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_jsoNotIgnoringNull);
_ = insertRecordCommand.Parameters["@name_types"].Value = JsonSerializer.Serialize(record.NameTypes, Utils.s_jsoNotIgnoringNull);
_ = insertRecordCommand.Parameters["@readings"].Value = record.Readings is not null ? JsonSerializer.Serialize(record.Readings, Utils.s_defaultJso) : DBNull.Value;
_ = insertRecordCommand.Parameters["@alternative_spellings"].Value = record.AlternativeSpellings is not null ? JsonSerializer.Serialize(record.AlternativeSpellings, Utils.s_defaultJso) : DBNull.Value;
_ = insertRecordCommand.Parameters["@glossary"].Value = JsonSerializer.Serialize(record.Definitions, Utils.s_defaultJso);
_ = insertRecordCommand.Parameters["@name_types"].Value = JsonSerializer.Serialize(record.NameTypes, Utils.s_defaultJso);
_ = insertRecordCommand.ExecuteNonQuery();

++id;
Expand Down Expand Up @@ -194,17 +194,17 @@ private static JmnedictRecord GetRecord(SqliteDataReader dataReader)
string[]? readings = null;
if (dataReader[nameof(readings)] is string readingsFromDB)
{
readings = JsonSerializer.Deserialize<string[]>(readingsFromDB, Utils.s_jsoNotIgnoringNull);
readings = JsonSerializer.Deserialize<string[]>(readingsFromDB, Utils.s_defaultJso);
}

string[]? alternativeSpellings = null;
if (dataReader[nameof(alternativeSpellings)] is string alternativeSpellingsFromDB)
{
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_jsoNotIgnoringNull);
alternativeSpellings = JsonSerializer.Deserialize<string[]>(alternativeSpellingsFromDB, Utils.s_defaultJso);
}

string[][] definitions = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(definitions)), Utils.s_jsoNotIgnoringNull)!;
string[][] nameTypes = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(nameTypes)), Utils.s_jsoNotIgnoringNull)!;
string[][] definitions = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(definitions)), Utils.s_defaultJso)!;
string[][] nameTypes = JsonSerializer.Deserialize<string[][]>(dataReader.GetString(nameof(nameTypes)), Utils.s_defaultJso)!;

return new JmnedictRecord(id, primarySpelling, alternativeSpellings, readings, definitions, nameTypes);
}
Expand Down
4 changes: 2 additions & 2 deletions JL.Core/Dicts/JMnedict/JmnedictRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public JmnedictRecord(int id, string primarySpelling, string[]? alternativeSpell
Readings = readings;
Definitions = definitions;
NameTypes = nameTypes;
//RelatedTerms = new List<List<string>?>();
//RelatedTerms = relatedTerms;
}

public string BuildFormattedDefinition(DictOptions options)
Expand Down Expand Up @@ -65,7 +65,7 @@ public string BuildFormattedDefinition(DictOptions options)
_ = defResult.Append(CultureInfo.InvariantCulture, $"({i + 1}) ");
}

// if (options.RelatedTerm!.Value)
// if (showRelatedTerms)
// {
// string[]? relatedTerms = RelatedTerms?[i];
// if (relatedTerms?.Length > 0)
Expand Down
Loading

0 comments on commit c6ab4e6

Please sign in to comment.