Ejemplo n.º 1
0
 public StringTagHandler(POSTagger tagger)
     : base("Part of Speech String Tag",
            "Tag each element of a string with a part of speech",
            new StringArgumentType(int.MaxValue, ".+", "buffalo buffalo"),
            LanguageNet.Grammarian.POSTagger.TagEnumerationResultType, 120)
 {
     this.tagger = tagger;
 }
Ejemplo n.º 2
0
 // Describe interface to UnitaryHandler
 public PhraseResolveHandler(POSTagger tagger)
     : base("Phrase List Tag",
            "Resolve the unknown elements contained in a list of Phrases.",
            new EnumerableArgumentType(int.MaxValue, new TypedArgumentType(typeof(IParsedPhrase), new WordPhrase("bufallo", "NN"))),
            LanguageNet.Grammarian.POSTagger.TagEnumerationResultType, 80)
 {
     this.tagger = tagger;
 }
 public EnumerableTagHandler(POSTagger tagger)
 // Describe the action to UnitaryHandler
     : base("Part of Speech List Tag",
            "Tag every element of a grammatical list with a part of speech.",
            new EnumerableArgumentType(int.MaxValue, new StringArgumentType(int.MaxValue, ".+", "buffalo")),
            LanguageNet.Grammarian.POSTagger.TagEnumerationResultType, 100)
 {
     this.tagger = tagger;
 }
Ejemplo n.º 4
0
 // Can we apply the part of speech given by our rule?
 public bool hasToTag(POSTagger tagger)
 {
     for (int ii = 0; ii < tagger.lexBuff[3].Length; ii++)
     {
         if (to.Equals(tagger.lexBuff[3][ii]))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
 // Apply the part of speech to the middle word
 public bool apply(POSTagger tagger)
 {
     if (hasToTag(tagger) && checkContext(tagger))
     {
         tagger.tagBuff[3] = to;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
        // Add the plugins actions and data source
        public InitializeResult Initialize(PluginEnvironment env, Assembly assembly, IMessageReceiver receiver)
        {
            // Data files contained in [datadrectory]/parser
            string    parserdir = env.GetConfigDirectory("datadirectory") + Path.DirectorySeparatorChar + "parser" + Path.DirectorySeparatorChar;
            POSTagger tagger    = new POSTagger(parserdir + "lexicon_all", parserdir + "ruleset", assembly, null);

            env.SetDataSource <string, string[]>(LanguageNet.Grammarian.POSTagger.PartsSourceName, tagger);
            env.AddAction(new EnumerableTagHandler(tagger));
            env.AddAction(new PhraseResolveHandler(tagger));
            env.AddAction(new StringTagHandler(tagger));

            return(InitializeResult.Success());
        }
Ejemplo n.º 7
0
 // either of the next words are as given
 public override bool checkContext(POSTagger tagger)
 {
     return(tagger.wordBuff[4] == context[0] ||
            tagger.wordBuff[5] == context[0]);
 }
Ejemplo n.º 8
0
 // any of the next speech parts are as given
 public override bool checkContext(POSTagger tagger)
 {
     return(tagger.lexBuff[4][0] == context[0] ||
            tagger.lexBuff[5][0] == context[0] ||
            tagger.lexBuff[6][0] == context[0]);
 }
Ejemplo n.º 9
0
 // the current and previous word are as given
 public override bool checkContext(POSTagger tagger)
 {
     return(tagger.wordBuff[2] == context[0] &&
            tagger.wordBuff[3] == context[1]);
 }
Ejemplo n.º 10
0
 // dummy rule-- always applies
 public override bool checkContext(POSTagger tagger)
 {
     return(true);
 }
Ejemplo n.º 11
0
 // the neighboring speech parts are as given
 public override bool checkContext(POSTagger tagger)
 {
     return(tagger.lexBuff[2][0] == context[0] &&
            tagger.lexBuff[4][0] == context[1]);
 }
Ejemplo n.º 12
0
 // Are we in an appropriate context?
 public virtual bool checkContext(POSTagger tagger)
 {
     return(true);
 }