Пример #1
0
 internal History(PairsHolder pairs, Extractors extractors)
 {
     // this is the index of the first word of the sentence
     //this is the index of the last word in the sentence - the dot
     // this is the index of the current word
     this.pairs      = pairs;
     this.extractors = extractors;
 }
Пример #2
0
        // This precomputes scores of local features (localScores).
        protected internal virtual double[] GetHistories(string[] tags, History h)
        {
            bool       rare = maxentTagger.IsRare(ExtractorFrames.cWord.Extract(h));
            Extractors ex   = maxentTagger.extractors;
            Extractors exR  = maxentTagger.extractorsRare;
            string     w    = pairs.GetWord(h.current);

            double[] lS;
            double[] lcS;
            lS = localScores[w];
            if (lS == null)
            {
                lS             = GetHistories(tags, h, ex.local, rare ? exR.local : null);
                localScores[w] = lS;
            }
            else
            {
                if (lS.Length != tags.Length)
                {
                    // This case can occur when a word was given a specific forced
                    // tag, and then later it shows up without the forced tag.
                    // TODO: if a word is given a forced tag, we should always get
                    // its features rather than use the cache, just in case the tag
                    // given is not the same tag as before
                    lS = GetHistories(tags, h, ex.local, rare ? exR.local : null);
                    if (tags.Length > 1)
                    {
                        localScores[w] = lS;
                    }
                }
            }
            if ((lcS = localContextScores[h.current]) == null)
            {
                lcS = GetHistories(tags, h, ex.localContext, rare ? exR.localContext : null);
                localContextScores[h.current] = lcS;
                ArrayMath.PairwiseAddInPlace(lcS, lS);
            }
            double[] totalS = GetHistories(tags, h, ex.dynamic, rare ? exR.dynamic : null);
            ArrayMath.PairwiseAddInPlace(totalS, lcS);
            return(totalS);
        }
Пример #3
0
 internal History(int start, int end, int current, PairsHolder pairs, Extractors extractors)
 {
     this.pairs      = pairs;
     this.extractors = extractors;
     Init(start, end, current);
 }