public List<String> getLabelsCoveringTokens(Collection<Integer> tokenIds) { List<String> output = new ArrayList<>(); for (int token : tokenIds) { output.addAll(this.getLabelsCoveringToken(token)); } return output; }
public List<String> getLabelsCoveringSpan(int start, int end) { List<String> output = new ArrayList<>(); for (int token = start; token < end; token++) { output.addAll(this.getLabelsCoveringToken(token)); } return output; }
public List<String> getLabelsCoveringTokens(Collection<Integer> tokenIds) { List<String> output = new ArrayList<>(); for (int token : tokenIds) { output.addAll(this.getLabelsCoveringToken(token)); } return output; }
public List<String> getLabelsCoveringSpan(int start, int end) { List<String> output = new ArrayList<>(); for (int token = start; token < end; token++) { output.addAll(this.getLabelsCoveringToken(token)); } return output; }
/** * get a lemma for the token at index tokIndex in TextAnnotation ta. * * @param ta TextAnnotation to query for lemma; MUST have POS view. * @param tokIndex token index for word to lemmatize * @return a String representing a lemma with the POS found for the corresponding word */ public String getLemma(TextAnnotation ta, int tokIndex) { if (tokIndex >= ta.getTokens().length) { String msg = "ERROR: " + NAME + ".getLemma(): index '" + tokIndex + "' is out of range of textAnnotation, " + "which has '" + ta.getTokens().length + "' tokens."; logger.error(msg); throw new IllegalArgumentException(msg); } String word = ta.getToken(tokIndex).toLowerCase().trim(); String pos = ta.getView(ViewNames.POS).getLabelsCoveringToken(tokIndex).get(0); return getLemma(word, pos); }
/** * get a lemma for the token at index tokIndex in TextAnnotation ta. * * @param ta TextAnnotation to query for lemma; MUST have POS view. * @param tokIndex token index for word to lemmatize * @return a String representing a lemma with the POS found for the corresponding word */ public String getLemma(TextAnnotation ta, int tokIndex) { if (tokIndex >= ta.getTokens().length) { String msg = "ERROR: " + NAME + ".getLemma(): index '" + tokIndex + "' is out of range of textAnnotation, " + "which has '" + ta.getTokens().length + "' tokens."; logger.error(msg); throw new IllegalArgumentException(msg); } String word = ta.getToken(tokIndex).toLowerCase().trim(); String pos = ta.getView(ViewNames.POS).getLabelsCoveringToken(tokIndex).get(0); return getLemma(word, pos); }
/** * A helper that checks if the two inputs have only noun phrases between * @param front The Constituent at the front * @param back The second Consituent * @return A boolean */ public static boolean onlyNounBetween(Constituent front, Constituent back){ TextAnnotation ta = front.getTextAnnotation(); View posView = ta.getView(ViewNames.POS); for (int i = front.getEndSpan(); i < back.getStartSpan(); i++){ if (!posView.getLabelsCoveringToken(i).get(0).startsWith("NN")){ //&& !posView.getLabelsCoveringToken(i).get(0).startsWith("JJ")){ return false; } } return true; }
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { String viewName = gazetteerViewGenerator.getViewName(); if (!ta.hasView(viewName)) try { ta.addView(gazetteerViewGenerator); } catch (AnnotatorException e) { throw new EdisonException(e); } Set<Feature> feats = new LinkedHashSet<>(); for (String label : ta.getView(viewName).getLabelsCoveringToken( wordPosition)) feats.add(DiscreteFeature.create(label)); return feats; }
onlyNounBetween(front_head, back_head)) { if (front_head.getStartSpan() == back.getStartSpan()) { if (posView.getLabelsCoveringToken(front_head.getStartSpan()).equals("PRP$")) { return false; if (!posView.getLabelsCoveringToken(i).get(0).startsWith("JJ") && !posView.getLabelsCoveringToken(i).get(0).startsWith("RB") && !posView.getLabelsCoveringToken(i).get(0).startsWith("VB") && !posView.getLabelsCoveringToken(i).get(0).startsWith("CD") && !posView.getLabelsCoveringToken(i).get(0).startsWith("DT") && !posView.getLabelsCoveringToken(i).get(0).startsWith("PD")) { return false;
boolean noNp = true; for (int i = front_head.getEndSpan(); i < back.getStartSpan(); i++){ if (isNoun(posView.getLabelsCoveringToken(i).get(0))){ noNp = false; if (posView.getLabelsCoveringToken(i).get(0).equals("IN") || posView.getLabelsCoveringToken(i).get(0).equals("TO")){ found_in_to = true; for (int i = front.getEndSpan(); i < back.getStartSpan(); i++){ non_overlap = true; if (isNoun(posView.getLabelsCoveringToken(i).get(0))){ noNp = false; if (posView.getLabelsCoveringToken(i).get(0).equals("IN") || posView.getLabelsCoveringToken(i).get(0).equals("TO")){ found_in_to = true; if (isNoun(posView.getLabelsCoveringToken(i).get(0))){ noNp = false; if (posView.getLabelsCoveringToken(i).get(0).equals("IN")){ found_in = true;
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { String viewName = gazetteerViewGenerator.getViewName(); if (!ta.hasView(viewName)) try { ta.addView(gazetteerViewGenerator); } catch (AnnotatorException e) { throw new EdisonException(e); } Set<Feature> feats = new LinkedHashSet<>(); for (String label : ta.getView(viewName).getLabelsCoveringToken( wordPosition)) feats.add(DiscreteFeature.create(label)); return feats; }
if (!posView.getLabelsCoveringToken(i).get(0).startsWith("NN") && !posView.getLabelsCoveringToken(i).get(0).equals(",")){ return false;
if (posView.getLabelsCoveringToken(front_head.getEndSpan()).get(0).equals("POS")){ return true; if (posView.getLabelsCoveringToken(front_head.getEndSpan() - 1).get(0).equals("PRP$") || posView.getLabelsCoveringToken(front_head.getEndSpan() - 1).get(0).equals("WP$")){ return true;