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

Fix LT-21797: Missing highlights in Analyze tab #61

Merged
merged 1 commit into from
May 24, 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
16 changes: 15 additions & 1 deletion Src/Common/RootSite/CollectorEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public class StackItem
public int m_tag;
/// <summary>Index of the current item</summary>
public int m_ihvo;
/// <summary>String properties of the current item</summary>
public Dictionary<int, string> m_stringProps;
/// <summary>Handles counting of previous occurrences of properties</summary>
public PrevPropCounter m_cpropPrev = new PrevPropCounter();

Expand All @@ -111,6 +113,7 @@ public StackItem(int hvoOuter, int hvo, int tag, int ihvo)
m_hvo = hvo;
m_tag = tag;
m_ihvo = ihvo;
m_stringProps = new Dictionary<int, string>();
}

/// --------------------------------------------------------------------------------
Expand Down Expand Up @@ -333,6 +336,10 @@ protected static SelLevInfo[] ConvertVwEnvStackToSelLevInfo(IList<StackItem> loc
protected IFwMetaDataCache m_mdc = null;
/// <summary>This is used to find virtual property handlers in setting notifiers. See LT-8245</summary>
protected IVwCacheDa m_cda = null;
/// <summary>
/// This is used to store string props for the next object added.
/// </summary>
protected Dictionary<int, string> m_stringProps = new Dictionary<int, string>();
#endregion

#region Constructor
Expand Down Expand Up @@ -843,11 +850,12 @@ public int CurrentObject()

/// ------------------------------------------------------------------------------------
/// <summary>
/// Nothing to do here. None of our collectors cares about string properties (yet).
/// Save string property for the next object.
/// </summary>
/// ------------------------------------------------------------------------------------
public virtual void set_StringProperty(int sp, string bstrValue)
{
m_stringProps[sp] = bstrValue;
}

/// ------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1319,6 +1327,12 @@ public virtual void AddObj(int hvoItem, IVwViewConstructor vc, int frag)
else
ihvo = 0; // not a vector item.
OpenTheObject(hvoItem, ihvo);
// Add any pending string props.
StackItem top = PeekStack;
if (top != null)
top.m_stringProps = m_stringProps;
// Clear pending string props.
m_stringProps = new Dictionary<int, string>();
vc.Display(this, hvoItem, frag);
CloseTheObject();
if (!wasPropOpen)
Expand Down
6 changes: 3 additions & 3 deletions Src/LexText/Interlinear/InterlinVc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +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;
internal const int ktagAnalysisStatus = -64;
// flids for paragraph annotation sequences.
internal int ktagSegmentForms;

Expand Down Expand Up @@ -1822,7 +1822,7 @@ private void DisplayMorphemes()
(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.set_StringProperty(ktagAnalysisStatus, "guess");
}
m_vwenv.AddObj(m_hvoDefault, m_this, kfragAnalysisMorphs);
}
Expand All @@ -1838,7 +1838,7 @@ 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.set_StringProperty(ktagAnalysisStatus, "guess");
}
m_vwenv.AddObj(m_hvoWfiAnalysis, m_this, kfragAnalysisMorphs);
}
Expand Down
13 changes: 3 additions & 10 deletions Src/LexText/Interlinear/InterlinearExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ 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 @@ -389,11 +388,6 @@ 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 @@ -608,16 +602,15 @@ public override void AddObjVecItems(int tag, IVwViewConstructor vc, int frag)
break;
case InterlinVc.kfragMorphBundle:
m_writer.WriteStartElement("morphemes");
if (m_fDoingGuessedAnalysis)
StackItem top = this.PeekStack;
if (top != null && top.m_stringProps.ContainsKey(InterlinVc.ktagAnalysisStatus))
{
m_writer.WriteAttributeString("analysisStatus", "guess");
m_writer.WriteAttributeString("analysisStatus", top.m_stringProps[InterlinVc.ktagAnalysisStatus]);
}
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