Esempio n. 1
0
        public static void Main(string[] args)
        {
            PluginEnvironment plugenv = new PluginEnvironment(new MainClass());
            string plugbase = "/Users/jrising/projects/virsona/github";
            plugenv.Initialize(plugbase + "/config.xml", new NameValueCollection());

            // Test 1: POS Tagging
            POSTagger tagger = new POSTagger(plugenv);
            List<KeyValuePair<string, string>> tagged = tagger.TagList(StringUtilities.SplitWords("This is a test.", false));
            foreach (KeyValuePair<string, string> kvp in tagged)
                Console.WriteLine(kvp.Key + ": " + kvp.Value);

            // Test 2: Grammar parsing
            GrammarParser parser = new GrammarParser(plugenv);
            IParsedPhrase before = parser.Parse("This is a rug and a keyboard.");
            Console.WriteLine(before.ToString());

            // Test 5: Pluralize nouns and conjugate verbs
            Nouns nouns = new Nouns(plugenv);
            Console.WriteLine("person becomes " + nouns.Pluralize("person"));
            Verbs verbs = new Verbs(plugenv);
            Console.WriteLine("goes becomes " + verbs.ComposePast("goes"));
            Console.WriteLine("eats becomes " + verbs.ComposePrespart(verbs.InputToBase("eats")));

            // Test 3: Paraphrasing
            Random randgen = new Random();
            IParsedPhrase after = parser.Paraphrase(before, null, null, randgen.NextDouble());
            Console.WriteLine(after.Text);

            // Test 4: Look up some indices
            WordNetAccess wordnet = new WordNetAccess(plugenv);
            Console.WriteLine("Synonyms: " + string.Join(", ", wordnet.GetExactSynonyms("rug", WordNetAccess.PartOfSpeech.Noun).ToArray()));
        }
        public VerbChoiceVariable(string name, List<string> options, PluginEnvironment plugenv, WordComparer comparer)
            : base(name, 100.0, new POSTagger(plugenv), new GrammarParser(plugenv))
        {
            this.options = options;
            this.verbs = new Verbs(plugenv);
            this.comparer = comparer;

            this.bases = new List<string>();
            foreach (string option in options)
                bases.Add(verbs.InputToBase(option));
        }
Esempio n. 3
0
        public static string ConjugateToTense(Memory memory, string verb, Verbs.Person person, Concept right, Verbs verbs)
        {
            if (right == memory.past)
                return verbs.ComposePersonable(verb, person, Verbs.Convert.ext_Ved);
            if (right == memory.now)
                return verbs.ComposePersonable(verb, person, Verbs.Convert.ext_Vs);
            if (right == memory.future)
                return "will " + verbs.ComposePersonable(verb, person, Verbs.Convert.ext_V);

            List<string> parts = StringUtilities.SplitWords(right.Name, true);
            bool usedverb = false;
            for (int ii = 0; ii < parts.Count; ii++)
            {
                if (parts[ii] == "en") {
                    parts[ii] = verbs.ComposePersonable(verb, person, Verbs.Convert.ext_Ven);
                    usedverb = true;
                }
                else if (parts[ii] == "ing") {
                    parts[ii] = verbs.ComposePersonable(verb, person, Verbs.Convert.ext_Ving);
                    usedverb = true;
                }
            }
            if (!usedverb)
                parts.Add(verbs.InputToBase(verb));
            return StringUtilities.JoinWords(parts);
        }
Esempio n. 4
0
 public static Concept ConceptNetGetConcept(Memory memory, Verbs verbs, Notion notion, Concept.Kind kind)
 {
     if (kind == Concept.Kind.Event)
         return memory.NewConcept(verbs.InputToBase(notion.Canonical), kind);
     else
         return memory.NewConcept(notion.Canonical, kind);
 }