Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Jan 3, 2025
1 parent cbd089f commit e4e7711
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions JL.Core/Lookup/IntermediaryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ internal sealed class IntermediaryResult(
List<IList<IDictRecord>> resultsList,
List<List<List<string>>>? processListList,
string matchedText,
string deconjugatedMatchedText,
string? deconjugatedMatchedText,
Dict dict)
{
public List<IList<IDictRecord>> Results { get; } = resultsList;
public List<List<List<string>>>? Processes { get; } = processListList;
public string MatchedText { get; } = matchedText;
public string DeconjugatedMatchedText { get; } = deconjugatedMatchedText;
public string? DeconjugatedMatchedText { get; } = deconjugatedMatchedText;
public Dict Dict { get; } = dict;
}
4 changes: 2 additions & 2 deletions JL.Core/Lookup/LookupResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class LookupResult
internal int EntryId { get; }

// Word dictionaries
public string DeconjugatedMatchedText { get; }
public string? DeconjugatedMatchedText { get; }
public string? DeconjugationProcess { get; }
// JMdict, Nazeka EPWING
public string[]? AlternativeSpellings { get; }
Expand All @@ -40,7 +40,7 @@ public sealed class LookupResult
internal LookupResult(
string primarySpelling,
string matchedText,
string deconjugatedMatchedText,
string? deconjugatedMatchedText,
Dict dict,
string[]? readings,
List<LookupFrequencyResult>? frequencies = null,
Expand Down
14 changes: 7 additions & 7 deletions JL.Core/Lookup/LookupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,7 @@ private static void GetWordResultsHelper(Dict dict,
if (wordDict.TryGetValue(textInHiragana, out IList<IDictRecord>? tempResult))
{
_ = results.TryAdd(textInHiragana,
new IntermediaryResult([tempResult], null, matchedText, matchedText,
dict));
new IntermediaryResult([tempResult], null, matchedText, null, dict));
}

if (deconjugationResults is not null)
Expand Down Expand Up @@ -687,10 +686,11 @@ private static List<IDictRecord> GetValidDeconjugatedResults(Dict dict, Form dec
Dictionary<string, IntermediaryResult> nameResults = new(textListCount, StringComparer.Ordinal);
for (int i = 0; i < textListCount; i++)
{
if (nameDict.TryGetValue(textInHiraganaList[i], out IList<IDictRecord>? result))
string textInHiragana = textInHiraganaList[i];
if (nameDict.TryGetValue(textInHiragana, out IList<IDictRecord>? result))
{
nameResults.Add(textInHiraganaList[i],
new IntermediaryResult([result], null, textList[i], textList[i], dict));
nameResults.Add(textInHiragana,
new IntermediaryResult([result], null, textList[i], null, dict));
}
}

Expand All @@ -702,7 +702,7 @@ private static List<IDictRecord> GetValidDeconjugatedResults(Dict dict, Form dec
private static IntermediaryResult? GetKanjiResults(string kanji, Dict dict)
{
return dict.Contents.TryGetValue(kanji, out IList<IDictRecord>? result)
? new IntermediaryResult([result], null, kanji, kanji, dict)
? new IntermediaryResult([result], null, kanji, null, dict)
: null;
}

Expand All @@ -711,7 +711,7 @@ private static List<IDictRecord> GetValidDeconjugatedResults(Dict dict, Form dec
List<IDictRecord>? results = getKanjiRecordsFromDB(dict.Name, kanji);

return results?.Count > 0
? new IntermediaryResult([results], null, kanji, kanji, dict)
? new IntermediaryResult([results], null, kanji, null, dict)
: null;
}

Expand Down
4 changes: 2 additions & 2 deletions JL.Core/Mining/MiningUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static class MiningUtils
return lookupResult.PrimarySpelling;

case JLField.DeconjugatedMatchedText:
return lookupResult.DeconjugatedMatchedText;
return lookupResult.DeconjugatedMatchedText ?? lookupResult.MatchedText;

case JLField.KanjiStats:
return lookupResult.KanjiStats;
Expand Down Expand Up @@ -376,7 +376,7 @@ private static Dictionary<JLField, string> GetMiningParameters(LookupResult look
[JLField.LocalTime] = DateTime.Now.ToString("s", CultureInfo.InvariantCulture),
[JLField.DictionaryName] = lookupResult.Dict.Name,
[JLField.MatchedText] = lookupResult.MatchedText,
[JLField.DeconjugatedMatchedText] = lookupResult.DeconjugatedMatchedText,
[JLField.DeconjugatedMatchedText] = lookupResult.DeconjugatedMatchedText ?? lookupResult.MatchedText,
[JLField.PrimarySpelling] = lookupResult.PrimarySpelling,
[JLField.PrimarySpellingWithOrthographyInfo] = lookupResult.PrimarySpellingOrthographyInfoList is not null
? $"{lookupResult.PrimarySpelling} ({string.Join(", ", lookupResult.PrimarySpellingOrthographyInfoList)})"
Expand Down
4 changes: 2 additions & 2 deletions JL.Windows/GUI/PopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public Task LookupOnCharPosition(TextBox textBox, int charPosition, bool enableM
StatsUtils.IncrementStat(StatType.NumberOfLookups);
if (CoreConfigManager.Instance.TrackTermLookupCounts)
{
StatsUtils.IncrementTermLookupCount(firstLookupResult.DeconjugatedMatchedText);
StatsUtils.IncrementTermLookupCount(firstLookupResult.DeconjugatedMatchedText ?? firstLookupResult.MatchedText);
}

if (configManager.HighlightLongestMatch)
Expand Down Expand Up @@ -374,7 +374,7 @@ public Task LookupOnSelect(TextBox textBox)
StatsUtils.IncrementStat(StatType.NumberOfLookups);
if (CoreConfigManager.Instance.TrackTermLookupCounts)
{
StatsUtils.IncrementTermLookupCount(firstLookupResult.DeconjugatedMatchedText);
StatsUtils.IncrementTermLookupCount(firstLookupResult.DeconjugatedMatchedText ?? firstLookupResult.MatchedText);
}

EnableMiningMode();
Expand Down

0 comments on commit e4e7711

Please sign in to comment.