internal override string Extract(History h, PairsHolder pH) { // I ran a bunch of timing tests that seem to indicate it is // cheaper to simply add string + char + string than use a // StringBuilder or go through the StringBuildMemoizer -horatio return(pH.GetWord(h, leftPosition) + '!' + pH.GetWord(h, rightPosition)); }
public virtual void PrintSent() { Print(System.Console.Out); for (int i = this.start; i < this.end; i++) { System.Console.Out.Write(pairs.GetTag(i) + ' ' + pairs.GetWord(i) + '\t'); } System.Console.Out.WriteLine(); }
internal override string Extract(History h, PairsHolder pH) { string cword = pH.GetWord(h, 0); int allCount = dict.Sum(cword); int vBNCount = dict.GetCount(cword, vbnTag); int vBDCount = dict.GetCount(cword, vbdTag); // Conditions for deciding inapplicable if ((allCount == 0) && (!(cword.EndsWith(edSuff) || cword.EndsWith(enSuff)))) { return(zeroSt); } if ((allCount > 0) && (vBNCount + vBDCount <= allCount / 100)) { return(zeroSt); } string lastverb = naWord; //String lastvtag = zeroSt; // mg: written but never read for (int index = -1; index >= -bound; index--) { string word2 = pH.GetWord(h, index); if ("NA".Equals(word2)) { break; } if (stopper.Matcher(word2).Matches()) { break; } if (vbnWord.Matcher(word2).Matches()) { lastverb = word2; break; } index--; } if (!lastverb.Equals(naWord)) { log.Info("VBN: For " + cword + ", found preceding VBN cue " + lastverb); return(oneSt); } return(zeroSt); }
internal override string Extract(History h, PairsHolder pH) { string cw = pH.GetWord(h, 0); string lk = cw.ToLower(Locale.English); if (lk.Equals(cw)) { return(zeroSt); } return(cw); }
internal override string Extract(History h, PairsHolder pH) { StringBuilder sb = new StringBuilder(); for (int j = left; j <= right; j++) { string s = pH.GetWord(h, j); sb.Append(WordShapeClassifier.WordShape(s, wordShaper)); if (j < right) { sb.Append('|'); } } return(sb.ToString()); }
internal override string Extract(History h, PairsHolder pH) { StringBuilder sb = new StringBuilder(); for (int j = left; j <= right; j++) { string word = pH.GetWord(h, j); string distSim = lexicon.GetMapping(word); sb.Append(distSim); if (j < right) { sb.Append('|'); } } return(sb.ToString()); }
// 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); }
internal virtual string ExtractLV(History h, PairsHolder pH, int bound) { // should extract last verbal word and also the current word int start = h.start; string lastverb = "NA"; int current = h.current; int index = current - 1; while ((index >= start) && (index >= current - bound)) { string tag = pH.GetTag(index); if (tag.StartsWith("VB")) { lastverb = pH.GetWord(index); break; } if (tag.StartsWith(",")) { break; } index--; } return(lastverb); }
internal virtual string Extract(History h, PairsHolder pH) { return(isTag ? pH.GetTag(h, position) : pH.GetWord(h, position)); }
internal override string Extract(History h, PairsHolder pH) { return(pH.GetTag(h, position1) + '!' + pH.GetWord(h, word) + '!' + pH.GetTag(h, position2)); }
internal override string Extract(History h, PairsHolder pH) { return(pH.GetWord(h, leftWord) + '!' + pH.GetTag(h, tag) + '!' + pH.GetWord(h, rightWord)); }
internal override string Extract(History h, PairsHolder pH) { return(pH.GetWord(h, position).ToLower(Locale.English)); }