static CompoundPronouns() { Dictionary = new Dictionary <string, CompoundWord>(25); Glosses = new Dictionary <string, Dictionary <string, Dictionary <string, string[]> > >(25); { var glossMap = new Dictionary <string, Dictionary <string, string[]> >(); { var en = new Dictionary <string, string[]>(); en.Add("mi-wan", new[] { "I", "me" }); glossMap.Add("en", en); } MiWan = new CompoundWord("mi-wan"); Dictionary.Add("mi-wan", MiWan); Glosses.Add("mi-wan", glossMap); } }
public string TryGloss(string language, string pos, Dialect dialect) { //HACK: This is wrong. Should be using Token or some other base class. if (word.ContainsCheck("-")) { CompoundWord cw = new CompoundWord(Text); return(cw.TryGloss(language, pos)); } int digits; bool isNumeric = int.TryParse(word, out digits); if (word.StartCheck("#") || isNumeric) { Number n = new Number(Text); return(n.TryGloss(language, pos, dialect)); } if (Token.IsNeologism(LookupForm(word))) { //A neologism is unglossable. return(word); } //HACK: This is a proper modifer if (LookupForm(word).IsFirstUpperCased()) { if (!ProperModifier.IsProperModifer(LookupForm(word))) { ForeignWord fw = new ForeignWord(word); return(fw.TryGloss(language, pos)); } ProperModifier cw = new ProperModifier(Text); return(cw.TryGloss(language, pos)); } Dictionary <string, Dictionary <string, string[]> > glossMap; Words.Glosses.TryGetValue(LookupForm(word), out glossMap); if (glossMap == null) { return("[missing map for " + Text + "]"); } if (glossMap.ContainsKey(language)) { if (glossMap[language].ContainsKey(pos)) { Random r = new Random(DateTime.Now.Millisecond);//TODO: Make this a part of config string[] possibilities = glossMap[language][pos]; return(possibilities[r.Next(possibilities.Length)]); } } //TraceMissingGloss(); if (Text.ToUpper()[0] != Text[0]) { return("[Error " + pos + " " + Text + " " + language + "]"); } else { return(Text); } }
public ExtendedCompoundWord(CompoundWord w, string spacey, string trimmed) { Word = w; Spacey = spacey; TrimmedWord = trimmed; }
private void ProcessSimpleSentence(bool includePos, Sentence s, List <string> gloss, Dialect dialect) { if (s.Vocative != null) { //TODO: extend to many vocatives? ProcessOneChain(includePos, gloss, dialect, s.Vocative.Nominal); //Need o? } if (s.Exclamation != null) { ProcessingleHeadedPhrase(includePos, gloss, dialect, s.Exclamation.Phrase); } //The whole sentence is a fragment, ending in la. if (s.Fragment != null) { //Simpler to treat fragments as degenerate, independent things. ProcessOneChain(includePos, gloss, dialect, s.Fragment.Nominal); //Need ...? } //mabye lots of fragents, all attached to the sentence. if (s.LaFragment != null && s.LaFragment.Count > 0) { foreach (Fragment bit in s.LaFragment) { if (bit.Nominal != null) { string ordinaryTp = bit.ToString("g").Replace(" ", "-"); if (!ordinaryTp.EndCheck("la")) { ordinaryTp = ordinaryTp + "-la"; } CompoundWord cw = new CompoundWord(ordinaryTp); string attempt = cw.TryGloss("en", "noun"); if (!attempt.StartCheck("[")) { gloss.Add(attempt); } else { ProcessOneChain(includePos, gloss, dialect, bit.Nominal); } } else { string ordinaryTp = bit.ToString("g").Replace(" ", "-"); if (!ordinaryTp.EndCheck("la")) { ordinaryTp = ordinaryTp + "-la"; } CompoundWord cw = new CompoundWord(ordinaryTp); string attempt = cw.TryGloss("en", "noun"); if (!attempt.StartCheck("[")) { gloss.Add(attempt); } else { foreach (PrepositionalPhrase phrase in bit.Prepositionals) { ProcessPrepositionalPhrase(gloss, phrase, includePos, dialect); } } } } } //Although if you have predicates, you should always have subjects. if (s.Subjects != null) { ProcessSubjects(includePos, s, gloss, dialect); } if (s.Predicates != null) { ProcessPredicates(includePos, s, gloss, dialect); } }