public NLPActionResult GrammarDumpWithSpellingMistake(define2 define, [AboditNLP.Attributes.Insensitive(caseInsensitive: true, editDistance: 1)] IAmbiguous <ITokenText> token) { if (token.Count() == 1) { st.Say($"I think you perhaps meant 'define {token.First().Text}'"); // But go ahead and show some more aggressive approximate matches anyway intent.DefineSuggestions(st, token.First().Text); } else { st.Say($"I think you perhaps meant 'define' and then one of {string.Join(", ", token.Select(x => x.Text))}"); } return(NLPActionResult.None); }
private FoundConnection FindConnections(IAmbiguous <INoun> nounAmbiguous, IAmbiguous <INoun> classAmbiguous) { bool onlyOne = nounAmbiguous.Count() == 1 && classAmbiguous.Count() == 1; foreach (var @class in classAmbiguous) { foreach (var noun in nounAmbiguous) { if (@class.Synset == noun.Synset) { return(new FoundConnection { Text = "Yes, those words can be synonyms." }); } var edgeSuccessors = SynSet.Graph.Successors <SynSet>(noun.Synset, Relation.RDFSType).ToList(); if (edgeSuccessors.Any(e => e == @class.Synset)) { if (onlyOne) { return new FoundConnection { Text = "Yes, a " + noun.Singular.Text + " is a " + @class.Singular.Text } } ; else { return new FoundConnection { Text = "Yes, a " + noun.Singular.Text + " can be a " + @class.Singular.Text } }; } } } return(null); }
public void GrammarDump(IListener st, IAmbiguous <ITokenText> tokenAmbiguous) { if (tokenAmbiguous.Count() > 1) { st.Say(tokenAmbiguous.First().Text + " could mean one of several things:"); } int i = 0; foreach (var tokenGroup in tokenAmbiguous.GroupBy(t => t.Synset ?? SynSet.Empty)) { st.Say(++i + ". " + tokenGroup.Key.Name); if (tokenGroup.Key == SynSet.Empty) { foreach (var t in tokenGroup) { this.GrammarDump(st, t); } } else { this.GrammarDump(st, tokenGroup.First()); } } }