Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lt 21777 Mark guessed analyses #40

Merged
merged 6 commits into from
May 3, 2024
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 @@ -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
Loading