public void ForeignWordConstructorTest() { var text = "Bonjour"; var target = new ForeignWord(text); Check.That(target.Text).IsEqualTo(text); Check.That(target.UsedAsType).IsNull(); }
public void UsedAsTypeTest() { var text = "Bonjour"; var target = new ForeignWord(text); var expected = typeof(Interjection); Type actual; target.UsedAsType = expected; actual = target.UsedAsType; Check.That(actual).IsEqualTo(expected); }
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 void NewThings() { string[] samples = new string[] { CorpusTexts.ProfesorAndMadMan, CorpusTexts.UnpaText, CorpusTexts.Gilgamesh, CorpusTexts.SampleText1, CorpusTexts.SampleText3, CorpusTexts.Lao, CorpusTexts.GeorgeSong, CorpusTexts.CrazyAnimal, CorpusTexts.CrazyAnimal2 //,CorpusTexts.JanSin //Too many neologisms to cope. , CorpusTexts.RuneDanceSong , CorpusTexts.janPusaRice , CorpusTexts.janPend }; foreach (string sample in samples) { //Split, normalize, tokenize, find words. TokenParserUtils tp = new TokenParserUtils(); Dictionary <string, string> stuff = new Dictionary <string, string>(); foreach (Token toke in tp.ValidTokens(sample).Distinct()) { if (toke.CheckIsCompoundWord(toke.Text)) { if (!stuff.ContainsKey(toke.Text)) { stuff.Add(toke.Text, "Compound"); } } if (toke.Text.StartCheck("#") && toke.CheckIsNumber(toke.Text)) { //Should just have to verify we can parse. No need for dictionary. if (!stuff.ContainsKey(toke.Text)) { stuff.Add(toke.Text, "Number"); } } if (toke.CheckIsProperModifier(toke.Text)) { if (!stuff.ContainsKey(toke.Text)) { stuff.Add(toke.Text, "Proper"); } } if (ForeignWord.IsForeign(toke.Text)) { if (!stuff.ContainsKey(toke.Text)) { stuff.Add(toke.Text, "Proper"); } } if (Neologism.IsNeologism(toke.Text)) { if (!stuff.ContainsKey(toke.Text)) { stuff.Add(toke.Text, "Neologism"); } } } foreach (var t in stuff) { Console.WriteLine(t.Value + " " + t.Key); } } }