コード例 #1
0
        public virtual void TestPairsHolder()
        {
            PairsHolder pairsHolder = new PairsHolder();

            for (int i = 0; i < 10; i++)
            {
                pairsHolder.Add(new WordTag("girl", "NN"));
            }
            MaxentTagger maxentTagger = new MaxentTagger();

            maxentTagger.Init(null);
            //maxentTagger.pairs = pairsHolder;
            History           h  = new History(0, 5, 3, pairsHolder, maxentTagger.extractors);
            TaggerExperiments te = new TaggerExperiments(maxentTagger);
            int x = te.GetHistoryTable().Add(h);
            //int x = maxentTagger.tHistories.add(h);
            int y = te.GetHistoryTable().GetIndex(h);

            //int y = maxentTagger.tHistories.getIndex(h);
            NUnit.Framework.Assert.AreEqual("Failing to get same index for history", x, y);
            Extractor e = new Extractor(0, false);
            string    k = e.Extract(h);

            NUnit.Framework.Assert.AreEqual("Extractor didn't find stored word", k, "girl");
        }
コード例 #2
0
        protected internal virtual void Add(int nFeatFrame, History history, int number)
        {
            Pair <int, string> wT;
            int general = maxentTagger.extractors.Size();

            if (nFeatFrame < general)
            {
                wT = new Pair <int, string>(nFeatFrame, maxentTagger.extractors.Extract(nFeatFrame, history));
            }
            else
            {
                wT = new Pair <int, string>(nFeatFrame, maxentTagger.extractorsRare.Extract(nFeatFrame - general, history));
            }
            if (tempHash.Contains(wT))
            {
                ListInstances li = tempHash[wT];
                // TODO: can we clean this call up somehow?  perhaps make the
                // TemplateHash aware of the TaggerExperiments if we need to, or
                // vice-versa?
                if (TaggerExperiments.IsPopulated(nFeatFrame, li.GetNum(), maxentTagger))
                {
                    li.Add(number);
                }
            }
            else
            {
                ListInstances li = new ListInstances();
                li.Add(number);
                tempHash[wT] = li;
            }
        }
コード例 #3
0
 protected internal TaggerFeature(int start, int end, FeatureKey key, int yTag, TaggerExperiments domain)
 {
     this.start  = start;
     this.end    = end;
     this.key    = key;
     this.domain = domain;
     this.yTag   = yTag;
 }
コード例 #4
0
 internal TaggerFeatures(TaggerExperiments domain)
     : base()
 {
     this.domain = domain;
 }