public Constituent getCommaConstituentFromTree(TreeView parseView) { Constituent comma = null; for (Constituent c : parseView.getConstituents()) { if (c.isConsituentInRange(commaPosition, commaPosition + 1)) { try { comma = parseView.getParsePhrase(c); } catch (Exception e) { e.printStackTrace(); System.exit(1); } break; } } return comma; }
public Constituent getCommaConstituentFromTree(TreeView parseView) { Constituent comma = null; for (Constituent c : parseView.getConstituents()) { if (c.isConsituentInRange(commaPosition, commaPosition + 1)) { try { comma = parseView.getParsePhrase(c); } catch (Exception e) { e.printStackTrace(); System.exit(1); } break; } } return comma; }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(ViewNames.PARSE_CHARNIAK); try { Constituent phrase = tree.getParsePhrase(c); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); Constituent c1 = new Constituent("", "", ta, head, head + 1); return Collections.singletonList(addPointerToSource(c, c1)); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(ViewNames.PARSE_BERKELEY); try { Constituent phrase = tree.getParsePhrase(c); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); Constituent c1 = new Constituent("", "", ta, head, head + 1); return Collections.singletonList(addPointerToSource(c, c1)); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(ViewNames.PARSE_CHARNIAK); try { Constituent phrase = tree.getParsePhrase(c); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); Constituent c1 = new Constituent("", "", ta, head, head + 1); return Collections.singletonList(addPointerToSource(c, c1)); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); TreeView parse = (TreeView) ta.getView(parseViewName); List<Constituent> siblings = new ArrayList<>(); try { Constituent phrase = parse.getParsePhrase(input); List<Relation> in = phrase.getIncomingRelations(); if (in.size() > 0) { List<Relation> outgoingRelations = in.get(0).getSource().getOutgoingRelations(); int id = -1; for (int i = 0; i < outgoingRelations.size(); i++) { Relation r = outgoingRelations.get(i); if (r.getTarget() == phrase) { id = i; break; } } if (id >= 0 && id + 1 < outgoingRelations.size()) siblings.add(outgoingRelations.get(id + 1).getTarget()); } } catch (EdisonException e) { throw new RuntimeException(e); } catch (Exception e) { e.printStackTrace(); } return siblings; }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); TreeView parse = (TreeView) ta.getView(parseViewName); List<Constituent> siblings = new ArrayList<>(); try { Constituent phrase = parse.getParsePhrase(input); List<Relation> in = phrase.getIncomingRelations(); if (in.size() > 0) { List<Relation> outgoingRelations = in.get(0).getSource().getOutgoingRelations(); int id = -1; for (int i = 0; i < outgoingRelations.size(); i++) { Relation r = outgoingRelations.get(i); if (r.getTarget() == phrase) { id = i; break; } } if (id >= 0 && id + 1 < outgoingRelations.size()) siblings.add(outgoingRelations.get(id + 1).getTarget()); } } catch (EdisonException e) { throw new RuntimeException(e); } catch (Exception e) { e.printStackTrace(); } return siblings; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewname); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); if (phrase != null) features.add(DiscreteFeature.create(phrase.getLabel())); return features; }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(ViewNames.PARSE_BERKELEY); try { Constituent phrase = tree.getParsePhrase(c); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); Constituent c1 = new Constituent("", "", ta, head, head + 1); return Collections.singletonList(addPointerToSource(c, c1)); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewname); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); if (phrase != null) features.add(DiscreteFeature.create(phrase.getLabel())); return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewName); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); features.add(DiscreteFeature.create("hw:" + ta.getToken(head).toLowerCase().trim())); features.add(DiscreteFeature.create("h-pos:" + WordHelpers.getPOS(ta, head))); return features; }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); TreeView parse = (TreeView) ta.getView(parseViewName); List<Constituent> siblings = new ArrayList<>(); try { Constituent phrase = parse.getParsePhrase(input); List<Relation> in = phrase.getIncomingRelations(); if (in.size() > 0) { Constituent prev = null; Relation relation = in.get(0); List<Relation> outgoingRelations = relation.getSource().getOutgoingRelations(); for (Relation r : outgoingRelations) { if (r.getTarget() == phrase) { break; } prev = r.getTarget(); } if (prev != null) siblings.add(prev); } } catch (EdisonException e) { throw new RuntimeException(e); } catch (Exception e) { e.printStackTrace(); } return siblings; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewName); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); features.add(DiscreteFeature.create("hw:" + ta.getToken(head).toLowerCase().trim())); features.add(DiscreteFeature.create("h-pos:" + WordHelpers.getPOS(ta, head))); return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView parse = (TreeView) ta.getView(parseViewName); String l; try { l = parse.getParsePhrase(c).getLabel(); } catch (Exception e) { throw new EdisonException(e); } boolean found = isLabelValid(l); Set<Feature> features = new LinkedHashSet<>(); if (found) { features.add(DiscreteFeature.create(label)); } return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { Set<Feature> features = new LinkedHashSet<>(); TreeView view = (TreeView) c.getTextAnnotation().getView(parseViewName); Constituent phrase; try { phrase = view.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } List<Relation> incomingRelations = phrase.getIncomingRelations(); if (incomingRelations == null) { features.add(DiscreteFeature.create("root")); } else { Constituent parent = incomingRelations.get(0).getSource(); StringBuilder subcat = new StringBuilder(); subcat.append(parent.getLabel()).append(">"); for (Relation r : parent.getOutgoingRelations()) { if (r.getTarget() == phrase) { subcat.append("(").append(r.getTarget().getLabel()).append(")"); } else { subcat.append(r.getTarget().getLabel()); } } features.add(DiscreteFeature.create(subcat.toString())); } return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView parse = (TreeView) ta.getView(parseViewName); String l; try { l = parse.getParsePhrase(c).getLabel(); } catch (Exception e) { throw new EdisonException(e); } boolean found = isLabelValid(l); Set<Feature> features = new LinkedHashSet<>(); if (found) { features.add(DiscreteFeature.create(label)); } return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewName); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); Constituent c1 = new Constituent("", "", ta, head, head + 1); features.addAll(fex.getFeatures(c1)); return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewName); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); int head = CollinsHeadFinder.getInstance().getHeadWordPosition(phrase); Constituent c1 = new Constituent("", "", ta, head, head + 1); features.addAll(fex.getFeatures(c1)); return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewname); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); if (phrase != null) { features.add(DiscreteFeature.create(phrase.getLabel())); String parentLabel = "ROOT"; if (phrase.getIncomingRelations().size() > 0) { Constituent parent = phrase.getIncomingRelations().get(0).getSource(); parentLabel = parent.getLabel(); int parentHead = CollinsHeadFinder.getInstance().getHeadWordPosition(parent); features.add(DiscreteFeature.create("pt:h:" + ta.getToken(parentHead).toLowerCase().trim())); features.add(DiscreteFeature.create("pt:h-pos:" + WordHelpers.getPOS(ta, parentHead))); } features.add(DiscreteFeature.create("pt:" + parentLabel)); } return features; }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { TextAnnotation ta = c.getTextAnnotation(); TreeView tree = (TreeView) ta.getView(parseViewname); Constituent phrase; try { phrase = tree.getParsePhrase(c); } catch (Exception e) { throw new EdisonException(e); } Set<Feature> features = new LinkedHashSet<>(); if (phrase != null) { features.add(DiscreteFeature.create(phrase.getLabel())); String parentLabel = "ROOT"; if (phrase.getIncomingRelations().size() > 0) { Constituent parent = phrase.getIncomingRelations().get(0).getSource(); parentLabel = parent.getLabel(); int parentHead = CollinsHeadFinder.getInstance().getHeadWordPosition(parent); features.add(DiscreteFeature.create("pt:h:" + ta.getToken(parentHead).toLowerCase().trim())); features.add(DiscreteFeature.create("pt:h-pos:" + WordHelpers.getPOS(ta, parentHead))); } features.add(DiscreteFeature.create("pt:" + parentLabel)); } return features; }