Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<command id="CmdTryAWord" label="_Try a Word..." icon="tryAWord" message="TryAWord"/>
<command id="CmdParseCurrentWord" label="Parse _Current Word" message="ParseCurrentWord"/>
<command id="CmdParseWordsInCurrentText" label="Parse Words in Te_xt" message="ParseWordsInCurrentText"/>
<command id="CmdParseUnapprovedWordsInCurrentText" label="Parse Unapproved Words in Text" message="ParseUnapprovedWordsInCurrentText"/>
<command id="CmdClearSelectedWordParserAnalyses" label="Clear Current Word's Parser _Analyses" message="ClearSelectedWordParserAnalyses"/>
<command id="CmdReInitializeParser" label="Re_load Grammar / Lexicon" message="ReInitParser" tooltip="Reloads data from the Grammar and Lexicon, so the parser uses your latest changes."/>
<command id="CmdCheckParserOnCurrentText" label="On Current Text" message="CheckParserOnCurrentText" tooltip="Checks parser on currrent text and reports results."/>
Expand Down Expand Up @@ -278,6 +279,7 @@
<item label="-" translate="do not translate"/>
<item command="CmdTryAWord"/>
<item command="CmdParseWordsInCurrentText"/>
<item command="CmdParseUnapprovedWordsInCurrentText"/>
<item command="CmdParseCurrentWord"/>
<item command="CmdClearSelectedWordParserAnalyses" defaultVisible="false"/>
<item label="-" translate="do not translate"/>
Expand Down
53 changes: 53 additions & 0 deletions Src/LexText/ParserUI/ParserListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class ParserListener : IxCoreColleague, IDisposable, IVwNotifyChange
private TryAWordDlg m_dialog;
private FormWindowState m_prevWindowState;
private ParserConnection m_parserConnection;
private int m_wordCount = 0;
private Timer m_timer;
// Keep track of parse results as we parse wordforms.
private Dictionary<IWfiWordform, ParseResult> m_checkParserResults = null;
Expand Down Expand Up @@ -271,6 +272,11 @@ public string ParserQueueString
med = m_parserConnection.GetQueueSize(ParserPriority.Medium).ToString();
high = m_parserConnection.GetQueueSize(ParserPriority.High).ToString();
}
if (low == "0" && med == "0" && high == "0")
{
// All done. Report number of words parsed.
return string.Format(ParserUIStrings.ksParsedXWords, m_wordCount);
}

return string.Format(ParserUIStrings.ksQueueXYZ, low, med, high);
}
Expand Down Expand Up @@ -504,6 +510,17 @@ public bool OnDisplayParseWordsInCurrentText(object commandObject, ref UIItemDis
return true; //we handled this.
}

public bool OnDisplayParseUnapprovedWordsInCurrentText(object commandObject, ref UIItemDisplayProperties display)
{
CheckDisposed();

bool enable = CurrentText != null;
display.Visible = enable;
display.Enabled = enable;

return true; //we handled this.
}

public bool OnParseWordsInCurrentText(object argument)
{
CheckDisposed();
Expand All @@ -518,6 +535,40 @@ public bool OnParseWordsInCurrentText(object argument)
return true; //we handled this.
}

public bool OnParseUnapprovedWordsInCurrentText(object argument)
{
CheckDisposed();

if (CurrentText != null && ConnectToParser())
{
IStText text = CurrentText;
IEnumerable<IWfiWordform> wordforms = GetUnapprovedWordforms(text);
UpdateWordforms(wordforms, ParserPriority.Medium);
}

return true; //we handled this.
}

private IEnumerable<IWfiWordform> GetUnapprovedWordforms(IStText text)
{
HashSet<IWfiWordform> unapprovedWordforms = new HashSet<IWfiWordform>();
foreach (IStTxtPara para in text.ParagraphsOS)
{
foreach (ISegment seg in para.SegmentsOS)
{
foreach (IAnalysis analysis in seg.AnalysesRS)
{
if (analysis is IWfiWordform)
{
unapprovedWordforms.Add(analysis.Wordform);
}
}
}
}
return unapprovedWordforms;

}

public bool OnCheckParserOnCurrentText(object argument)
{
CheckDisposed();
Expand Down Expand Up @@ -632,11 +683,13 @@ private void UpdateWordforms(IEnumerable<IWfiWordform> wordforms, ParserPriority
ShowParserReport(viewModel);
}
}
m_wordCount = wordforms.Count();
m_parserConnection.UpdateWordforms(wordforms, priority, checkParser);
}

private void UpdateWordform(IWfiWordform wordform, ParserPriority priority)
{
m_wordCount = 1;
m_parserConnection.UpdateWordform(wordform, priority);
}

Expand Down
9 changes: 9 additions & 0 deletions Src/LexText/ParserUI/ParserUIStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Src/LexText/ParserUI/ParserUIStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
<value>Queue: ({0}/{1}/{2})</value>
<comment>{0}, {1}, and {2} are numbers (or value of ksDash)</comment>
</data>
<data name="ksParsedXWords" xml:space="preserve">
<value>Parsed {0} word(s)</value>
</data>
<data name="ksUndoEditingParserParameters" xml:space="preserve">
<value>Undo Editing Parser Parameters</value>
</data>
Expand Down
Loading