private IList <IWord> CreateAdjective(IWordData wordData) { //There will be non-functional adjectives here List <IWord> alt = new List <IWord> (); string adjective = wordData.Word + "ly"; if (wordData.Word [wordData.Word.Length - 1] == 'y') { adjective = wordData.Word + "ily"; } /* else if (wordData.Word.Substring(wordData.Word.Length -2, 2) == "le") { * * adjective = wordData.Word.Substring(wordData.Word.Length -1) + "ly"; * * }*/ if (ContainsWordDelegate.Contains(adjective)) { return(alt); } DefaultGram gram = m_gram.Children.Where(child => child.Name == "adjective").First(); string typeClass = adjective [0].IsVowel() ? gram.Classes.Where(c => c == "an").First() : gram.Classes.Where(c => c == "a").First(); alt.Add(new DefaultWord(adjective, gram, NextWordId, typeClass)); //alt.AddRange (CreateDeterminedAndUndetermined (adjective, gram)); return(alt); }
public override System.Collections.Generic.IList<IWord> Identify (IWordData wordData) { if (ContainsWordDelegate == null) { throw new ApplicationException ("English1AdverbIdentifier needs a ContainsWordDelegate"); } List<IWord> alt = new List<IWord> (); if (ContainsWordDelegate.Contains (wordData.Word)) { //Will create duplicates, but should be removed as a post-process //return alt; } string typeClass = wordData.Word [0].IsVowel () ? m_gram.Classes.Where (c => c == "an").First(): m_gram.Classes.Where (c => c == "a").First(); alt.Add (new DefaultWord(wordData.Word, m_gram, NextWordId, typeClass)); //alt.AddRange(CreateDeterminedAndUndetermined(wordData.Word, m_gram)); m_adverbs.Add (wordData.Word); return alt; }
public IList <IWord> Parse(IWordData wordData) { List <IWord> words = new List <IWord> (); if (m_ignore.Contains(wordData.Descriptor)) { //The identifier should not be used (it's probably redundant) return(words); } else if (m_ignoreWords.Contains(wordData.Word)) { //The word should not be used. It might parsed separately return(words); } bool didParse = false; foreach (IGrammarIdentifier identifier in m_identifiers) { if (identifier.CanParse(wordData)) { didParse = true; words.AddRange(identifier.Identify(wordData)); } } if (!didParse && !String.IsNullOrEmpty(wordData.Descriptor)) { Console.WriteLine("Unable to find identifier for: " + wordData.Word + " id: " + wordData.Descriptor); } return(words); }
public override System.Collections.Generic.IList <IWord> Identify(IWordData wordData) { if (ContainsWordDelegate == null) { throw new ApplicationException("English1AdverbIdentifier needs a ContainsWordDelegate"); } List <IWord> alt = new List <IWord> (); if (ContainsWordDelegate.Contains(wordData.Word)) { //Will create duplicates, but should be removed as a post-process //return alt; } string typeClass = wordData.Word [0].IsVowel() ? m_gram.Classes.Where(c => c == "an").First(): m_gram.Classes.Where(c => c == "a").First(); alt.Add(new DefaultWord(wordData.Word, m_gram, NextWordId, typeClass)); //alt.AddRange(CreateDeterminedAndUndetermined(wordData.Word, m_gram)); m_adverbs.Add(wordData.Word); return(alt); }
private string getPlural(IWordData wordData) { Match match = m_pluralIdentifier.Match(wordData.GetRow(2)); string pluralWord = wordData.Word; if (match.Success) { //The word contains an irregular plural definiton pluralWord = wordData.GetRow(2).Substring(match.Index + match.Length); pluralWord = new Regex(@"[A-Za-z]+").Match(pluralWord).Value.ToLower(); } else if (pluralWord.EndsWith("s")) { pluralWord += "es"; } else if (pluralWord.EndsWith("y")) { pluralWord = pluralWord.Substring(0, pluralWord.Length - 2) + "ies"; } else { pluralWord += "s"; } return(pluralWord); }
public override IList<IWord> Identify (IWordData wordData) { List<IWord> alt = new List<IWord> (); if (m_pluralCaseIgnore.IsMatch (wordData.RawData)) { //Plural form only (i e wives) and will be included in the base noun (wife); thus, ignore return alt; } //string article = "the"; DefaultGram pluralGrammar = m_noun.Children.Where (child => child.Name == "plural").First (); if (wordData.Descriptor == "n.pl.") { //Plural only nuon (ie scissors) alt.Add (new DefaultWord (wordData.Word, pluralGrammar, NextWordId)); /*string definedPluralOnly = article + " " + wordData.Word; alt.Add (new DefaultWord (definedPluralOnly, pluralGrammar.Children.Where (child => child.Name == "articulated").First (), NextWordId)); */ alt.AddRange (CreateGenitiveList (alt)); return alt; } string typeClass = wordData.Word [0].IsVowel () ? m_noun.Classes.Where (c => c == "an").First() : m_noun.Classes.Where (c => c == "a").First(); alt.Add (new DefaultWord(wordData.Word, m_noun, NextWordId, typeClass )); // if n.sing., the word is conjugated the same in singular/plural string pluralWord = wordData.Descriptor == "n.sing." ? wordData.Word : getPlural (wordData); alt.Add (new DefaultWord(pluralWord, pluralGrammar, NextWordId)); /* string undetermined = getUnDermined (wordData.Word); alt.Add (new DefaultWord(undetermined, m_noun.Children.Where( child => child.Name == "undetermined").First(), NextWordId)); string definedSingular = article + " " + wordData.Word; alt.Add (new DefaultWord(definedSingular, m_noun.Children.Where( child => child.Name == "articulated").First(), NextWordId)); string definedPlural = article + " " + pluralWord; alt.Add (new DefaultWord(definedPlural, pluralGrammar.Children.Where( child => child.Name == "articulated").First(), NextWordId)); */ alt.AddRange (CreateGenitiveList (alt)); return alt; }
public override IList <IWord> Identify(IWordData wordData) { List <IWord> alt = new List <IWord> (); if (m_pluralCaseIgnore.IsMatch(wordData.RawData)) { //Plural form only (i e wives) and will be included in the base noun (wife); thus, ignore return(alt); } //string article = "the"; DefaultGram pluralGrammar = m_noun.Children.Where(child => child.Name == "plural").First(); if (wordData.Descriptor == "n.pl.") { //Plural only nuon (ie scissors) alt.Add(new DefaultWord(wordData.Word, pluralGrammar, NextWordId)); /*string definedPluralOnly = article + " " + wordData.Word; * * alt.Add (new DefaultWord (definedPluralOnly, pluralGrammar.Children.Where (child => child.Name == "articulated").First (), NextWordId)); */ alt.AddRange(CreateGenitiveList(alt)); return(alt); } string typeClass = wordData.Word [0].IsVowel() ? m_noun.Classes.Where(c => c == "an").First() : m_noun.Classes.Where(c => c == "a").First(); alt.Add(new DefaultWord(wordData.Word, m_noun, NextWordId, typeClass)); // if n.sing., the word is conjugated the same in singular/plural string pluralWord = wordData.Descriptor == "n.sing." ? wordData.Word : getPlural(wordData); alt.Add(new DefaultWord(pluralWord, pluralGrammar, NextWordId)); /* * string undetermined = getUnDermined (wordData.Word); * * alt.Add (new DefaultWord(undetermined, m_noun.Children.Where( child => child.Name == "undetermined").First(), NextWordId)); * * string definedSingular = article + " " + wordData.Word; * * alt.Add (new DefaultWord(definedSingular, m_noun.Children.Where( child => child.Name == "articulated").First(), NextWordId)); * * string definedPlural = article + " " + pluralWord; * * alt.Add (new DefaultWord(definedPlural, pluralGrammar.Children.Where( child => child.Name == "articulated").First(), NextWordId)); */ alt.AddRange(CreateGenitiveList(alt)); return(alt); }
public override bool CanParse(IWordData wordData) { foreach (DefaultGram gram in m_grammar) { if (gram.Key == wordData.Descriptor) { return(true); } } return(false); }
public override IList <IWord> Identify(IWordData wordData) { IList <IWord> list = new List <IWord> (); foreach (DefaultGram gram in m_grammar) { if (gram.Key == wordData.Descriptor) { list.Add(new DefaultWord(wordData.Word, gram, NextWordId)); } } return(list); }
public override bool CanParse (IWordData wordData) { foreach (DefaultGram gram in m_grammar) { if (gram.Key == wordData.Descriptor) { return true; } } return false; }
public override IList<IWord> Identify (IWordData wordData) { IList<IWord> list = new List<IWord> (); foreach (DefaultGram gram in m_grammar) { if (gram.Key == wordData.Descriptor) { list.Add (new DefaultWord(wordData.Word, gram, NextWordId)); } } return list; }
public IList<IWord> Parse (IWordData wordData) { List<IWord> words = new List<IWord> (); if (m_ignore.Contains (wordData.Descriptor)) { //The identifier should not be used (it's probably redundant) return words; } else if (m_ignoreWords.Contains (wordData.Word)) { //The word should not be used. It might parsed separately return words; } bool didParse = false; foreach (IGrammarIdentifier identifier in m_identifiers) { if (identifier.CanParse(wordData)) { didParse = true; words.AddRange(identifier.Identify(wordData)); } } if (!didParse && !String.IsNullOrEmpty(wordData.Descriptor)) { Console.WriteLine ("Unable to find identifier for: " + wordData.Word + " id: " + wordData.Descriptor); } return words; }
public bool Contains (IWordData wordData) { return m_adverbs.Contains (wordData.Word); }
public override bool CanParse (IWordData wordData) { return m_gram.Key == wordData.Descriptor; }
public override IList<IWord> Identify (IWordData wordData) { if (ContainsWordDelegate == null) { throw new ApplicationException ("English1AdjectiveIdentifier needs a ContainsWordDelegate"); } List<IWord> alt = new List<IWord> (); string typeClass; if (wordData.Descriptor == "a.superl.") { //Supqrlative only adjective (ie aftermost) DefaultGram gram = m_gram.Children.Where (child => child.Name == "superlative").First (); typeClass = wordData.Word [0].IsVowel () ? gram.Classes.Where (c => c == "an").First() : gram.Classes.Where (c => c == "a").First(); alt.Add (new DefaultWord (wordData.Word, gram, NextWordId)); //alt.AddRange(CreateArticulated(wordData.Word,gram)); return alt; } if (m_brackets.IsMatch (wordData.RawData)) { //Brackets ( [Compa...) found string bracketsContainer = m_brackets.Match (wordData.RawData).Value.Replace ('\n', ' '); IList<IWord> comp = GetComparative (bracketsContainer); if (comp.Count > 0) { alt.AddRange (comp); } else { Console.WriteLine ("Unable to match Comparative for: " + wordData.Word); } IList<IWord> sup = GetSuperlative (bracketsContainer); if (sup.Count > 0) { alt.AddRange (sup); } else { Console.WriteLine ("Unable to match Superlative for: " + wordData.Word); } } else { //Console.WriteLine ("Unable to match brackets for: " + wordData.Word); } typeClass = wordData.Word [0].IsVowel () ? m_gram.Classes.Where (c => c == "an").First() : m_gram.Classes.Where (c => c == "a").First(); alt.Add (new DefaultWord(wordData.Word, m_gram, NextWordId, typeClass)); //alt.AddRange(CreateDeterminedAndUndetermined(wordData.Word, m_gram)); alt.AddRange (CreateAdjective (wordData)); foreach (IWord word in alt) { m_adjectives.Add (word.Value); } return alt; }
public abstract bool CanParse(IWordData wordData);
public bool Contains(IWordData wordData) { return(m_adverbs.Contains(wordData.Word)); }
public override bool CanParse(IWordData wordData) { return(m_gram.Key == wordData.Descriptor); }
public override bool CanParse (IWordData wordData) { return m_nuonIdentifiers.Contains (wordData.Descriptor); }
private string getPlural(IWordData wordData) { Match match = m_pluralIdentifier.Match (wordData.GetRow (2)); string pluralWord = wordData.Word; if (match.Success) { //The word contains an irregular plural definiton pluralWord = wordData.GetRow (2).Substring (match.Index + match.Length); pluralWord = new Regex (@"[A-Za-z]+").Match (pluralWord).Value.ToLower(); } else if (pluralWord.EndsWith("s")) { pluralWord += "es"; } else if (pluralWord.EndsWith("y")) { pluralWord = pluralWord.Substring(0, pluralWord.Length - 2) + "ies"; } else { pluralWord += "s"; } return pluralWord; }
private IList<IWord> CreateAdjective(IWordData wordData) { //There will be non-functional adjectives here List<IWord> alt = new List<IWord> (); string adjective = wordData.Word + "ly"; if (wordData.Word [wordData.Word.Length - 1] == 'y') { adjective = wordData.Word + "ily"; } /* else if (wordData.Word.Substring(wordData.Word.Length -2, 2) == "le") { adjective = wordData.Word.Substring(wordData.Word.Length -1) + "ly"; }*/ if (ContainsWordDelegate.Contains (adjective)) { return alt; } DefaultGram gram = m_gram.Children.Where (child => child.Name == "adjective").First (); string typeClass = adjective [0].IsVowel () ? gram.Classes.Where (c => c == "an").First() : gram.Classes.Where (c => c == "a").First(); alt.Add (new DefaultWord(adjective, gram, NextWordId, typeClass)); //alt.AddRange (CreateDeterminedAndUndetermined (adjective, gram)); return alt; }
public override IList<IWord> Identify (IWordData wordData) { //If no sub grammar (imp. p.p etc) found, this verb is concidered to be an alteration of another verb and should be ignored. bool didMatchImp = false; bool didPast = false; bool didMatchProgressive = false; List<IWord> alt = new List<IWord> (); if (m_ignoreObsolete.IsMatch(wordData.RawData)) { //Marked as an obsolete word return alt; } if (m_brackets.IsMatch (wordData.RawData)) { //Brackets ( [imp. & p.p. Abashed; ...) found string bracketsContainer = m_brackets.Match (wordData.RawData).Value.Replace ('\n', ' '); IList<IWord> impAndPast = GetImperfectAndPast (bracketsContainer); if (impAndPast.Count > 0) { didMatchImp = true; didPast = true; alt.AddRange (impAndPast); } else { IList<IWord> imp = GetImperfect (bracketsContainer); if (imp.Count > 0) { didMatchImp = true; alt.AddRange (imp); } IList<IWord> past = GetPast (bracketsContainer); if (past.Count > 0) { didPast = true; alt.AddRange (past); } } IList<IWord> progressive = GetProgressive (bracketsContainer); if (progressive.Count > 0) { didMatchProgressive = true; alt.AddRange (progressive); } else { //Try to create one by guessing didMatchProgressive = true; alt.Add (new DefaultWord(CreateProgressive(wordData.Word), m_verb.Children.Where (child => child.Name == "progressive").First (), NextWordId)); } } else { //This is probably a non-consistent verb (it is a form ov another, parseable word and is ignored) //However, it might be a verb which requires manual conjugation. Need word list in order to check... if (!HasTrackedWord (wordData.Word)) { m_untrackedWords.Add (wordData.Word); } return alt; } if (!(didPast && didMatchImp && didMatchProgressive)) { if (!didPast) { badCount++; Console.WriteLine ("Unable to match PAST: " + wordData.Word); } if (!didMatchImp) { badCount++; Console.WriteLine ("Unable to match IMP: " + wordData.Word); } if (!didMatchProgressive) { badCount++; Console.WriteLine ("Unable to match PROGRESSIVE: " + wordData.Word); } return alt; } AddTrackedWord(wordData.Word); if (m_untrackedWords.Contains (wordData.Word)) { m_untrackedWords.Remove (wordData.Word); } alt.Add (new DefaultWord(wordData.Word, m_verb, NextWordId)); string presentThird = GetPresentThird (wordData.Word); alt.Add (new DefaultWord(presentThird, m_verb.Children.Where( child => child.Name == "third").First(), NextWordId)); return alt; }
public abstract bool CanParse (IWordData wordData);
public abstract IList<IWord> Identify(IWordData wordData);
public bool Contains(IWordData wordData) { return(m_adjectives.Contains(wordData.Word)); }
public override IList <IWord> Identify(IWordData wordData) { //If no sub grammar (imp. p.p etc) found, this verb is concidered to be an alteration of another verb and should be ignored. bool didMatchImp = false; bool didPast = false; bool didMatchProgressive = false; List <IWord> alt = new List <IWord> (); if (m_ignoreObsolete.IsMatch(wordData.RawData)) { //Marked as an obsolete word return(alt); } if (m_brackets.IsMatch(wordData.RawData)) { //Brackets ( [imp. & p.p. Abashed; ...) found string bracketsContainer = m_brackets.Match(wordData.RawData).Value.Replace('\n', ' '); IList <IWord> impAndPast = GetImperfectAndPast(bracketsContainer); if (impAndPast.Count > 0) { didMatchImp = true; didPast = true; alt.AddRange(impAndPast); } else { IList <IWord> imp = GetImperfect(bracketsContainer); if (imp.Count > 0) { didMatchImp = true; alt.AddRange(imp); } IList <IWord> past = GetPast(bracketsContainer); if (past.Count > 0) { didPast = true; alt.AddRange(past); } } IList <IWord> progressive = GetProgressive(bracketsContainer); if (progressive.Count > 0) { didMatchProgressive = true; alt.AddRange(progressive); } else { //Try to create one by guessing didMatchProgressive = true; alt.Add(new DefaultWord(CreateProgressive(wordData.Word), m_verb.Children.Where(child => child.Name == "progressive").First(), NextWordId)); } } else { //This is probably a non-consistent verb (it is a form ov another, parseable word and is ignored) //However, it might be a verb which requires manual conjugation. Need word list in order to check... if (!HasTrackedWord(wordData.Word)) { m_untrackedWords.Add(wordData.Word); } return(alt); } if (!(didPast && didMatchImp && didMatchProgressive)) { if (!didPast) { badCount++; Console.WriteLine("Unable to match PAST: " + wordData.Word); } if (!didMatchImp) { badCount++; Console.WriteLine("Unable to match IMP: " + wordData.Word); } if (!didMatchProgressive) { badCount++; Console.WriteLine("Unable to match PROGRESSIVE: " + wordData.Word); } return(alt); } AddTrackedWord(wordData.Word); if (m_untrackedWords.Contains(wordData.Word)) { m_untrackedWords.Remove(wordData.Word); } alt.Add(new DefaultWord(wordData.Word, m_verb, NextWordId)); string presentThird = GetPresentThird(wordData.Word); alt.Add(new DefaultWord(presentThird, m_verb.Children.Where(child => child.Name == "third").First(), NextWordId)); return(alt); }
public override bool CanParse(IWordData wordData) { return(m_identifiers.Contains(wordData.Descriptor)); }
public WordApplication(IWordData wordData) { this.wordData = wordData; }
public override IList <IWord> Identify(IWordData wordData) { if (ContainsWordDelegate == null) { throw new ApplicationException("English1AdjectiveIdentifier needs a ContainsWordDelegate"); } List <IWord> alt = new List <IWord> (); string typeClass; if (wordData.Descriptor == "a.superl.") { //Supqrlative only adjective (ie aftermost) DefaultGram gram = m_gram.Children.Where(child => child.Name == "superlative").First(); typeClass = wordData.Word [0].IsVowel() ? gram.Classes.Where(c => c == "an").First() : gram.Classes.Where(c => c == "a").First(); alt.Add(new DefaultWord(wordData.Word, gram, NextWordId)); //alt.AddRange(CreateArticulated(wordData.Word,gram)); return(alt); } if (m_brackets.IsMatch(wordData.RawData)) { //Brackets ( [Compa...) found string bracketsContainer = m_brackets.Match(wordData.RawData).Value.Replace('\n', ' '); IList <IWord> comp = GetComparative(bracketsContainer); if (comp.Count > 0) { alt.AddRange(comp); } else { Console.WriteLine("Unable to match Comparative for: " + wordData.Word); } IList <IWord> sup = GetSuperlative(bracketsContainer); if (sup.Count > 0) { alt.AddRange(sup); } else { Console.WriteLine("Unable to match Superlative for: " + wordData.Word); } } else { //Console.WriteLine ("Unable to match brackets for: " + wordData.Word); } typeClass = wordData.Word [0].IsVowel() ? m_gram.Classes.Where(c => c == "an").First() : m_gram.Classes.Where(c => c == "a").First(); alt.Add(new DefaultWord(wordData.Word, m_gram, NextWordId, typeClass)); //alt.AddRange(CreateDeterminedAndUndetermined(wordData.Word, m_gram)); alt.AddRange(CreateAdjective(wordData)); foreach (IWord word in alt) { m_adjectives.Add(word.Value); } return(alt); }
public abstract IList <IWord> Identify(IWordData wordData);
public bool Contains (IWordData wordData) { return m_adjectives.Contains (wordData.Word); }