/// <summary> /// Constructs the SWUM for the given node, using this rule. /// </summary> /// <param name="node">The node to construct SWUM for.</param> public override void ConstructSwum(ProgramElementNode node) { if (node is MethodDeclarationNode) { ((MethodDeclarationNode)node).Parse(this.Splitter); this.PosTagger.PreTag(node); base.ConstructSwum(node); } }
/// <summary> /// Determines whether the given node satisfies this rule. /// /// ** Note that calling this method has the effect of stripping any preamble from the given node, and tagging any digits and prepositions. ** /// </summary> /// <param name="node">The node to test.</param> /// <returns>True if the node matches this rule, False otherwise.</returns> public override bool InClass(ProgramElementNode node) { if (node is MethodDeclarationNode) { MethodDeclarationNode mdn = (MethodDeclarationNode)node; mdn.Parse(this.Splitter); this.PosTagger.PreTag(mdn); return(MakeClassification(mdn)); } return(false); }
/// <summary> /// Constructs the SWUM for the given node, using this rule. /// </summary> /// <param name="node">The node to construct SWUM for.</param> public override void ConstructSwum(ProgramElementNode node) { if (node is MethodDeclarationNode) { MethodDeclarationNode mdn = (MethodDeclarationNode)node; //don't need to parse or tag, because there's no name //fill in SWUM mdn.AssignStructuralInformation(this.Splitter, this.PosTagger); mdn.Theme = mdn.Preamble; //TODO: from Emily, how to fill in Action? mdn.SwumRuleUsed = this; } }
/// <summary> /// Constructs the SWUM for the given node, using this rule. /// </summary> /// <param name="node">The node to construct SWUM for.</param> public override void ConstructSwum(ProgramElementNode node) { if (node is MethodDeclarationNode) { var mdn = (MethodDeclarationNode)node; mdn.Action = mdn.ParsedName[0].GetNewWord("handle", PartOfSpeechTag.Verb); this.PosTagger.TagNounPhrase(mdn.ParsedName); mdn.CreateThemeFromPhrases(mdn.Preamble, mdn.ParsedName); SetDefaultUnknownArguments(mdn); mdn.IsReactive = true; mdn.SwumRuleUsed = this; } }
/// <summary> /// Constructs the SWUM for the given node, using this rule. /// </summary> /// <param name="node">The node to construct SWUM for.</param> public override void ConstructSwum(ProgramElementNode node) { if (node is MethodDeclarationNode) { var mdn = (MethodDeclarationNode)node; mdn.AssignStructuralInformation(this.Splitter, this.PosTagger); if (mdn.ReturnType != null && mdn.ReturnType.Name.ToLower() == "void") { ParseReactiveName(mdn); //this also sets the Action, Theme, and arguments } else { this.PosTagger.TagNounPhrase(mdn.ParsedName); mdn.CreateThemeFromPhrases(mdn.Preamble, mdn.ParsedName); mdn.Action = mdn.ParsedName[0].GetNewWord("get", PartOfSpeechTag.Verb); SetDefaultUnknownArguments(mdn); } mdn.SwumRuleUsed = this; } }
/// <summary> /// Constructs the SWUM for the given node, using this rule. /// </summary> /// <param name="node">The node to construct SWUM for.</param> public override void ConstructSwum(ProgramElementNode node) { if (node is MethodDeclarationNode) { var mdn = (MethodDeclarationNode)node; mdn.AssignStructuralInformation(this.Splitter, this.PosTagger); if (mdn.ParsedName[0].Tag != PartOfSpeechTag.Preposition) { //this shouldn't be necessary, because prepositions should have been tagged in tagger.PreTag, which should have been called prior to this method mdn.ParsedName[0].Tag = PartOfSpeechTag.Preposition; Console.Error.WriteLine("LeadingPrepositionRule.ConstructSwum(): found node with untagged preposition: {0}", mdn); } if (mdn.ParsedName.Size() > 1) { this.PosTagger.TagNounPhrase(mdn.ParsedName, 1, mdn.ParsedName.Size() - 1); } mdn.CreateThemeFromPhrases(mdn.Preamble, mdn.ParsedName); //TODO: from Emily, make name proper SecondaryArg string prep = mdn.ParsedName[0].Text.ToLower(); if (prep == "to" || prep == "from") { mdn.Action = mdn.ParsedName[0].GetNewWord("convert", PartOfSpeechTag.Verb); SetDefaultUnknownArguments(mdn); } else if (prep == "on" || prep == "before" || prep == "after") //EventHandlerRule should be run first { ParseReactiveName(mdn); } else { SetDefaultUnknownArguments(mdn); } mdn.SwumRuleUsed = this; } }
/// <summary> /// Performs various actions that should occur prior to further tagging. /// This method tags any digits in the name, identifies and removes any preamble, and tags any prepositions remaining in the name. /// </summary> /// <param name="node">The node to be tagged.</param> public abstract void PreTag(ProgramElementNode node);
/// <summary> /// Does nothing; simply returns; /// </summary> /// <param name="node"></param> public override void PreTag(ProgramElementNode node) { return; }