public String transform(Constituent input) { return input.getSurfaceForm(); } };
public String transform(Constituent input) { return input.getSurfaceForm(); } };
public String transform(Constituent input) { return input.getSurfaceForm(); } };
public String transform(Constituent input) { return input.getSurfaceForm(); } };
public String transform(Constituent input) { return input.getSurfaceForm(); } };
public static Set<String> getLegalRoles(Constituent predicate) { if (prepositionToValidRoles == null) lazyReadMaps(); Set<String> strings = new HashSet<>(); strings.add(DataReader.CANDIDATE); if (prepositionToValidRoles.containsKey(predicate.getSurfaceForm().toLowerCase())) strings.addAll(prepositionToValidRoles.get(predicate.getSurfaceForm().toLowerCase())); return strings; }
public static Set<String> getLegalRoles(Constituent predicate) { if (prepositionToValidRoles == null) lazyReadMaps(); Set<String> strings = new HashSet<>(); strings.add(DataReader.CANDIDATE); if (prepositionToValidRoles.containsKey(predicate.getSurfaceForm().toLowerCase())) strings.addAll(prepositionToValidRoles.get(predicate.getSurfaceForm().toLowerCase())); return strings; }
public static boolean[] getStringPatternsBoolean(TextAnnotation s) { List<Constituent> list = s.getView(ViewNames.POS).getConstituents(); boolean cb = list.get(1).getLabel().contains("NN"); boolean what = list.get(0).getSurfaceForm().toLowerCase().contains("what"); boolean where = list.get(0).getSurfaceForm().toLowerCase().contains("where"); boolean when = list.get(0).getSurfaceForm().toLowerCase().contains("when"); String secondWordCapitalization = list.get(1).getSurfaceForm(); boolean whereOrWhenAndCapitapized = (where || when) && isCapitalized(secondWordCapitalization.substring(0, 1)); boolean containsBodyOrPart = s.text.contains(" body") || s.text.contains(" part "); boolean whatNationality = s.text.toLowerCase().contains("what") && s.text.contains("nationality"); return new boolean[]{ cb && what, whereOrWhenAndCapitapized, containsBodyOrPart}; }
/** * wraps the simpler xmlrpcclient compareStrings() method * creates EntailmentResult using threshold and sign of MetricResponse */ public EntailmentResult compare( Constituent specific_, Constituent general_ ) { MetricResponse mr = compareStrings( specific_.getSurfaceForm(), general_.getSurfaceForm() ); boolean decision = Math.abs( mr.score ) > m_threshold; boolean positivePolarity = ( mr.score >= 0 ); boolean upwardMonotonicity = true; return new EntailmentResult( m_methodName, (float) mr.score, mr.reason, decision, positivePolarity, upwardMonotonicity, null); }
public static boolean[] getStringPatternsBoolean(TextAnnotation s) { List<Constituent> list = s.getView(ViewNames.POS).getConstituents(); boolean cb = list.get(1).getLabel().contains("NN"); boolean what = list.get(0).getSurfaceForm().toLowerCase().contains("what"); boolean where = list.get(0).getSurfaceForm().toLowerCase().contains("where"); boolean when = list.get(0).getSurfaceForm().toLowerCase().contains("when"); String secondWordCapitalization = list.get(1).getSurfaceForm(); boolean whereOrWhenAndCapitapized = (where || when) && isCapitalized(secondWordCapitalization.substring(0, 1)); boolean containsBodyOrPart = s.text.contains(" body") || s.text.contains(" part "); boolean whatNationality = s.text.toLowerCase().contains("what") && s.text.contains("nationality"); return new boolean[]{ cb && what, whereOrWhenAndCapitapized, containsBodyOrPart}; }
public static String getFirstConstituents(TextAnnotation s, String viewName, int k, boolean getLabel) { List<Constituent> list = s.getView(viewName).getConstituents(); String output = ""; for(int i = 0; i < k && i < list.size(); i++) { if(getLabel) output += list.get(i).getLabel(); else output += list.get(i).getSurfaceForm(); } return output; }
public static String getFirstConstituents(TextAnnotation s, String viewName, int k, boolean getLabel) { List<Constituent> list = s.getView(viewName).getConstituents(); String output = ""; for(int i = 0; i < k && i < list.size(); i++) { if(getLabel) output += list.get(i).getLabel(); else output += list.get(i).getSurfaceForm(); } return output; }
public static String[] getStringPatternsDiscrete(TextAnnotation s) { List<Constituent> posCons = s.getView(ViewNames.POS).getConstituents(); List<Constituent> lemmaCons = s.getView(ViewNames.LEMMA).getConstituents(); boolean what = lemmaCons.get(0).getSurfaceForm().toLowerCase().contains("what"); String whatNounNoun = ""; if(what && posCons.size() >= 2) { whatNounNoun = lemmaCons.get(1).getLabel() + "-" + lemmaCons.get(2).getLabel(); } return new String[]{ whatNounNoun }; }
public static String[] getStringPatternsDiscrete(TextAnnotation s) { List<Constituent> posCons = s.getView(ViewNames.POS).getConstituents(); List<Constituent> lemmaCons = s.getView(ViewNames.LEMMA).getConstituents(); boolean what = lemmaCons.get(0).getSurfaceForm().toLowerCase().contains("what"); String whatNounNoun = ""; if(what && posCons.size() >= 2) { whatNounNoun = lemmaCons.get(1).getLabel() + "-" + lemmaCons.get(2).getLabel(); } return new String[]{ whatNounNoun }; }
/** * @param word the token to match. * @param which the index of the token. */ final public void match(List<Constituent> words, int which, SpanLabelView view) { GazEntry ge = gaz.get(splitter.normalize(words.get(which).getSurfaceForm())); if (ge != null) { ge.compileMatches(words, which, which, view); } }
public static String getFirstLabel(TextAnnotation s, String label) { List<Constituent> list = s.getView(ViewNames.SHALLOW_PARSE).getConstituents(); String nounPhrase = ""; for(Constituent c : list) { if(c.getLabel().contains(label)) { nounPhrase = c.getSurfaceForm(); } } return nounPhrase; }
/** * @param word the token to match. * @param which the index of the token. */ final public void match(List<Constituent> words, int which, SpanLabelView view) { GazEntry ge = gaz.get(splitter.normalize(words.get(which).getSurfaceForm())); if (ge != null) { ge.compileMatches(words, which, which, view); } }
public static String getFirstLabel(TextAnnotation s, String label) { List<Constituent> list = s.getView(ViewNames.SHALLOW_PARSE).getConstituents(); String nounPhrase = ""; for(Constituent c : list) { if(c.getLabel().contains(label)) { nounPhrase = c.getSurfaceForm(); } } return nounPhrase; }
/** Helper methods to handle Protobuf implementation */ private static void writeTokenOffsets(TextAnnotation ta, TextAnnotationProto.Builder taBuilder) { for (Constituent c : ta.getView(ViewNames.TOKENS).getConstituents()) { TokenOffsetsProto.Builder tokenOffsetBuilder = TokenOffsetsProto.newBuilder(); tokenOffsetBuilder.setForm(c.getSurfaceForm()); tokenOffsetBuilder.setStartCharOffset(c.getStartCharOffset()); tokenOffsetBuilder.setEndCharOffset(c.getEndCharOffset()); taBuilder.addTokenOffsets(tokenOffsetBuilder); } }
/** Helper methods to handle Protobuf implementation */ private static void writeTokenOffsets(TextAnnotation ta, TextAnnotationProto.Builder taBuilder) { for (Constituent c : ta.getView(ViewNames.TOKENS).getConstituents()) { TokenOffsetsProto.Builder tokenOffsetBuilder = TokenOffsetsProto.newBuilder(); tokenOffsetBuilder.setForm(c.getSurfaceForm()); tokenOffsetBuilder.setStartCharOffset(c.getStartCharOffset()); tokenOffsetBuilder.setEndCharOffset(c.getEndCharOffset()); taBuilder.addTokenOffsets(tokenOffsetBuilder); } }