public String getWordToRight(int distance) { // Dummy symbol for sentence end (in case comma is the second to last word in the sentence) if (commaPosition + distance >= s.ta.getTokens().length) return "###"; return s.ta.getToken(commaPosition + distance); }
public String getWordToLeft(int distance) { // Dummy symbol for sentence start (in case comma is the second word in the sentence) if (commaPosition - distance < 0) return "$$$"; return s.ta.getToken(commaPosition - distance); }
public String getWordToLeft(int distance) { // Dummy symbol for sentence start (in case comma is the second word in the sentence) if (commaPosition - distance < 0) return "$$$"; return s.ta.getToken(commaPosition - distance); }
public String getWordToRight(int distance) { // Dummy symbol for sentence end (in case comma is the second to last word in the sentence) if (commaPosition + distance >= s.ta.getTokens().length) return "###"; return s.ta.getToken(commaPosition + distance); }
public static String getWord(TextAnnotation ta, int tokenId) { return ta.getToken(tokenId); }
public static String getWord(TextAnnotation ta, int tokenId) { return ta.getToken(tokenId); }
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { String pos = getSafePOS(ta, wordPosition); Set<Feature> features = new LinkedHashSet<>(); if (POSUtils.isPOSNumber(pos)) features.add(NUMBER_IDENTIFIER); else if (WordLists.NUMBERS.contains(ta.getToken(wordPosition).toLowerCase())) features.add(NUMBER_IDENTIFIER); else if (ta.getToken(wordPosition).matches(numberPattern)) features.add(NUMBER_IDENTIFIER); return features; } };
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { String pos = getSafePOS(ta, wordPosition); Set<Feature> features = new LinkedHashSet<>(); if (POSUtils.isPOSNumber(pos)) features.add(NUMBER_IDENTIFIER); else if (WordLists.NUMBERS.contains(ta.getToken(wordPosition).toLowerCase())) features.add(NUMBER_IDENTIFIER); else if (ta.getToken(wordPosition).matches(numberPattern)) features.add(NUMBER_IDENTIFIER); return features; } };
private static String getSafeToken(TextAnnotation ta, int wordPosition) { String token = "*"; if (wordPosition >= 0 && wordPosition < ta.size()) token = ta.getToken(wordPosition); return token; }
private static String getSafeToken(TextAnnotation ta, int wordPosition) { String token = "*"; if (wordPosition >= 0 && wordPosition < ta.size()) token = ta.getToken(wordPosition); return token; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < this.textAnnotation.size(); i++) { String label = this.getLabel(i); if (label.length() == 0) sb.append(this.getTextAnnotation().getToken(i)).append(" "); else sb.append("(").append(this.getLabel(i)).append(" ") .append(this.textAnnotation.getToken(i)).append(") "); } return sb.toString(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < this.textAnnotation.size(); i++) { String label = this.getLabel(i); if (label.length() == 0) sb.append(this.getTextAnnotation().getToken(i)).append(" "); else sb.append("(").append(this.getLabel(i)).append(" ") .append(this.textAnnotation.getToken(i)).append(") "); } return sb.toString(); } }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'headLastWord(Relation)' defined on line 15 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; return "" + (r.getTarget().getTextAnnotation().getToken(r.getTarget().getEndSpan() - 1).toLowerCase()); }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'headLastWord(Relation)' defined on line 15 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; return "" + (r.getTarget().getTextAnnotation().getToken(r.getTarget().getEndSpan() - 1).toLowerCase()); }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'headLastWord(Relation)' defined on line 15 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; return "" + (r.getTarget().getTextAnnotation().getToken(r.getTarget().getEndSpan() - 1).toLowerCase()); }
/** * Lexical Feature Extractor Part A * @Extract source mention BOW * @return A List of String features */ public List<String> getLexicalFeaturePartA(Relation r){ List<String> ret_features = new ArrayList<String>(); Constituent source = r.getSource(); TextAnnotation ta = source.getTextAnnotation(); for (int i = source.getStartSpan(); i < source.getEndSpan(); i++){ ret_features.add(ta.getToken(i)); } return ret_features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { String classifier = "MikheevPOS"; TextAnnotation ta = c.getTextAnnotation(); int start = c.getStartSpan(); int end = c.getEndSpan(); Set<Feature> features = new LinkedHashSet<>(); for (int i = start; i < end; i++) { String form = ta.getToken(i); String tag = counter.tag(i, ta); features.add(new DiscreteFeature(classifier + ":" + tag + "_" + form)); } return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { String classifier = "BaseLinePOS"; TextAnnotation ta = c.getTextAnnotation(); int start = c.getStartSpan(); int end = c.getEndSpan(); Set<Feature> features = new LinkedHashSet<>(); for (int i = start; i < end; i++) { String form = ta.getToken(i); String tag = counter.tag(i, ta); features.add(new DiscreteFeature(classifier + ":" + tag + "_" + form)); } return features; }
@Override public void addView(TextAnnotation input) { TokenLabelView view = new TokenLabelView(getViewName(), "PorterStemmer", input, 1.0); synchronized (instance) { for (int i = 0; i < input.size(); i++) { stemmer.setCurrent(input.getToken(i)); stemmer.stem(); view.addTokenLabel(i, stemmer.getCurrent(), 1.0); } } input.addView(getViewName(), view); }
@Override public void addView(TextAnnotation input) { TokenLabelView view = new TokenLabelView(getViewName(), "PorterStemmer", input, 1.0); synchronized (instance) { for (int i = 0; i < input.size(); i++) { stemmer.setCurrent(input.getToken(i)); stemmer.stem(); view.addTokenLabel(i, stemmer.getCurrent(), 1.0); } } input.addView(getViewName(), view); }