public void NewGlossExistingLexEntryAllomorphNewLexSense() { int hvoCba0_0 = GetCbaHvo(0, 0, 0); m_sandbox.SwitchWord(hvoCba0_0, false); string formLexEntry = "xxxab"; ITsString tssLexEntryForm = StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs); string formAllomorph = "xxxa"; ITsString tssAllomorphForm = StringUtils.MakeTss(formAllomorph, Cache.DefaultVernWs); // first create an entry with a matching allomorph that doesn't match 'verb' POS we will be selecting in the sandbox ILexEntry lexEntry_NounPos; ILexSense lexSense_NounPos; SetupLexEntryAndSense("xxxab", "0.0.xxxab_NounPos", "noun", out lexEntry_NounPos, out lexSense_NounPos); IMoStemAllomorph allomorph0 = lexEntry_NounPos.AlternateFormsOS.Append(new MoStemAllomorph()) as IMoStemAllomorph; allomorph0.Form.SetAlternativeTss(tssAllomorphForm); // now create the entry we want to match, that has a 'verb' POS. ILexEntry lexEntry1_Entry; ILexSense lexEntry1_Sense1; SetupLexEntryAndSense("xxxab", "0.0.xxxab_VerbPos", "verb", out lexEntry1_Entry, out lexEntry1_Sense1); IMoStemAllomorph allomorph = lexEntry1_Entry.AlternateFormsOS.Append(new MoStemAllomorph()) as IMoStemAllomorph; allomorph.Form.SetAlternativeTss(tssAllomorphForm); // mark the count of LexEntries int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count; // add a new word gloss ITsString tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa"); int hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0); WfiWordform wf = new WfiWordform(Cache, hvoWf); // set word pos to verb int hvoSbWordPos = m_sandbox.GetComboItemHvo(InterlinLineChoices.kflidWordPos, 0, "transitive verb"); m_sandbox.SelectItemInCombo(InterlinLineChoices.kflidWordPos, 0, hvoSbWordPos); // confirm the analysis (making a real analysis and a LexSense) int hvoGloss = m_sandbox.ConfirmAnalysis(); WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss); // make sure we didn't add entries to the Lexicon. int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count; Assert.AreEqual(cEntriesOrig, cEntriesAfter); // confirm we have only one analysis and that it is monomorphemic WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis; Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform."); Assert.AreEqual(1, wf.AnalysesOC.Count); Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count); Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count); // make sure the strings of the wfi gloss matches the strings of the lex gloss. ValidateSenseWithAnalysis(m_sandbox.GetLexSenseForWord(), wfiGloss, hvoSbWordPos, true, allomorph); }
private void LaunchRespellerDlgOnWord(ITsString tss) { if (tss == null || string.IsNullOrEmpty(tss.Text)) { return; } FdoCache cache = m_mediator.PropertyTable.GetValue("cache") as FdoCache; int hvoWordform = WfiWordform.FindOrCreateWordform(cache, tss); if (hvoWordform == 0) { return; // paranoia. } IWfiWordform wf = WfiWordform.CreateFromDBObject(cache, hvoWordform); using (RecordClerk.ListUpdateHelper luh = new RecordClerk.ListUpdateHelper(m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk)) { // Launch the Respeller Dlg. using (RespellerDlg dlg = new RespellerDlg()) { XWindow xwindow = m_mediator.PropertyTable.GetValue("window") as XWindow; if (dlg.SetDlgInfo2(wf, m_mediator, m_configurationParameters)) { dlg.ShowDialog(xwindow); } else { MessageBox.Show(MEStrings.ksCannotRespellWordform); } } // We assume that RespellerDlg made all the necessary changes to relevant lists. // no need to reload due to a propchange (e.g. change in paragraph contents). luh.TriggerPendingReloadOnDispose = false; } }
/// <summary> /// Handle a right mouse up, invoking an appropriate context menu. /// </summary> /// <param name="pt"></param> /// <param name="rcSrcRoot"></param> /// <param name="rcDstRoot"></param> /// <returns></returns> protected override bool DoContextMenu(IVwSelection sel, Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot) { // Allow base method to handle spell check problems, if any. if (base.DoContextMenu(sel, pt, rcSrcRoot, rcDstRoot)) { return(true); } XWindow mainWind = this.ParentForm as XWindow; if (mainWind == null || sel == null) { return(false); } ITsString tssWord; sel.GrowToWord().GetSelectionString(out tssWord, " "); TemporaryColleagueParameter tempColleague = null; if (tssWord != null && !string.IsNullOrEmpty(tssWord.Text)) { // We can have a WfiWordformUi as an additional colleague to handle more menu items. // The temporaray colleague handles adding and removing it. int form = WfiWordform.FindOrCreateWordform(Cache, tssWord, true); CmObjectUi ui = CmObjectUi.MakeUi(Cache, form); ui.Mediator = m_mediator; tempColleague = new TemporaryColleagueParameter(m_mediator, ui, false); } mainWind.ShowContextMenu("mnuIText-RawText", new Point(Cursor.Position.X, Cursor.Position.Y), tempColleague, null); return(true); }
public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel) { CheckDisposed(); // no need to parse if we don't have a connection. if (this.Connection == null) { return; } // If someone updated the wordform inventory with a real wordform, schedule it to be parsed. if (tag == (int)WfiWordform.WfiWordformTags.kflidForm) { // the form of this WfiWordform was changed, so update its parse info. UpdateWordformAsap(WfiWordform.CreateFromDBObject(m_cache, hvo) as WfiWordform); } // Note: typically when adding a new WfiWordform to WordformInventory, it will not // have it's form set. So, there's no point in checking for that case. // It's sufficient to check for change in Form. //else if (tag == (int)WordformInventory.WordformInventoryTags.kflidWordforms && // cvIns == 1 && cvDel == 0) //{ // // find the item with the highest id. // int[] hvosWf = m_cache.LangProject.WordformInventoryOA.WordformsOC.HvoArray; // List<int> hvosSorted = new List<int>(hvosWf); // hvosSorted.Sort(); // int hvoWfNew = hvosSorted[hvosSorted.Count - 1]; // // Schedule this one to be parsed. // WfiWordform wf = WfiWordform.CreateFromDBObject(m_cache, hvoWfNew) as WfiWordform; // // no need to update // UpdateWordformAsap(wf); //} }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } base.Dispose(disposing); if (disposing) { //RightMouseClickedEvent -= new FwRightMouseClickEventHandler(InterlinDocChild_RightMouseClickedEvent); if (m_oneAnalSandbox != null) { if (!Controls.Contains(m_oneAnalSandbox)) { m_oneAnalSandbox.Dispose(); } } if (m_vc != null) { m_vc.Dispose(); } } m_oneAnalSandbox = null; m_vc = null; m_configurationNode = null; m_wordform = null; }
public bool OnClearSelectedWordParserAnalyses(object argument) { WfiWordform wf = CurrentWordform; if (wf == null) { MessageBox.Show(ParserUIStrings.ksSelectWordFirst); } else { if (CurrentWordformHvo > 0) { using (WfiWordformUi wfui = new WfiWordformUi(WfiWordform.CreateFromDBObject(m_cache, CurrentWordformHvo))) { if (m_cache.DatabaseAccessor.IsTransactionOpen()) { m_cache.DatabaseAccessor.CommitTrans(); } m_cache.DatabaseAccessor.BeginTrans(); DbOps.ExecuteStoredProc( m_cache, string.Format("EXEC RemoveParserApprovedAnalyses$ {0}", CurrentWordformHvo), null); m_cache.DatabaseAccessor.CommitTrans(); wfui.UpdateWordsToolDisplay(CurrentWordformHvo, false, false, true, true); } } } return(true); //we handled this. }
/// <summary> /// Collect up a set of unique WfiWordforms. /// </summary> /// <param name="wfi"></param> /// <param name="ws"></param> /// <param name="wordforms">Table of unique wordforms.</param> /// <param name="buffer"></param> private void GetUniqueWords(Dictionary <string, IWfiWordform> wordforms, string buffer) { int start = -1; // -1 means we're still looking for a word to start. int length = 0; int totalLengh = buffer.Length; for (int i = 0; i < totalLengh; i++) { bool isWordforming = m_lgCharPropEngineVern.get_IsWordForming(buffer[i]); if (isWordforming) { length++; if (start < 0) //first character in this word? { start = i; } } if ((start > -1) && // had a word and found yet? (!isWordforming || i == totalLengh - 1 /*last char of the input*/)) { string word = buffer.Substring(start, length); if (!wordforms.ContainsKey(word)) { wordforms.Add(word, WfiWordform.FindOrCreateWordform(m_cache, word, m_ws)); } length = 0; start = -1; } } }
public bool OnParseCurrentWord(object argument) { CheckDisposed(); WfiWordform wf = CurrentWordform; if (wf == null) { MessageBox.Show(ParserUIStrings.ksSelectWordFirst); } else { if (Connection == null) { ConnectToParser(false); } else { ParserScheduler parser = Connection.Parser; if (parser != null) { parser.LoadGrammarAndLexiconIfNeeded(); } } UpdateWordformAsap(wf); } return(true); //we handled this. }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tests adding a word /// </summary> /// <param name="cache">the FdoCache</param> /// ------------------------------------------------------------------------------------ protected void AddWord(FdoCache cache) { const string kWordForm = "FDOCompetingTransactions"; ILangProject lp = cache.LangProject; IWfiWordform word = WfiWordform.FindOrCreateWordform(m_fdoCache, kWordForm, lp.DefaultVernacularWritingSystem); word.AnalysesOC.Add(new WfiAnalysis()); }
/// <summary> /// Make one. Everything interesting happens when it is given a root object, however. /// </summary> /// <param name="cache"></param> /// <param name="hvoAnalysis"></param> /// <param name="configurationNode"></param> /// <param name="stringTable"></param> public AnalysisInterlinearRS(FdoCache cache, int hvoAnalysis, XmlNode configurationNode, StringTable stringTable) : base(cache) { m_configurationNode = configurationNode; m_hvoWfiAnalysis = hvoAnalysis; m_wordform = (WfiWordform)CmObject.CreateFromDBObject(m_fdoCache, m_fdoCache.GetOwnerOfObject(m_hvoWfiAnalysis), false); // RightMouseClickedEvent += new FwRightMouseClickEventHandler(InterlinDocChild_RightMouseClickedEvent); }
private void m_updateTimer_Elapsed(object sender, EventArgs myEventArgs) { if (!InWordsAnalyses) { TraceVerboseLine("ParserListener:Timer not in Analyses tool - don't process timer message."); return; } TraceVerbose(" <<updateTimer,"); TraceVerbose(" TID=" + System.Threading.Thread.CurrentThread.GetHashCode() + " "); if (m_busy) { TraceVerbose(" THE BUSY MEMBER IS ALREADY SET. STILL PROCESSING LAST TIMER MESSAGE."); TraceVerboseLine(" Done>>"); return; } int currentWordformHvo = CurrentWordformHvo; if (!m_busy && currentWordformHvo > 0) { m_busy = true; try { // SyncMsg.ksyncSimpleEdit is added to Sync$ table in ParseFiler for every wordform, // whether it was changed, or not. using (WfiWordformUi wfui = new WfiWordformUi(CurrentWordform)) { foreach (int id in SimpleEdits) { m_maxID = id; wfui.UpdateWordsToolDisplay(currentWordformHvo, false, false, true, true); } } // SyncMsg.ksyncFullRefresh is added to Sync$ table in ParseFiler for every wordform, // but only when its count of analyses was changed. foreach (int[] ints in FullRefreshes) { m_maxIDAnal = ints[0]; int wfID = ints[1]; // it is possible for this word form to no longer be valid. The parser thread could have // added this sync record before the main thread removed it. See LT-9618 if (m_cache.IsValidObject(wfID)) { using (WfiWordformUi wfui = new WfiWordformUi(WfiWordform.CreateFromDBObject(m_cache, wfID))) { wfui.UpdateWordsToolDisplay(wfui.Object.Hvo, false, false, true, (currentWordformHvo == wfID)); } } } } finally { m_busy = false; } } }
/// <summary> /// Have the utility do what it does. /// </summary> public void Process() { Debug.Assert(m_dlg != null); FdoCache cache = (FdoCache)m_dlg.Mediator.PropertyTable.GetValue("cache"); List <int> wordformIds = DbOps.ReadIntsFromCommand( cache, "SELECT Id FROM WfiWordform", null); int curObjId = 0; if (m_dlg.Mediator != null) { Mediator mediator = m_dlg.Mediator; RecordClerk activeClerk = (RecordClerk)mediator.PropertyTable.GetValue("ActiveClerk"); if (activeClerk != null && activeClerk.Id == "concordanceWords" && activeClerk.CurrentObject != null) { curObjId = activeClerk.CurrentObject.Hvo; } } // Set up progress bar. m_dlg.ProgressBar.Minimum = 0; m_dlg.ProgressBar.Maximum = wordformIds.Count; m_dlg.ProgressBar.Step = 1; // stop parser if it's running. m_dlg.Mediator.SendMessage("StopParser", null); if (wordformIds.Count > 0) { if (cache.DatabaseAccessor.IsTransactionOpen()) { cache.DatabaseAccessor.CommitTrans(); } foreach (int wfId in wordformIds) { cache.DatabaseAccessor.BeginTrans(); DbOps.ExecuteStoredProc( cache, string.Format("EXEC RemoveParserApprovedAnalyses$ {0}", wfId), null); cache.DatabaseAccessor.CommitTrans(); using (WfiWordformUi wfui = new WfiWordformUi(WfiWordform.CreateFromDBObject(cache, wfId))) { wfui.UpdateWordsToolDisplay(curObjId, false, false, true, true); } m_dlg.ProgressBar.PerformStep(); } } else { m_dlg.ProgressBar.PerformStep(); } }
public void GetFormOfWordform() { CheckDisposed(); int hvo = m_fdoCache.LangProject.WordformInventoryOA.WordformsOC.HvoArray[0]; //9749; //"ak" IWfiWordform w = WfiWordform.CreateFromDBObject(m_fdoCache, hvo); String s = w.Form.VernacularDefaultWritingSystem; Assert.IsNotNull(s); Assert.IsTrue(s.Length > 0); }
/// <summary> /// Put the wordform in the highest priority queue of the Parser /// </summary> /// <param name="wf"></param> public void UpdateWordformAsap(WfiWordform wf) { CheckDisposed(); ParserConnection con = Connection; if (con != null && con.Parser != null && wf.Form.VernacularDefaultWritingSystem != null) { con.Parser.ScheduleOneWordformForUpdate(wf.Hvo, WordWorks.Parser.ParserScheduler.Priority.ASAP); } }
private IWfiAnalysis SetupAnalysisForEntry(int hvoCba0_0, string gloss, ILexSense lexEntry1_Sense1, out WfiWordform wf) { int hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0); wf = new WfiWordform(Cache, hvoWf); IWfiAnalysis analysis = wf.AnalysesOC.Add(new WfiAnalysis()); analysis.CategoryRA = (lexEntry1_Sense1.MorphoSyntaxAnalysisRA as MoStemMsa).PartOfSpeechRA; IWfiGloss wfigloss = analysis.MeaningsOC.Add(new WfiGloss()); wfigloss.Form.SetAlternative(gloss, Cache.DefaultAnalWs); return(analysis); }
private string FormOfWord(int hvo) { try { WfiWordform word = new WfiWordform(m_cache, hvo); return(word.Form.VernacularDefaultWritingSystem); } catch (Exception) { Debug.Assert(false, "The word returned in msg from parser apparently doesn't exist in db"); return(ParserUIStrings.ksUnknown); } }
private void VerifyDoneStateApplyTwoAndCopyAnalyses() { VerifyDoneStateApplyTwo(); IWfiWordform wf = WfiWordform.CreateFromDBObject(Cache, WfiWordform.FindOrCreateWordform(Cache, "ayyy", Cache.DefaultVernWs, false)); VerifyAnalysis(wf, "axe", 0, "axx", "axe", "first mono"); VerifyAnalysis(wf, "chopper", -1, null, null, "second gloss"); VerifyAnalysis(wf, "cut", 0, "axx", "cut", "second mono"); VerifyAnalysis(wf, "cut.it", 0, "ax", "cut", "first morph cut.it"); VerifyAnalysis(wf, "cut.it", 1, "x", "it", "2nd morph cut.it"); VerifyAnalysis(wf, "not.rude", 0, "a", "not", "first morph not.rude"); VerifyAnalysis(wf, "not.rude", 1, "xx", "rude", "2nd morph not.rude"); }
private void btnTrace_Click(object sender, System.EventArgs e) { FdoOwningCollection <IWfiWordform> words = m_selectedFdoCache.LangProject.WordformInventoryOA.WordformsOC; if (words.Count == 0) { MessageBox.Show("Can't do that, because there are no wordforms in this project."); return; } IWfiWordform word = WfiWordform.CreateFromDBObject(m_selectedFdoCache, words.HvoArray[0]); m_selectedParserConnection.TryAWordAsynchronously(word.Form.VernacularDefaultWritingSystem, true); }
public void NewGlossNewLexEntryNewLexSense() { // load sandbox for first 'xxxa' int hvoCba0_0 = GetCbaHvo(0, 0, 0); m_sandbox.SwitchWord(hvoCba0_0, false); // verify that the word gloss is empty ITsString tssEmpty = StringUtils.MakeTss("", Cache.DefaultAnalWs); ITsString tssWordGloss = m_sandbox.GetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs); CompareTss(tssEmpty, tssWordGloss); // add a new word gloss and confirm the analysis. ITsString tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa"); // mark the count of LexEntries int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count; // verify no analyses exist for this wordform; int hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0); WfiWordform wf = new WfiWordform(Cache, hvoWf); Assert.AreEqual(0, wf.AnalysesOC.Count); // set word pos, to first possibility (e.g. 'adjunct') int hvoSbWordPos = m_sandbox.SelectIndexInCombo(InterlinLineChoices.kflidWordPos, 0, 0); Assert.IsFalse(hvoSbWordPos == 0); // select nonzero pos // confirm the analysis (making a real analysis and a LexSense) int hvoGloss = m_sandbox.ConfirmAnalysis(); WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss); CompareTss(tssWordGlossInSandbox, wfiGloss.Form.GetAlternativeTss(Cache.DefaultAnalWs)); // confirm we have only one analysis and that it is monomorphemic WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis; Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform."); Assert.AreEqual(1, wf.AnalysesOC.Count); Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count); Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count); // make sure the strings of the wfi gloss matches the strings of the lex gloss. ValidateSenseWithAnalysis(m_sandbox.GetLexSenseForWord(), wfiGloss, hvoSbWordPos); // make sure a new entry is in the Lexicon. int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count; Assert.AreEqual(cEntriesOrig + 1, cEntriesAfter); }
private void CreateTryAWordSandbox() { // skip if it's before we've set the word if (m_sWordForm == null) { return; } // skip if it's before we've set up the rootsite control if (m_rootb == null) { return; } // skip if we're not visible if (!Visible) { return; } //Debug.WriteLine("TryAWordRootSite:WordForm - creating sandbox for " + m_sWordForm.Text); int hvoWordform = WfiWordform.FindOrCreateWordform(m_fdoCache, m_sWordForm, false); //if (m_fdoCache.IsDummyObject(hvo)) // m_wordform = new WfiWordform(); m_wordform = WfiWordform.CreateFromDBObject(m_fdoCache, hvoWordform); m_rootb.SetRootObject(hvoWordform, m_vc, m_kfragSingleInterlinearAnalysisWithLabels, m_styleSheet); //Debug.Assert(m_tryAWordSandbox == null); m_tryAWordSandbox = new TryAWordSandbox(m_fdoCache, Mediator, StyleSheet, m_vc.LineChoices, hvoWordform); m_tryAWordSandbox.Visible = false; Controls.Add(m_tryAWordSandbox); SetSandboxSize(); SetSandboxLocation(); m_tryAWordSandbox.Visible = true; SetBackgroundColor(); int height = Math.Max(ScrollRange.Height, m_tryAWordSandbox.Height) + SystemInformation.HorizontalScrollBarHeight; if (Height != height) { Height = height; } m_tryAWordSandbox.SizeChanged += new EventHandler(m_tryAWordSandbox_SizeChanged); //m_tryAWordSandbox.Focus(); }
// Make some sort of wfics for the text of the specified paragraph. Assumes no double spaces! // Caches results and does not repeat on same para internal int[] MakeAnnotations(StTxtPara para) { int[] previous; if (m_annotations.TryGetValue(para.Hvo, out previous)) { return(previous); } string contents = para.Contents.Text; string[] words = contents.Split(new char[] { ' ', '.' }); int ich = 0; List <int> results = new List <int>(); ICmAnnotationDefn WficType = CmAnnotationDefn.Twfic(Cache); foreach (string word in words) { if (word == "") { ich++; continue; } WfiWordform wordform = new WfiWordform(); Cache.LangProject.WordformInventoryOA.WordformsOC.Add(wordform); wordform.Form.SetAlternative(word, Cache.DefaultVernWs); // JohnT: This should ideally use CmBaseAnnotation.CreateUnownedCba. But most or all uses of this // method are memory-only tests, and that method requires a database. CmBaseAnnotation cba = new CmBaseAnnotation(); Cache.LangProject.AnnotationsOC.Add(cba); cba.BeginOffset = ich; ich += word.Length; cba.EndOffset = ich; ich++; // past space or dot cba.BeginObjectRA = para; cba.AnnotationTypeRA = WficType; //cba.AnnotationTypeRA = ?? can we get CmAnnotationDefn.Twfic(Cache) with a non-database cache? WfiAnalysis analysis = new WfiAnalysis(); wordform.AnalysesOC.Add(analysis); WfiGloss gloss = new WfiGloss(); analysis.MeaningsOC.Add(gloss); gloss.Form.SetAlternative(word + "Gloss" + ich, Cache.DefaultAnalWs); cba.InstanceOfRA = gloss; results.Add(cba.Hvo); } int[] result = results.ToArray(); m_annotations[para.Hvo] = result; return(result); }
public void TestFDOAnalysisAddRemove() { CheckDisposed(); const string kWordForm = "ak"; ILangProject lp = m_fdoCache.LangProject; IWfiWordform word = WfiWordform.FindOrCreateWordform(m_fdoCache, kWordForm, lp.DefaultVernacularWritingSystem); word.AnalysesOC.Add(new WfiAnalysis()); int[] hvos = word.AnalysesOC.HvoArray; foreach (int hvo in hvos) { word.AnalysesOC.Remove(hvo); } Assert.AreEqual(0, word.AnalysesOC.Count, "Analyses removal failed."); }
public void PickLexGlossCreatingNewAnalysis() { int hvoCba0_0 = GetCbaHvo(0, 0, 0); m_sandbox.SwitchWord(hvoCba0_0, false); ILexEntry lexEntry1_Entry; ILexSense lexEntry1_Sense1; SetupLexEntryAndSense("xxxa", "0.0.xxxa", out lexEntry1_Entry, out lexEntry1_Sense1); // mark the count of LexEntries int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count; // add a new word gloss ITsString tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa"); int hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0); WfiWordform wf = new WfiWordform(Cache, hvoWf); // set word pos, to first possibility (e.g. 'adjunct') int hvoSbWordPos = m_sandbox.SelectIndexInCombo(InterlinLineChoices.kflidWordPos, 0, 0); // confirm the analysis (making a real analysis and a LexSense) int hvoGloss = m_sandbox.ConfirmAnalysis(); WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss); // make sure we didn't add entries or senses to the Lexicon. int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count; Assert.AreEqual(cEntriesOrig, cEntriesAfter); Assert.AreEqual(1, lexEntry1_Entry.SensesOS.Count); // make sure the sense matches the existing one. ILexSense sense = m_sandbox.GetLexSenseForWord(); Assert.AreEqual(lexEntry1_Sense1.Hvo, sense.Hvo); // make sure the morph is linked to our lexicon sense, msa, and part of speech. ValidateSenseWithAnalysis(sense, wfiGloss, hvoSbWordPos); // confirm we have created a new analysis and that it is monomorphemic WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis; Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform."); Assert.AreEqual(1, wf.AnalysesOC.Count); Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count); Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count); }
public void VectorEnumerator() { CheckDisposed(); FdoOwningCollection <IWfiWordform> oc = m_fdoCache.LangProject.WordformInventoryOA.WordformsOC; //do this two times to reduce the interference of which method went first. for (int i = 0; i < 2; i++) { //test using hvos and no pre-caching int[] hvos = oc.HvoArray; foreach (int hvo in hvos) { WfiWordform word; word = new WfiWordform(m_fdoCache, hvo); } } }
/// <summary> /// Verify everything any test cares about concerning the initial state. /// Used after various Undo operations to verify success. /// </summary> private void VerifyStartingState() { string text = m_para1.Contents.Text; Assert.AreEqual(text, "Axx simplexx testxx withxx axx lotxx ofxx wordsxx endingxx inxx xx", "para 1 changes should be undone"); text = m_para2.Contents.Text; Assert.AreEqual(text, "axx sentencexx axx havingxx axx lotxx ofxx axx", "para 2 changes should be undone"); VerifyTwfic(m_cba2.Hvo, "axx sentencexx axx havingxx axx ".Length, "axx sentencexx axx havingxx axx lotxx".Length, "following Twfic"); VerifyTwfic(m_para1Occurrences[0], 0, "Axx".Length, "first para 1 Twfic changed"); VerifyTwfic(m_para1Occurrences[1], "Axx simplexx testxx withxx ".Length, "Axx simplexx testxx withxx axx".Length, "first para 1 Twfic changed"); VerifyTwfic(m_para2Occurrences[0], 0, "axx".Length, "first Twfic changed"); VerifyTwfic(m_para2Occurrences[1], "axx sentencexx ".Length, "axx sentencexx axx".Length, "first Twfic changed"); VerifyTwfic(m_para2Occurrences[2], "axx sentencexx axx havingxx ".Length, "axx sentencexx axx havingxx axx".Length, "second Twfic changed"); VerifyTwfic(m_para2Occurrences[3], "axx sentencexx axx havingxx axx lotxx ofxx ".Length, "axx sentencexx axx havingxx axx lotxx ofxx axx".Length, "final (unchanged) Twfic"); IWfiWordform wf = WfiWordform.CreateFromDBObject(Cache, WfiWordform.FindOrCreateWordform(Cache, "ayyy", Cache.DefaultVernWs, false)); //the wordform becomes real, and that is not undoable. //Assert.IsTrue(wf.IsDummyObject, "should have deleted the WF"); Assert.AreEqual(0, Cache.GetVectorSize(wf.Hvo, (int)WfiWordform.WfiWordformTags.kflidAnalyses), "when undone ayyy should have no analyses"); IWfiWordform wfOld = WfiWordform.CreateFromDBObject(Cache, WfiWordform.FindOrCreateWordform(Cache, "axx", Cache.DefaultVernWs, false)); Assert.AreEqual((int)SpellingStatusStates.undecided, wf.SpellingStatus); if (m_wfaAxe != null) { Assert.AreEqual("axx", m_wfaAxe.MorphBundlesOS[0].MorphRA.Form.VernacularDefaultWritingSystem, "lexicon should be restored(axe)"); Assert.AreEqual("axx", m_wfaCut.MorphBundlesOS[0].MorphRA.Form.VernacularDefaultWritingSystem, "lexicon should be restored(cut)"); } Assert.AreEqual(m_cAnalyses, wfOld.AnalysesOC.Count, "original analyes restored"); }
private void VerifyDoneStateApplyAllAndUpdateLexicon() { string text = m_para1.Contents.Text; Assert.AreEqual(text, "Ay simplexx testxx withxx ay lotxx ofxx wordsxx endingxx inxx xx", "expected text changes para 1"); text = m_para2.Contents.Text; Assert.AreEqual(text, "ay sentencexx ay havingxx ay lotxx ofxx ay", "expected text changes para 2"); VerifyTwfic(m_cba2.Hvo, "ay sentencexx ay havingxx ay ".Length, "ay sentencexx ay havingxx ay lotxx".Length, "following Twfic"); VerifyTwfic(m_para1Occurrences[0], 0, "Ay".Length, "first para 1 Twfic changed"); VerifyTwfic(m_para1Occurrences[1], "Ay simplexx testxx withxx ".Length, "Ay simplexx testxx withxx ay".Length, "first para 1 Twfic changed"); VerifyTwfic(m_para2Occurrences[0], 0, "ay".Length, "first Twfic changed"); VerifyTwfic(m_para2Occurrences[1], "ay sentencexx ".Length, "ay sentencexx ay".Length, "first Twfic changed"); VerifyTwfic(m_para2Occurrences[2], "ay sentencexx ay havingxx ".Length, "ay sentencexx ay havingxx ay".Length, "second Twfic changed"); VerifyTwfic(m_para2Occurrences[3], "ay sentencexx ay havingxx ay lotxx ofxx ".Length, "ay sentencexx ay havingxx ay lotxx ofxx ay".Length, "final (unchanged) Twfic"); IWfiWordform wf = WfiWordform.CreateFromDBObject(Cache, WfiWordform.FindOrCreateWordform(Cache, "ay", Cache.DefaultVernWs, false)); Assert.IsFalse(wf.IsDummyObject, "should have a real WF to hold spelling status"); Assert.AreEqual((int)SpellingStatusStates.correct, wf.SpellingStatus); IWfiWordform wfOld = WfiWordform.CreateFromDBObject(Cache, WfiWordform.FindOrCreateWordform(Cache, "axx", Cache.DefaultVernWs, false)); Assert.IsFalse(wfOld.IsDummyObject, "should have a real WF to hold old spelling status"); Assert.AreEqual((int)SpellingStatusStates.incorrect, wfOld.SpellingStatus); Assert.AreEqual("ay", m_wfaAxe.MorphBundlesOS[0].MorphRA.Form.VernacularDefaultWritingSystem, "lexicon should be updated(axe)"); Assert.AreEqual("ay", m_wfaCut.MorphBundlesOS[0].MorphRA.Form.VernacularDefaultWritingSystem, "lexicon should be updated(cut)"); Assert.AreEqual(0, wfOld.AnalysesOC.Count, "old wordform has no analyses"); Assert.AreEqual(2, wf.AnalysesOC.Count, "two analyses survived"); foreach (WfiAnalysis wa in wf.AnalysesOC) { Assert.AreEqual(1, wa.MorphBundlesOS.Count, "only monomorphemic analyses survived"); } }
public void NewGlossExistingLexEntryNewLexSense() { int hvoCba0_0 = GetCbaHvo(0, 0, 0); m_sandbox.SwitchWord(hvoCba0_0, false); string formLexEntry = "xxxa"; ITsString tssLexEntryForm = StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs); int clsidForm; ILexEntry lexEntry1_Entry = LexEntry.CreateEntry(Cache, MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm, "xxxa.existingsense1", null); ILexSense lexEntry1_Sense1 = lexEntry1_Entry.SensesOS[0]; // mark the count of LexEntries int cEntriesOrig = Cache.LangProject.LexDbOA.EntriesOC.Count; // add a new word gloss ITsString tssWordGlossInSandbox = m_sandbox.SetTssInSandbox(InterlinLineChoices.kflidWordGloss, Cache.DefaultAnalWs, "0.0.xxxa"); int hvoWf = WfiWordform.GetWfiWordformFromInstanceOf(Cache, hvoCba0_0); WfiWordform wf = new WfiWordform(Cache, hvoWf); // set word pos, to first possibility (e.g. 'adjunct') int hvoSbWordPos = m_sandbox.SelectIndexInCombo(InterlinLineChoices.kflidWordPos, 0, 0); // confirm the analysis (making a real analysis and a LexSense) int hvoGloss = m_sandbox.ConfirmAnalysis(); WfiGloss wfiGloss = new WfiGloss(Cache, hvoGloss); // make sure we didn't add entries to the Lexicon. int cEntriesAfter = Cache.LangProject.LexDbOA.EntriesOC.Count; Assert.AreEqual(cEntriesOrig, cEntriesAfter); // confirm we have only one analysis and that it is monomorphemic WfiAnalysis wfiAnalysis = wfiGloss.Owner as WfiAnalysis; Assert.AreEqual(wf.Hvo, wfiAnalysis.OwnerHVO, "Expected confirmed analysis to be owned by the original wordform."); Assert.AreEqual(1, wf.AnalysesOC.Count); Assert.AreEqual(1, wfiAnalysis.MorphBundlesOS.Count); Assert.AreEqual(1, wfiAnalysis.MeaningsOC.Count); // make sure the strings of the wfi gloss matches the strings of the lex gloss. ValidateSenseWithAnalysis(m_sandbox.GetLexSenseForWord(), wfiGloss, hvoSbWordPos); }
public void SetGetMultiUnicode() { CheckDisposed(); m_inMemoryCache.InitializeLexDb(); WfiWordform w = new WfiWordform(); Cache.LangProject.WordformInventoryOA.WordformsOC.Add(w); // TEST WRITE string s = "test" + m_rand.Next().ToString(); w.Form.AnalysisDefaultWritingSystem = s; // TEST READ Assert.AreEqual(s, w.Form.AnalysisDefaultWritingSystem); }
/// <summary> /// Verify the expected state of the world after doing (or redoing) changing the spelling of /// the middle two occurrences in paragraph 2. /// </summary> /// <param name="ich2ndOcc"></param> /// <param name="ich3rdOcc"></param> private void VerifyDoneStateApplyTwo() { string text = m_para2.Contents.Text; Assert.AreEqual(text, "axx sentencexx ayyy havingxx ayyy lotxx ofxx axx", "expected text changes should occur"); VerifyTwfic(m_cba2.Hvo, "axx sentencexx ayyy havingxx ayyy ".Length, "axx sentencexx ayyy havingxx ayyy lotxx".Length, "following Twfic"); VerifyTwfic(m_para2Occurrences[0], 0, "axx".Length, "first Twfic changed"); VerifyTwfic(m_para2Occurrences[1], "axx sentencexx ".Length, "axx sentencexx ayyy".Length, "first Twfic changed"); VerifyTwfic(m_para2Occurrences[2], "axx sentencexx ayyy havingxx ".Length, "axx sentencexx ayyy havingxx ayyy".Length, "second Twfic changed"); VerifyTwfic(m_para2Occurrences[3], "axx sentencexx ayyy havingxx ayyy lotxx ofxx ".Length, "axx sentencexx ayyy havingxx ayyy lotxx ofxx axx".Length, "final (unchanged) Twfic"); IWfiWordform wf = WfiWordform.CreateFromDBObject(Cache, WfiWordform.FindOrCreateWordform(Cache, "ayyy", Cache.DefaultVernWs, false)); Assert.IsFalse(wf.IsDummyObject, "should have a real WF to hold spelling status"); Assert.AreEqual((int)SpellingStatusStates.correct, wf.SpellingStatus); }
protected void SetInitialWord() { SetFontInfo(); string sCurrentControl = m_mediator.PropertyTable.GetStringProperty("currentContentControl", null); if (sCurrentControl != null) { if (sCurrentControl != "Analyses" && sCurrentControl != "wordListConcordance") { // use the last wordform used in Try A Word if we're not in a control that lists out wordforms GetLastWordUsed(); return; } } // we are in a control that lists out wordforms; try to get that wordform Object x = m_mediator.PropertyTable.GetValue("concordanceWords-selected"); if (x == null) { // nothing set or no wordforms to use yet GetLastWordUsed(); return; } WfiWordform wordform = null; RecordNavigationInfo info = x as RecordNavigationInfo; if (info != null) { wordform = info.Clerk.CurrentObject as WfiWordform; } if (wordform == null) { // can't find the selected wordform GetLastWordUsed(); return; } SetWordToUse(wordform.Form.VernacularDefaultWritingSystem); }