diff --git a/JL.Core/Mining/JLField.cs b/JL.Core/Mining/JLField.cs index d709e8e1..f918cec4 100644 --- a/JL.Core/Mining/JLField.cs +++ b/JL.Core/Mining/JLField.cs @@ -16,10 +16,12 @@ public enum JLField [Description("Dictionary Name")] DictionaryName, Audio, Image, + [Description("Source Text")] SourceText, + [Description("Leading Source Text Part")] LeadingSourceTextPart, + [Description("Trailing Source Text Part")] TrailingSourceTextPart, Sentence, [Description("Leading Sentence Part")] LeadingSentencePart, [Description("Trailing Sentence Part")] TrailingSentencePart, - [Description("Source Text")] SourceText, [Description("Matched Text")] MatchedText, [Description("Local Time")] LocalTime, Frequencies, diff --git a/JL.Core/Mining/JLFieldUtils.cs b/JL.Core/Mining/JLFieldUtils.cs index 7923f62d..c901299c 100644 --- a/JL.Core/Mining/JLFieldUtils.cs +++ b/JL.Core/Mining/JLFieldUtils.cs @@ -20,6 +20,8 @@ public static class JLFieldUtils JLField.Audio, JLField.Image, JLField.SourceText, + JLField.LeadingSourceTextPart, + JLField.TrailingSourceTextPart, JLField.Sentence, JLField.LeadingSentencePart, JLField.TrailingSentencePart, @@ -54,6 +56,8 @@ public static class JLFieldUtils JLField.Audio, JLField.Image, JLField.SourceText, + JLField.LeadingSourceTextPart, + JLField.TrailingSourceTextPart, JLField.Sentence, JLField.LeadingSentencePart, JLField.TrailingSentencePart, @@ -81,6 +85,8 @@ public static class JLFieldUtils JLField.Audio, JLField.Image, JLField.SourceText, + JLField.LeadingSourceTextPart, + JLField.TrailingSourceTextPart, JLField.Sentence, JLField.LeadingSentencePart, JLField.TrailingSentencePart, diff --git a/JL.Core/Mining/MiningUtils.cs b/JL.Core/Mining/MiningUtils.cs index e2f1d27e..d41c7917 100644 --- a/JL.Core/Mining/MiningUtils.cs +++ b/JL.Core/Mining/MiningUtils.cs @@ -79,9 +79,6 @@ private static Dictionary GetMiningParameters(LookupResult look Dictionary miningParams = new() { [JLField.LocalTime] = DateTime.Now.ToString("s", CultureInfo.InvariantCulture), - [JLField.SourceText] = useHtmlTags - ? string.Create(CultureInfo.InvariantCulture, $"{currentText[..currentCharPosition]}{lookupResult.MatchedText}{currentText[(currentCharPosition + lookupResult.MatchedText.Length)..]}").ReplaceLineEndings("
") - : currentText, [JLField.DictionaryName] = lookupResult.Dict.Name, [JLField.MatchedText] = lookupResult.MatchedText, [JLField.DeconjugatedMatchedText] = lookupResult.DeconjugatedMatchedText, @@ -91,6 +88,21 @@ private static Dictionary GetMiningParameters(LookupResult look : lookupResult.PrimarySpelling }; + string leadingSourcePart = currentText[..currentCharPosition]; + string trailingSourcePart = currentText[(currentCharPosition + lookupResult.MatchedText.Length)..]; + if (useHtmlTags) + { + leadingSourcePart = leadingSourcePart.ReplaceLineEndings("
"); + trailingSourcePart = trailingSourcePart.ReplaceLineEndings("
"); + } + + miningParams[JLField.LeadingSourceTextPart] = leadingSourcePart; + miningParams[JLField.TrailingSourceTextPart] = trailingSourcePart; + + miningParams[JLField.SourceText] = useHtmlTags + ? string.Create(CultureInfo.InvariantCulture, $"{leadingSourcePart}{lookupResult.MatchedText}{trailingSourcePart}").ReplaceLineEndings("
") + : currentText; + string sentence = JapaneseUtils.FindSentence(currentText, currentCharPosition); int searchStartIndex = currentCharPosition + lookupResult.MatchedText.Length - sentence.Length; if (searchStartIndex < 0 || searchStartIndex >= currentText.Length) diff --git a/JL.Windows/GUI/PreferencesWindow.xaml.cs b/JL.Windows/GUI/PreferencesWindow.xaml.cs index f27cbcdc..d797381f 100644 --- a/JL.Windows/GUI/PreferencesWindow.xaml.cs +++ b/JL.Windows/GUI/PreferencesWindow.xaml.cs @@ -61,6 +61,8 @@ public static bool IsItVisible() • Audio: Audio for the first reading of the mined word. • Image: Image found in clipboard at the time of mining. • Source Text: Whole text in which the mined word appears in. + • Leading Source Text Part: Part of the source text that appears before the matched text. + • Trailing Sentence Text Part: Part of the source that appears after the matched text. • Sentence: Sentence in which the mined word appears in. • Leading Sentence Part: Part of the sentence that appears before the matched text. e.g., if the mined word is "大好き" while the sentence is "妹が大好きです", "Leading Sentence Part" will be "妹が". • Trailing Sentence Part: Part of the sentence that appears after the matched text. e.g., if the mined word is "大好き" while the sentence is "妹が大好きです", "Trailing Sentence Part" will be "です". @@ -93,6 +95,8 @@ public static bool IsItVisible() • Audio: Audio for the first reading of the mined word. • Image: Image found in clipboard at the time of mining. • Source Text: Whole text in which the mined kanji appears in. + • Leading Source Text Part: Part of the source text that appears before the mined kanji. + • Trailing Sentence Text Part: Part of the source that appears after the mined kanji. • Sentence: Sentence in which the mined kanji appears in. • Leading Sentence Part: Part of the sentence that appears before the mined kanji. e.g., if the mined kanji is "大" while the sentence is "妹が大好きです", "Leading Sentence Part" will be "妹が". • Trailing Sentence Part: Part of the sentence that appears after the mined kanji. e.g., if the mined kanji is "大" while the sentence is "妹が大好きです", "Trailing Sentence Part" will be "好きです". @@ -117,6 +121,8 @@ public static bool IsItVisible() • Audio: Audio for the first reading of the mined word. • Image: Image found in clipboard at the time of mining. • Source Text: Whole text in which the mined name appears in. + • Leading Source Text Part: Part of the source text that appears before the mined name. + • Trailing Sentence Text Part: Part of the source that appears after the mined name. • Sentence: Sentence in which the mined name appears in. • Leading Sentence Part: Part of the sentence that appears before the mined name. e.g., if the mined name is "エスト" while the sentence is "俺はエストのことが大好き", "Leading Sentence Part" will be "俺は". • Trailing Sentence Part: Part of the sentence that appears after the mined name. e.g., if the mined name is "エスト" while the sentence is "俺はエストのことが大好き", "Trailing Sentence Part" will be "のことが大好き".