Skip to content

Commit

Permalink
Mark guessed analyses in InterlinearExport (LT-21777) (#40)
Browse files Browse the repository at this point in the history
Add a new attribute to analysis in the export when they are guesses not yet accepted by the user
---------
Co-authored-by: Jason Naylor <[email protected]>
  • Loading branch information
jtmaxwell3 authored May 3, 2024
1 parent 9a21ec4 commit 812f532
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public void ExportBasicInformation_FormSansMorph()
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($@"//morphemes[@analysisStatus='guess']", 1);
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);
}
Expand Down Expand Up @@ -450,6 +451,7 @@ public void ExportVariantTypeInformation_LT9374()
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//word[item[@type='txt']='went']", 1);
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='txt']='went']", 1);
// The guesser adds an analysis for "go".
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//morphemes[@analysisStatus='guess']", 1);
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);
Expand Down Expand Up @@ -600,6 +602,7 @@ public void ExportIrrInflVariantTypeInformation_LT7581_glsAppend()

AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath(@"//morph[item[@type='txt']='went']", 1);
// The guesser adds an analysis for "go".
AssertThatXmlIn.Dom(exportedDoc).HasSpecifiedNumberOfMatchesForXpath($@"//morphemes[@analysisStatus='guess']", 1);
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);
Expand Down
5 changes: 5 additions & 0 deletions Src/LexText/Interlinear/InterlinVc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public class InterlinVc : FwBaseVc, IDisposable
internal const int ktagSegmentFree = -61;
internal const int ktagSegmentLit = -62;
internal const int ktagSegmentNote = -63;
internal const int ktagGuessedAnalysis = -64;
// flids for paragraph annotation sequences.
internal int ktagSegmentForms;

Expand Down Expand Up @@ -1821,6 +1822,8 @@ private void DisplayMorphemes()
bool isHumanGuess = m_this.Decorator.get_IntProp(m_hvoDefault, InterlinViewDataCache.OpinionAgentFlid) !=
(int) AnalysisGuessServices.OpinionAgent.Parser;
m_this.SetGuessing(m_vwenv, isHumanGuess ? ApprovedGuessColor : MachineGuessColor);
// Let the exporter know that this is a guessed analysis.
m_vwenv.AddProp(ktagGuessedAnalysis, m_this, 0);
}
m_vwenv.AddObj(m_hvoDefault, m_this, kfragAnalysisMorphs);
}
Expand All @@ -1835,6 +1838,8 @@ private void DisplayMorphemes()
{
// Real analysis is just word, one we're displaying is a default
m_this.SetGuessing(m_vwenv);
// Let the exporter know that this is a guessed analysis.
m_vwenv.AddProp(ktagGuessedAnalysis, m_this, 0);
}
m_vwenv.AddObj(m_hvoWfiAnalysis, m_this, kfragAnalysisMorphs);
}
Expand Down
12 changes: 12 additions & 0 deletions Src/LexText/Interlinear/InterlinearExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class InterlinearExporter : CollectorEnv
bool m_fDoingInterlinName = false; // true during MSA
bool m_fDoingGlossPrepend = false; // true after special AddProp
bool m_fDoingGlossAppend = false; // true after special AddProp
bool m_fDoingGuessedAnalysis = false; // true after special AddProp
string m_sPendingPrefix; // got a prefix, need the ws from the form itself before we write it.
string m_sFreeAnnotationType;
ITsString m_tssPendingHomographNumber;
Expand Down Expand Up @@ -388,6 +389,11 @@ public override void AddObj(int hvoItem, IVwViewConstructor vc, int frag)

public override void AddProp(int tag, IVwViewConstructor vc, int frag)
{
if (tag == InterlinVc.ktagGuessedAnalysis)
{
m_fDoingGuessedAnalysis = true;
return;
}
if (tag == InterlinVc.ktagGlossPrepend)
{
m_fDoingGlossPrepend = true;
Expand Down Expand Up @@ -602,10 +608,16 @@ public override void AddObjVecItems(int tag, IVwViewConstructor vc, int frag)
break;
case InterlinVc.kfragMorphBundle:
m_writer.WriteStartElement("morphemes");
if (m_fDoingGuessedAnalysis)
{
m_writer.WriteAttributeString("analysisStatus", "guess");
}
break;
default:
break;
}
// Clear here instead of above just to make sure it gets cleared.
m_fDoingGuessedAnalysis = false;
base.AddObjVecItems (tag, vc, frag);
switch(frag)
{
Expand Down

0 comments on commit 812f532

Please sign in to comment.