/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the glosses in all available writing systems to the specified sense. /// </summary> /// ------------------------------------------------------------------------------------ private void AddDbGlossesToSense(LexSense sense, IMultiUnicode glosses) { for (int i = 0; i < glosses.StringCount; i++) { int ws; ITsString tssGloss = glosses.GetStringFromIndex(i, out ws); string icuLocale = m_cache.WritingSystemFactory.GetStrFromWs(ws); sense.Glosses.Add(new LexGloss(icuLocale, tssGloss.Text)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new LexicalEntry from the specified word form in the DB /// </summary> /// ------------------------------------------------------------------------------------ private LexicalEntry CreateEntryFromDbWordform(IWfiWordform wordform) { const int homograph = 1; LexicalEntry entry = new LexicalEntry(LexemeType.Word, wordform.Form.VernacularDefaultWritingSystem.Text, homograph); foreach (IWfiAnalysis dbAnalysis in wordform.AnalysesOC) { // Since our "sense" is really an analysis for a wordform, assume that any meanings // for that analysis are glosses for the same "sense". LexSense sense = new LexSense(kAnalysisPrefix + dbAnalysis.Guid.ToString()); foreach (IWfiGloss gloss in dbAnalysis.MeaningsOC) { AddDbGlossesToSense(sense, gloss.Form); } entry.Senses.Add(sense); } return(entry); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new LexicalEntry from the specified lexical entry in the DB /// </summary> /// ------------------------------------------------------------------------------------ private LexicalEntry CreateEntryFromDbEntry(LexemeType type, ILexEntry dbEntry) { if (type == LexemeType.Word) { throw new ArgumentException("Lexeme type specified can not be created from a LexEntry"); } // A homograph number of zero in the DB means there is only one entry for the wordform. // However, the interface requires there be an entry with a homograph of one even if // there is only one entry. LexicalEntry entry = new LexicalEntry(type, dbEntry.HomographForm, dbEntry.HomographNumber > 0 ? dbEntry.HomographNumber : 1); // Add the senses to the interface (non-DB) entry foreach (ILexSense dbSense in dbEntry.SensesOS) { LexSense sense = new LexSense(dbSense.Guid.ToString()); AddDbGlossesToSense(sense, dbSense.Gloss); entry.Senses.Add(sense); // Add the sense to the list of senses } return(entry); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new LexicalEntry from the specified word form in the DB /// </summary> /// ------------------------------------------------------------------------------------ private LexicalEntry CreateEntryFromDbWordform(IWfiWordform wordform) { const int homograph = 1; LexicalEntry entry = new LexicalEntry(LexemeType.Word, wordform.Form.VernacularDefaultWritingSystem.Text, homograph); foreach (IWfiAnalysis dbAnalysis in wordform.AnalysesOC) { // Since our "sense" is really an analysis for a wordform, assume that any meanings // for that analysis are glosses for the same "sense". LexSense sense = new LexSense(kAnalysisPrefix + dbAnalysis.Guid.ToString()); foreach (IWfiGloss gloss in dbAnalysis.MeaningsOC) AddDbGlossesToSense(sense, gloss.Form); entry.Senses.Add(sense); } return entry; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new LexicalEntry from the specified lexical entry in the DB /// </summary> /// ------------------------------------------------------------------------------------ private LexicalEntry CreateEntryFromDbEntry(LexemeType type, ILexEntry dbEntry) { if (type == LexemeType.Word) throw new ArgumentException("Lexeme type specified can not be created from a LexEntry"); // A homograph number of zero in the DB means there is only one entry for the wordform. // However, the interface requires there be an entry with a homograph of one even if // there is only one entry. LexicalEntry entry = new LexicalEntry(type, dbEntry.HomographForm, dbEntry.HomographNumber > 0 ? dbEntry.HomographNumber : 1); // Add the senses to the interface (non-DB) entry foreach (ILexSense dbSense in dbEntry.SensesOS) { LexSense sense = new LexSense(dbSense.Guid.ToString()); AddDbGlossesToSense(sense, dbSense.Gloss); entry.Senses.Add(sense); // Add the sense to the list of senses } return entry; }