public Concept GetConcept(IParsedPhrase phrase) { string name = Nouns.AsSubject(phrase.Text); if (firstsecond) { if (name == "I") { return(memory.you); } else if (name == "you") { return(memory.self); } } else { if (name == "I") { return(memory.self); } else if (name == "you") { return(memory.you); } } return(memory.NewConcept(phrase)); }
public Noun QueryNoun(string wordCase) { string word = wordCase.ToLower(); Nouns.TryGetValue(word, out var value); return(value); }
public override void Initialize() { Nouns.Add("BLUE"); Locked = true; IsMatchingKey = k => object.ReferenceEquals(k, GetObject("palantine\\library_key")); Short = "blue door"; }
public window(string Short, string Outside, params string[] AdditionalNouns) { this.Short = Short; Nouns.Add(Short.Split(' ')); Nouns.Add("WINDOW"); Nouns.Add(AdditionalNouns); this.Outside = Outside; Perform <RMUD.MudObject, RMUD.MudObject>("describe") .Do((viewer, thing) => { var outside = GetObject(Outside) as RMUD.Room; if (outside != null) { RMUD.Core.GlobalRules.ConsiderPerformRule("describe-locale", viewer, outside); } else { SendMessage(viewer, "There seems to be a problem with the window."); } return(RMUD.PerformResult.Stop); }) .Name("Looking through a window rule."); Value <RMUD.MudObject, RMUD.LightingLevel>("emits-light").Do(EmittedLight); }
public torch() { Short = "torch"; Nouns.Add("torch"); Value <RMUD.MudObject, RMUD.LightingLevel>("light level").Do(a => RMUD.LightingLevel.Bright); }
/// <summary> /// Gets the base word based on the type (Part of Speech) passed in. /// </summary> /// <returns>The base word.</returns> /// <param name="baseType">Part of speech.</param> private string GetBaseWord(string baseType) { Random rand = new Random(); string baseWord = null; switch (baseType) { case "noun": baseWord = Nouns.ElementAt(rand.Next(Nouns.Count)); break; case "adjective": baseWord = Adjectives.ElementAt(rand.Next(Adjectives.Count)); break; case "verb": baseWord = Verbs.ElementAt(rand.Next(Verbs.Count)); break; default: baseWord = DefaultBaseWord; break; } return(baseWord); }
public Actor() : base(RelativeLocations.Held | RelativeLocations.Worn, RelativeLocations.Held) { Gender = RMUD.Gender.Male; Nouns.Add("MAN", (a) => a.Gender == RMUD.Gender.Male); Nouns.Add("WOMAN", (a) => a.Gender == RMUD.Gender.Female); }
public lamp() { Nouns.Add("gas", "lamp"); Long = "This little gas lamp somehow manages to fill the endless closet with light."; Value <RMUD.MudObject, RMUD.LightingLevel>("light level").Do(a => RMUD.LightingLevel.Bright); }
public override void Initialize() { Nouns.Add("RED"); Locked = true; IsMatchingKey = k => object.ReferenceEquals(k, GetObject("palantine\\disambig_key")); Short = "red door"; }
public Jupiter() { Nouns.Add("jupiter"); Long = "Jupiter holds in his left hand a gleaming thunderbolt. It glows bright enough to light the entire chamber. In his right, he holds a chisel."; Value <RMUD.MudObject, RMUD.LightingLevel>("light level").Do(a => RMUD.LightingLevel.Bright); }
public override void Initialize() { Short = "map of Port Ivy"; Nouns.Add("port", "ivy", "map", "of"); Long = @"Port Ivy - The Island ·-·-·-·-·-· o: Cathedral / / \ 1: Bed And Breakfast · 1-M-0 ·-· 2: Lighthouse \ A \ · I ·-· | N | · |-CRESCENT ·-· / S S \ 2 · T T B \| R R E ·-·-E EET-E-·-·-A | E R E C D T T T H O | S | | C-·-DOCK · · K \ / / S-·-· · · | \ / / WATER ·-·-· ·-·-· P / ARK-· "; }
public override Phrase Parapharse(Verbs verbs, Nouns nouns, WordNetAccess wordnet, GrammarParser.ParaphraseOptions options, List <Phrase> emphasizes, ref double prob) { if (this is PronounPersonal) { if (word == "I") { return(new PronounPersonal("I")); } else { return(base.Parapharse(verbs, nouns, wordnet, options, emphasizes, ref prob)); } } Phrase synonym = SynonymParaphrase(WordNetAccess.PartOfSpeech.Noun, verbs, nouns, wordnet, options, emphasizes, ref prob); if (synonym == null) { return(base.Parapharse(verbs, nouns, wordnet, options, emphasizes, ref prob)); } else { return(synonym); } }
private void btFindSimilar_Click(object sender, EventArgs e) { tbRes.Clear(); var sb = new StringBuilder(); var v = Verbs.FindSimilar(tbWord.Text, (VerbAspect)cbAspect.SelectedItem); if (v != null) { BuildString(sb, v); } var n = Nouns.FindSimilar(tbWord.Text, (Gender)cbGender.SelectedItem, (Animacy)cbAnimacy.SelectedItem); if (n != null) { BuildString(sb, n); } var a = Adjectives.FindSimilar(tbWord.Text, (Comparability)cbComparability.SelectedItem); if (a != null) { BuildString(sb, a); } tbRes.Text = sb.ToString(); }
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(); try { IParsedPhrase after = parser.Paraphrase(before, null, null, randgen.NextDouble()); Console.WriteLine(after.Text); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } // Test 4: Look up some indices WordNetAccess wordnet = new WordNetAccess(plugenv); List <string> synonyms = null; try { synonyms = wordnet.GetExactSynonyms("rug", WordNetAccess.PartOfSpeech.Noun); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } if (synonyms == null) { Console.WriteLine("Could not find a synonym for 'rug'. Is Memcached installed?"); } else { Console.WriteLine("Synonyms: " + string.Join(", ", synonyms.ToArray())); } }
public override void Initialize() { Short = "round steel door"; Long = "There is a round steel door in the side of the lighthouse."; Nouns.Add("STEEL", "DOOR", "ROUND"); Open = true; }
/// <summary> /// Returns a list of all noun groups that the given noun is a member of /// </summary> public static List <Nouns> GetNounGroupsFromMember(Nouns noun) { List <Nouns> groups = null; _nounToGroupMap.TryGetValue(noun, out groups); return(groups); }
public static Nouns GetModelNoun(string model) { Nouns noun = Nouns.N_NONE; _modelNounMap.TryGetValue(model, out noun); return(noun); }
public TenseRule(double salience, Relations.Relation nounrel, Memory memory, Verbs verbs, Nouns nouns, POSTagger tagger, GrammarParser parser) : base(ArgumentMode.ManyArguments, salience, 2 * 4, 10, tagger, parser) { this.nounrel = nounrel; this.memory = memory; this.verbs = verbs; this.nouns = nouns; }
private static void addNounToGroup(Nouns noun, Nouns group) { if (_nounToGroupMap.ContainsKey(noun) == false) { _nounToGroupMap.Add(noun, new List <Nouns>()); } _nounToGroupMap[noun].Add(group); }
public static int GetChatCount(Nouns noun) { if (_chatCounts.ContainsKey(noun) == false) { return(0); } return(_chatCounts[noun]); }
public override Phrase Parapharse(Verbs verbs, Nouns nouns, WordNetAccess wordnet, GrammarParser.ParaphraseOptions options, List <Phrase> emphasizes, ref double prob) { Paragraph paragraph = new Paragraph(); foreach (Phrase constituent in constituents) { paragraph.constituents.Add(constituent.Parapharse(verbs, nouns, wordnet, options | GrammarParser.ParaphraseOptions.IsStayingStart, emphasizes, ref prob)); } return(paragraph); }
public static int GetTopicCount(Nouns noun, Verbs verb) { int nounverb = (int)noun * (int)Game.Verbs._LAST + (int)verb; if (_topicCounts.ContainsKey(nounverb) == false) { return(0); } return(_topicCounts[nounverb]); }
public static int GetNounVerbCount(Nouns noun, Verbs verb, bool isGabe) { int count; if (_nounVerbCounts.TryGetValue(new NounVerbCombination(noun, verb, isGabe), out count)) { return(count); } return(0); }
public virtual Phrase Parapharse(Verbs verbs, Nouns nouns, WordNetAccess wordnet, GrammarParser.ParaphraseOptions options, List <Phrase> emphasizes, ref double prob) { List <Phrase> newconsts = new List <Phrase>(); foreach (Phrase constituent in constituents) { newconsts.Add(constituent.Parapharse(verbs, nouns, wordnet, options, emphasizes, ref prob)); options &= ~(GrammarParser.ParaphraseOptions.MoveToStart | GrammarParser.ParaphraseOptions.MoveOffStart | GrammarParser.ParaphraseOptions.IsStayingStart); } return(new Phrase(part, newconsts)); }
protected string ProcessNoun(string word, ParserStatesEnum nextState) { var noun = Nouns.GetNounForSynonym(word); if (!string.IsNullOrEmpty(noun)) { _parserStates = nextState; return(noun); } return(string.Empty); }
private bool ProcessNoun2(string word) { var noun = Nouns.GetNounForSynonym(word); if (!string.IsNullOrEmpty(noun)) { _command.Noun2 = noun; return(true); } return(false); }
public Phrase ParaphraseAsSubject(Verbs verbs, Nouns nouns, WordNetAccess wordnet, GrammarParser.ParaphraseOptions options, List <Phrase> emphasizes, ref double prob) { string asSubject = Nouns.AsSubject(Text); if (asSubject == Text) { return(Parapharse(verbs, nouns, wordnet, options, emphasizes, ref prob)); } else { return(new NounPhrase(new Noun(asSubject))); } }
public override Phrase Parapharse(Verbs verbs, Nouns nouns, WordNetAccess wordnet, GrammarParser.ParaphraseOptions options, List <Phrase> emphasizes, ref double prob) { Phrase synonym = SynonymParaphrase(WordNetAccess.PartOfSpeech.Verb, verbs, nouns, wordnet, options, emphasizes, ref prob); if (synonym == null) { return(base.Parapharse(verbs, nouns, wordnet, options, emphasizes, ref prob)); } else { return(synonym); } }
public override void Initialize() { /* * The player wears a velvet cloak. The cloak can be hung or unhung. * Understand "dark" or "black" or "satin" as the cloak. * The description of the cloak is "A handsome cloak, * of velvet trimmed with satin, and slightly splattered with raindrops. * Its blackness is so deep that it almost seems to suck light from the room." */ SetProperty("clothing layer", ClothingModule.ClothingLayer.Outer); SetProperty("clothing part", ClothingModule.ClothingBodyPart.Cloak); SetProperty("wearable?", true); Short = "velvet cloak"; Nouns.Add("dark", "black", "satin", "velvet", "cloak"); Long = "A handsome cloak, of velvet trimmed with satin, and slightly spattered with raindrops. Its blackness is so deep that it almost seems to suck light from the room."; //Carry out taking the cloak: // now the bar is dark. Perform <MudObject, MudObject>("take").Do((actor, thing) => { GetObject <Room>("Bar").AmbientLighting = LightingLevel.Dark; return(PerformResult.Continue); }); //Carry out putting the unhung cloak on something in the cloakroom: // now the cloak is hung; // increase score by 1. //Perform<MudObject, MudObject, MudObject, RelativeLocations>("put") // .When((actor, item, container, relloc) => container is Hook) // .Do((actor, item, container, relloc) => { isHung = true; return PerformResult.Continue; }); //Carry out putting the cloak on something in the cloakroom: // now the bar is lit. Perform <MudObject, MudObject, MudObject, RelativeLocations>("put") .When((actor, item, container, relloc) => actor.Location is Cloakroom) .Do((actor, item, container, relloc) => { GetObject <Room>("Bar").AmbientLighting = LightingLevel.Bright; return(PerformResult.Continue); }); //Carry out dropping the cloak in the cloakroom: // now the bar is lit. Perform <MudObject, MudObject>("drop") .When((actor, item) => actor.Location is Cloakroom) .Do((actor, item) => { GetObject <Room>("Bar").AmbientLighting = LightingLevel.Bright; return(PerformResult.Continue); }); //Instead of dropping or putting the cloak on when the player is not in the cloakroom: // say "This isn't the best place to leave a smart cloak lying around." // * Since putting checks dropping, we only need one rule. Check <MudObject, MudObject>("can drop?") .When((actor, item) => !(actor.Location is Cloakroom)) .Do((actor, item) => { SendMessage(actor, "This isn't the best place to leave a smart cloak lying around."); return(CheckResult.Disallow); }); }
private bool ProcessNoun1(string word) { var noun = Nouns.GetNounForSynonym(word); if (!string.IsNullOrEmpty(noun)) { _command.Noun = noun; _parserStates = ParserStatesEnum.Preposition; return(true); } return(false); }