Skip to content

Commit

Permalink
Implement Parse Prioritizer in Interlinear (LT-21728) (#36)
Browse files Browse the repository at this point in the history
* Change to liblcm beta0089
* Add sorted list of choices based on prioritization from liblcm
  • Loading branch information
jtmaxwell3 authored May 1, 2024
1 parent c351ca8 commit bea232f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Build/mkall.targets
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
<ChorusNugetVersion>5.2.0-beta0003</ChorusNugetVersion>
<PalasoNugetVersion>13.0.0-beta0076</PalasoNugetVersion>
<ParatextNugetVersion>9.4.0.1-beta</ParatextNugetVersion>
<LcmNugetVersion>11.0.0-beta0087</LcmNugetVersion>
<LcmNugetVersion>11.0.0-beta0089</LcmNugetVersion>
<IcuNugetVersion>70.1.123</IcuNugetVersion>
<HermitCrabNugetVersion>2.5.13</HermitCrabNugetVersion>
<!--Todo: use PalasoBuildType, when it refers to somewhere that has the IPCFramework.-->
Expand Down
18 changes: 9 additions & 9 deletions Build/nuget-common/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@
<package id="SIL.Core" version="8.1.0-beta0035" targetFramework="net461" />
<package id="SIL.Core" version="13.0.0-beta0076" targetFramework="net461" />
<package id="SIL.DesktopAnalytics" version="4.0.0" targetFramework="net461" />
<package id="SIL.LCModel.Build.Tasks" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.Core.Tests" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.Core" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.FixData" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.Tests" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.Tools" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.Utils.Tests" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.Utils" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel" version="11.0.0-beta0087" targetFramework="net461" />
<package id="SIL.LCModel.Build.Tasks" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel.Core.Tests" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel.Core" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel.FixData" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel.Tests" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel.Tools" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel.Utils.Tests" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel.Utils" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.LCModel" version="11.0.0-beta0089" targetFramework="net461" />
<package id="SIL.Lexicon" version="13.0.0-beta0076" targetFramework="net461" />
<package id="SIL.libpalaso.l10ns" version="6.0.0" targetFramework="net461" />
<package id="SIL.Lift" version="13.0.0-beta0076" targetFramework="net461" />
Expand Down
12 changes: 9 additions & 3 deletions Src/LexText/Interlinear/ChooseAnalysisHander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class ChooseAnalysisHandler : IComboHandler, IDisposable
{
int m_hvoAnalysis; // The current 'analysis', may be wordform, analysis, gloss.
int m_hvoSrc; // the object (CmAnnotation? or SbWordform) we're analyzing.
AnalysisOccurrence m_occurrence;
bool m_fInitializing = false; // true to suppress AnalysisChosen while setting up combo.
LcmCache m_cache;
IComboList m_combo;
Expand Down Expand Up @@ -110,12 +111,13 @@ internal IVwStylesheet StyleSheet
/// <param name="hvoSrc"></param>
/// <param name="?"></param>
/// <param name="comboList"></param>
public ChooseAnalysisHandler(LcmCache cache, int hvoSrc, int hvoAnalysis, IComboList comboList)
public ChooseAnalysisHandler(LcmCache cache, int hvoSrc, int hvoAnalysis, AnalysisOccurrence occurrence, IComboList comboList)
{
m_combo = comboList;
m_cache = cache;
m_hvoSrc = hvoSrc;
m_hvoAnalysis = hvoAnalysis;
m_occurrence = occurrence;
m_combo.SelectedIndexChanged += new EventHandler(m_combo_SelectedIndexChanged);
m_combo.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
}
Expand Down Expand Up @@ -280,7 +282,9 @@ public void SetupCombo()
var wordform = m_owner.GetWordformOfAnalysis();

// Add the analyses, and recursively the other items.
foreach (var wa in wordform.AnalysesOC)
var guess_services = new AnalysisGuessServices(m_cache);
var sorted_analyses = guess_services.GetSortedAnalysisGuesses(wordform, m_occurrence, false);
foreach (var wa in sorted_analyses)
{
Opinions o = wa.GetAgentOpinion(
m_cache.LangProject.DefaultUserAgent);
Expand All @@ -307,7 +311,9 @@ void AddAnalysisItems(IWfiAnalysis wa)
{
AddItem(wa,
MakeAnalysisStringRep(wa, m_cache, StyleSheet != null, (m_owner as SandboxBase).RawWordformWs), true);
foreach (var gloss in wa.MeaningsOC)
var guess_services = new AnalysisGuessServices(m_cache);
var sorted_glosses = guess_services.GetSortedGlossGuesses(wa, m_occurrence);
foreach (var gloss in sorted_glosses)
{
AddItem(gloss, MakeGlossStringRep(gloss, m_cache, StyleSheet != null), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ public void ExportBasicInformation_FormSansMorph()
//validate export xml against schema
ValidateInterlinearXml(exportedDoc);

AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//word[item[@type='txt' and @lang='{QaaXKal}']='gone']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//morph[item[@type='txt' and @lang='{QaaXKal}']]", 2);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//morph[item[@type='txt' and @lang='{QaaXKal}']='go']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//morph[item[@type='txt' and @lang='{QaaXKal}']='en']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//word[item[@type='txt' and @lang='{QaaXKal}']='gone']", 1);
// The guesser adds an analysis for "go".
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//morph[item[@type='txt' and @lang='{QaaXKal}']='go']", 2);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//morph[item[@type='txt' and @lang='{QaaXKal}']]", 3);
}

/// <summary>
Expand Down Expand Up @@ -448,7 +449,8 @@ public void ExportVariantTypeInformation_LT9374()
ValidateInterlinearXml(exportedDoc);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//word[item[@type='txt']='went']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='txt']='went']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='cf']='go']", 1);
// The guesser adds an analysis for "go".
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='cf']='go']", 2);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph/item[@type='variantTypes']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='variantTypes']='+fr. var.']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='gls']='go.PST']", 1);
Expand Down Expand Up @@ -597,7 +599,8 @@ public void ExportIrrInflVariantTypeInformation_LT7581_glsAppend()
ValidateInterlinearXml(exportedDoc);

AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='txt']='went']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='cf']='go']", 1);
// The guesser adds an analysis for "go".
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='cf']='go']", 2);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='gls']='glossgo']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph/item[@type='glsAppend']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='glsAppend']='.pst']", 1);
Expand Down
11 changes: 8 additions & 3 deletions Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private static IComboHandler MakeCombo(IHelpTopicProvider helpTopicProvider,
ComboListBox clb2 = new ComboListBox();
clb2.StyleSheet = sandbox.StyleSheet;
ChooseAnalysisHandler caHandler = new ChooseAnalysisHandler(
caches.MainCache, hvoSbWord, sandbox.Analysis, clb2);
caches.MainCache, hvoSbWord, sandbox.Analysis, sandbox.m_occurrenceSelected, clb2);
caHandler.Owner = sandbox;
caHandler.AnalysisChosen += new EventHandler(
sandbox.Handle_AnalysisChosen);
Expand Down Expand Up @@ -1125,7 +1125,9 @@ private void AddAnalysesOf(IWfiWordform wordform, bool fBaseWordIsPhrase)
return; // no real wordform, can't have analyses.
ITsStrBldr builder = TsStringUtils.MakeStrBldr();
ITsString space = TsStringUtils.MakeString(fBaseWordIsPhrase ? " " : " ", m_wsVern);
foreach (IWfiAnalysis wa in wordform.AnalysesOC)
var guess_services = new AnalysisGuessServices(m_caches.MainCache);
var sorted_analyses = guess_services.GetSortedAnalysisGuesses(wordform, m_wsVern);
foreach (IWfiAnalysis wa in sorted_analyses)
{
Opinions o = wa.GetAgentOpinion(
m_caches.MainCache.LangProject.DefaultUserAgent);
Expand Down Expand Up @@ -3195,7 +3197,10 @@ public override void SetupCombo()
private void AddComboItems(ref int hvoEmptyGloss, ITsStrBldr tsb, IWfiAnalysis wa)
{
IList<int> wsids = m_sandbox.m_choices.EnabledWritingSystemsForFlid(InterlinLineChoices.kflidWordGloss);
foreach (IWfiGloss gloss in wa.MeaningsOC)

var guess_services = new AnalysisGuessServices(m_caches.MainCache);
var sorted_glosses = guess_services.GetSortedGlossGuesses(wa);
foreach (IWfiGloss gloss in sorted_glosses)
{
int glossCount = 0;

Expand Down

0 comments on commit bea232f

Please sign in to comment.