@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); int tokenPosition = c.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent prepositionDepConstituent = dependency.getConstituentsCoveringToken(tokenPosition).get(0); List<Relation> incomingRelations = prepositionDepConstituent.getIncomingRelations(); List<Constituent> list = new ArrayList<>(); if (incomingRelations != null && incomingRelations.size() > 0) { Constituent parent = incomingRelations.get(0).getSource(); for (Relation out : parent.getOutgoingRelations()) { if (out == incomingRelations.get(0)) continue; String label = out.getRelationName(); if (label.contains("prep")) { Constituent ppNode = out.getTarget(); list.add(addPointerToSource(c, ppNode)); // get the first child of the pp and add this List<Relation> ppOut = ppNode.getOutgoingRelations(); if (ppOut != null && ppOut.size() != 0) { Constituent child = ppOut.get(0).getTarget(); list.add(addPointerToSource(c, child)); } } } } return list; }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); int tokenPosition = c.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent prepositionDepConstituent = dependency.getConstituentsCoveringToken(tokenPosition).get(0); List<Relation> incomingRelations = prepositionDepConstituent.getIncomingRelations(); List<Constituent> list = new ArrayList<>(); if (incomingRelations != null && incomingRelations.size() > 0) { Constituent parent = incomingRelations.get(0).getSource(); for (Relation out : parent.getOutgoingRelations()) { if (out == incomingRelations.get(0)) continue; String label = out.getRelationName(); if (label.contains("prep")) { Constituent ppNode = out.getTarget(); list.add(addPointerToSource(c, ppNode)); // get the first child of the pp and add this List<Relation> ppOut = ppNode.getOutgoingRelations(); if (ppOut != null && ppOut.size() != 0) { Constituent child = ppOut.get(0).getTarget(); list.add(addPointerToSource(c, child)); } } } } return list; }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); int tokenPosition = input.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent verbNode = dependency.getConstituentsCoveringToken(tokenPosition).get(0); boolean done = false; while (!done) { String pos = WordHelpers.getPOS(ta, verbNode.getStartSpan()); if (POSUtils.isPOSVerb(pos)) { done = true; } else { List<Relation> incoming = verbNode.getIncomingRelations(); if (incoming == null || incoming.size() == 0) { return new ArrayList<>(); } else verbNode = incoming.get(0).getSource(); } } return Collections.singletonList(addPointerToSource(input, verbNode)); }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); int tokenPosition = c.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent prepositionDepConstituent = dependency.getConstituentsCoveringToken(tokenPosition).get(0); List<Relation> incomingRelations = prepositionDepConstituent.getIncomingRelations(); List<Constituent> list = new ArrayList<>(); if (incomingRelations != null && incomingRelations.size() > 0) { Constituent parent = incomingRelations.get(0).getSource(); for (Relation out : parent.getOutgoingRelations()) { if (out == incomingRelations.get(0)) continue; String label = out.getRelationName(); if (label.contains("prep")) { Constituent ppNode = out.getTarget(); list.add(addPointerToSource(c, ppNode)); // get the first child of the pp and add this List<Relation> ppOut = ppNode.getOutgoingRelations(); if (ppOut != null && ppOut.size() != 0) { Constituent child = ppOut.get(0).getTarget(); list.add(addPointerToSource(c, child)); } } } } return list; }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); int tokenPosition = c.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent prepositionDepConstituent = dependency.getConstituentsCoveringToken(tokenPosition).get(0); List<Relation> incomingRelations = prepositionDepConstituent.getIncomingRelations(); List<Constituent> list = new ArrayList<>(); if (incomingRelations != null && incomingRelations.size() > 0) { Constituent parent = incomingRelations.get(0).getSource(); for (Relation out : parent.getOutgoingRelations()) { if (out == incomingRelations.get(0)) continue; String label = out.getRelationName(); if (label.contains("prep")) { Constituent ppNode = out.getTarget(); list.add(addPointerToSource(c, ppNode)); // get the first child of the pp and add this List<Relation> ppOut = ppNode.getOutgoingRelations(); if (ppOut != null && ppOut.size() != 0) { Constituent child = ppOut.get(0).getTarget(); list.add(addPointerToSource(c, child)); } } } } return list; }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); int tokenPosition = input.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent verbNode = dependency.getConstituentsCoveringToken(tokenPosition).get(0); boolean done = false; while (!done) { String pos = WordHelpers.getPOS(ta, verbNode.getStartSpan()); if (POSUtils.isPOSVerb(pos)) { done = true; } else { List<Relation> incoming = verbNode.getIncomingRelations(); if (incoming == null || incoming.size() == 0) { return new ArrayList<>(); } else verbNode = incoming.get(0).getSource(); } } return Collections.singletonList(addPointerToSource(input, verbNode)); }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); int tokenPosition = input.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent verbNode = dependency.getConstituentsCoveringToken(tokenPosition).get(0); boolean done = false; while (!done) { String pos = WordHelpers.getPOS(ta, verbNode.getStartSpan()); if (POSUtils.isPOSVerb(pos)) { done = true; } else { List<Relation> incoming = verbNode.getIncomingRelations(); if (incoming == null || incoming.size() == 0) { return new ArrayList<>(); } else verbNode = incoming.get(0).getSource(); } } return Collections.singletonList(addPointerToSource(input, verbNode)); }
parse.getConstituentsCoveringToken( c.getIncomingRelations().get(0).getSource().getStartSpan()).get(0); Constituent c2 = parse.getConstituentsCoveringToken(c.getStartSpan()).get(0);
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); int tokenPosition = input.getStartSpan(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); Constituent verbNode = dependency.getConstituentsCoveringToken(tokenPosition).get(0); boolean done = false; while (!done) { String pos = WordHelpers.getPOS(ta, verbNode.getStartSpan()); if (POSUtils.isPOSVerb(pos)) { done = true; } else { List<Relation> incoming = verbNode.getIncomingRelations(); if (incoming == null || incoming.size() == 0) { return new ArrayList<>(); } else verbNode = incoming.get(0).getSource(); } } return Collections.singletonList(addPointerToSource(input, verbNode)); }
parse.getConstituentsCoveringToken( c.getIncomingRelations().get(0).getSource().getStartSpan()).get(0); Constituent c2 = parse.getConstituentsCoveringToken(c.getStartSpan()).get(0);
TreeView parse = (TreeView) ta.getView(dependencyViewName); Constituent c2 = parse.getConstituentsCoveringToken(c.getStartSpan()).get(0); List<Relation> incomingRelations = c2.getIncomingRelations(); if (incomingRelations.size() > 0) { Constituent c1 = parse.getConstituentsCoveringToken( incomingRelations.get(0).getSource().getStartSpan()).get(0);
TreeView parse = (TreeView) ta.getView(dependencyViewName); Constituent c2 = parse.getConstituentsCoveringToken(c.getStartSpan()).get(0); List<Relation> incomingRelations = c2.getIncomingRelations(); if (incomingRelations.size() > 0) { Constituent c1 = parse.getConstituentsCoveringToken( incomingRelations.get(0).getSource().getStartSpan()).get(0);
View annotatedView = source.getTextAnnotation().getView("RE_ANNOTATED"); View posView = source.getTextAnnotation().getView(ViewNames.POS); List<Constituent> source_parsed_list = parse.getConstituentsCoveringToken(source_head.getStartSpan()); List<Constituent> target_parsed_list = parse.getConstituentsCoveringToken(target_head.getStartSpan()); if (source.getSentenceId() == target.getSentenceId()){ try { if (source_parsed_list.size() != 0 && target_parsed_list.size() != 0) { Constituent source_parsed = parse.getConstituentsCoveringToken(source_head.getStartSpan()).get(0); Constituent target_parsed = parse.getConstituentsCoveringToken(target_head.getStartSpan()).get(0); List<Constituent> paths = PathFeatureHelper.getPathConstituents(source_parsed, target_parsed, 100); for (int i = 0; i < paths.size(); i++){
List<Constituent> source_parsed_list = parse.getConstituentsCoveringToken(source_head.getStartSpan()); List<Constituent> target_parsed_list = parse.getConstituentsCoveringToken(target_head.getStartSpan()); if (source.getSentenceId() == target.getSentenceId()){ try { if (source_parsed_list.size() != 0 && target_parsed_list.size() != 0) { Constituent source_parsed = parse.getConstituentsCoveringToken(source_head.getStartSpan()).get(0); Constituent target_parsed = parse.getConstituentsCoveringToken(target_head.getStartSpan()).get(0); List<Constituent> paths = PathFeatureHelper.getPathConstituents(source_parsed, target_parsed, 100); if (paths.get(paths.size() - 2).getLabel().equals("prep") && paths.get(paths.size() - 1).getLabel().equals("pobj")){