/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the requested punctuation form and adds it to the segment's analyses. /// </summary> /// <param name="segment">The segment.</param> /// <param name="form">The form.</param> /// ------------------------------------------------------------------------------------ private static void CreatePuncForm(ISegment segment, ITsString form) { IPunctuationForm puncForm = segment.Services.GetInstance <IPunctuationFormFactory>().Create(); segment.AnalysesRS.Add(puncForm); puncForm.Form = form; }
public void TryGetObject_ORCWithDifferentProps_WsOnly() { IPunctuationForm pf = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create(); pf.Form = TsStringUtils.MakeString(StringUtils.kszObject, Cache.DefaultAnalWs); IPunctuationForm pfDummy; ITsString tssOrcness = TsStringUtils.MakeString(StringUtils.kszObject, Cache.DefaultVernWs); Assert.IsFalse(m_repo.TryGetObject(tssOrcness, out pfDummy)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Verifies that the ith analysis is the expected punctuation form. /// </summary> /// <param name="seg">The segment whose analyses are being verified.</param> /// <param name="puncForm">The expected punctuation form.</param> /// <param name="iAnalysis">The index of the analysis which we expect to be the /// punctuation form corresponding to the given character.</param> /// <returns>The TsString of the form (in case the caller wants to check more stuff) /// </returns> /// ------------------------------------------------------------------------------------ private static ITsString VerifyPunctuationForm(ISegment seg, string puncForm, int iAnalysis) { IPunctuationForm punc = seg.AnalysesRS[iAnalysis] as IPunctuationForm; Assert.IsNotNull(punc, "Expected analysis " + iAnalysis + " to be a punctuation form for: " + puncForm); ITsString form = punc.Form; Assert.AreEqual(puncForm, form.Text); return(form); }
public void TryGetObject_PlainPunctString_Exists() { IPunctuationForm pf = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create(); pf.Form = TsStringUtils.MakeString(".", Cache.DefaultAnalWs); IPunctuationForm pfExisting; ITsString tssPunc = TsStringUtils.MakeString(".", Cache.DefaultVernWs); Assert.IsTrue(m_repo.TryGetObject(tssPunc, out pfExisting)); Assert.AreEqual(pf, pfExisting); }
public void TryGetObject_ORCWithSameProps_WsOnly() { IPunctuationForm pf = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create(); pf.Form = TsStringUtils.MakeString(StringUtils.kszObject, Cache.DefaultAnalWs); IPunctuationForm pfExisting; ITsString tssOrcness = TsStringUtils.MakeString(StringUtils.kszObject, Cache.DefaultAnalWs); Assert.IsTrue(m_repo.TryGetObject(tssOrcness, out pfExisting)); Assert.AreEqual(pf, pfExisting); }
public void TryGetObject_PlainPunctString_NotExists_ORCTableNotEmpty() { IPunctuationForm pf = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create(); ITsStrBldr bldr = TsStringUtils.MakeStrBldr(); TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtNameGuidHot, bldr, 0, 0, Cache.DefaultVernWs); pf.Form = bldr.GetString(); IPunctuationForm pfDummy; ITsString tssPunc = TsStringUtils.MakeString(".", Cache.DefaultVernWs); Assert.IsFalse(m_repo.TryGetObject(tssPunc, out pfDummy)); }
public void TryGetObject_ORCWithSameProps_ObjData() { IPunctuationForm pf = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create(); ITsStrBldr bldr = TsStringUtils.MakeStrBldr(); TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtNameGuidHot, bldr, 0, 0, Cache.DefaultVernWs); pf.Form = bldr.GetString(); IPunctuationForm pfExisting; ITsString tssOrcness = bldr.GetString(); Assert.IsTrue(m_repo.TryGetObject(tssOrcness, out pfExisting)); Assert.AreEqual(pf, pfExisting); }
public void TryGetObject_ORCWithDifferentProps_ObjData() { IPunctuationForm pf = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create(); ITsStrBldr bldr = TsStringUtils.MakeStrBldr(); TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtNameGuidHot, bldr, 0, 0, Cache.DefaultVernWs); pf.Form = bldr.GetString(); IPunctuationForm pfDummy; // Replace the ORC in the builder with a different ORC TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtOwnNameGuidHot, bldr, 0, 1, Cache.DefaultVernWs); ITsString tssOrcness = bldr.GetString(); Assert.IsFalse(m_repo.TryGetObject(tssOrcness, out pfDummy)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates analyses for the words and punctuation forms of the specified segment. Words /// will have WfiWordforms created if they don't already exist. /// </summary> /// <param name="segment">The segment.</param> /// <param name="paraContents">The para contents.</param> /// <param name="ichBeginOffset">The beginning character offset.</param> /// <param name="ichLimOffset">The character offset limit.</param> /// <param name="fCreateGlosses">if set to <c>true</c> create glosses in addition to the /// WfiWordforms for each surface form.</param> /// ------------------------------------------------------------------------------------ public static void CreateAnalyses(ISegment segment, ITsString paraContents, int ichBeginOffset, int ichLimOffset, bool fCreateGlosses) { FdoCache cache = segment.Cache; IFdoServiceLocator servloc = cache.ServiceLocator; if (SegmentBreaker.HasLabelText(paraContents, ichBeginOffset, ichLimOffset)) { IPunctuationForm labelPunc = servloc.GetInstance <IPunctuationFormFactory>().Create(); segment.AnalysesRS.Add(labelPunc); labelPunc.Form = paraContents.GetSubstring(ichBeginOffset, ichLimOffset); } else { ParseSegBaseline(segment, ichBeginOffset, ichLimOffset, (iForm, word, iAnalysis) => { CreateAnalysisForWord(word, segment, cache.DefaultAnalWs, fCreateGlosses); return(true); }, (sPunc, iAnalysis) => CreatePuncForm(segment, cache.TsStrFactory.MakeString(sPunc, cache.DefaultVernWs)), (ichOrc, iAnalysis) => CreatePuncForm(segment, paraContents.Substring(segment.BeginOffset + ichOrc, 1))); } }