private static Constituent addIncomingRelation(Constituent input, Constituent c) { Constituent i = input.cloneForNewView(""); Constituent c1 = c.cloneForNewView(""); new Relation("", i, c1, 0d); return c1; } }
private static Constituent addIncomingRelation(Constituent input, Constituent c) { Constituent i = input.cloneForNewView(""); Constituent c1 = c.cloneForNewView(""); new Relation("", i, c1, 0d); return c1; } }
@Override public List<Constituent> transform(Constituent c) { Constituent c1 = c.cloneForNewView(c.getViewName()); new Relation("", c, c1, 0.0); return Collections.singletonList(c1); }
@Override public List<Constituent> transform(Constituent c) { Constituent c1 = c.cloneForNewView(c.getViewName()); new Relation("", c, c1, 0.0); return Collections.singletonList(c1); }
private static Constituent addPointerToSource(Constituent source, Constituent c) { Constituent c1 = c.cloneForNewView(c.getViewName()); new Relation("", source, c1, 0.0); return c1; }
private static Constituent addPointerToSource(Constituent source, Constituent c) { Constituent c1 = c.cloneForNewView(c.getViewName()); new Relation("", source, c1, 0.0); return c1; }
public SRLPredicateInstance(Constituent predicate, SRLManager manager) { this.manager = manager; //XXX Generate a clone of the predicate to avoid changing the gold TA Constituent predicateClone = predicate.cloneForNewView(predicate.getViewName()); senseInstance = new SRLMulticlassInstance(predicateClone, predicateClone, manager); List<SRLMulticlassInstance> list = new ArrayList<>(); ArgumentCandidateGenerator candidateGenerator = manager.getArgumentCandidateGenerator(); List<Constituent> cands = candidateGenerator.generateCandidates(predicate); for (Constituent c : cands) { list.add(new SRLMulticlassInstance(c, predicateClone, manager)); } this.candidates = Collections.unmodifiableList(list); }
public SRLPredicateInstance(Constituent predicate, SRLManager manager, ArgumentIdentifier identifier) { this.manager = manager; //XXX Generate a clone of the predicate to avoid changing the gold TA Constituent predicateClone = predicate.cloneForNewView(predicate.getViewName()); senseInstance = new SRLMulticlassInstance(predicateClone, predicateClone, manager); ArgumentCandidateGenerator candidateGenerator = manager.getArgumentCandidateGenerator(); List<SRLMulticlassInstance> allCandidates = new ArrayList<>(); for (Constituent c : candidateGenerator.generateCandidates(predicate)) { allCandidates.add(new SRLMulticlassInstance(c, predicateClone, manager)); } cacheIdentifierFeatures(allCandidates); List<SRLMulticlassInstance> list = new ArrayList<>(); for (SRLMulticlassInstance c : allCandidates) { if (identifier.getIdentifierScaledDecision(c)) list.add(c); } this.candidates = Collections.unmodifiableList(list); }
private static Constituent getHead(Constituent c, TreeView dependency) { Constituent end = null; List<Constituent> constituentsCovering = dependency.getConstituentsCovering(c); for (Constituent d : constituentsCovering) { List<Relation> in = d.getIncomingRelations(); if (in.size() == 0) { end = d; break; } else { Constituent parent = in.get(0).getSource(); int parentToken = parent.getStartSpan(); if (c.getStartSpan() <= parentToken && parentToken < c.getEndSpan()) continue; if (end == null) { end = d; } else if (end.getStartSpan() < d.getStartSpan()) { end = d; } } } Constituent c1; if (end == null) c1 = constituentsCovering.get(0).cloneForNewView(""); else c1 = end.cloneForNewView(""); return addPointerToSource(c, c1); }
c2 = parse.getParsePhrase(c).cloneForNewView(""); } catch (Exception e) { e.printStackTrace(); c1 = parse.getParsePhrase(c.getIncomingRelations().get(0).getSource()) .cloneForNewView(""); } catch (Exception e) { e.printStackTrace();
private static Constituent getHead(Constituent c, TreeView dependency) { Constituent end = null; List<Constituent> constituentsCovering = dependency.getConstituentsCovering(c); for (Constituent d : constituentsCovering) { List<Relation> in = d.getIncomingRelations(); if (in.size() == 0) { end = d; break; } else { Constituent parent = in.get(0).getSource(); int parentToken = parent.getStartSpan(); if (c.getStartSpan() <= parentToken && parentToken < c.getEndSpan()) continue; if (end == null) { end = d; } else if (end.getStartSpan() < d.getStartSpan()) { end = d; } } } Constituent c1; if (end == null) c1 = constituentsCovering.get(0).cloneForNewView(""); else c1 = end.cloneForNewView(""); return addPointerToSource(c, c1); }
c2 = parse.getParsePhrase(c).cloneForNewView(""); } catch (Exception e) { e.printStackTrace(); c1 = parse.getParsePhrase(c.getIncomingRelations().get(0).getSource()).cloneForNewView(""); } catch (Exception e) { e.printStackTrace();
c2 = parse.getParsePhrase(c).cloneForNewView(""); } catch (Exception e) { e.printStackTrace(); c1 = parse.getParsePhrase(c.getIncomingRelations().get(0).getSource()) .cloneForNewView(""); } catch (Exception e) { e.printStackTrace();
public ILPInference(ILPSolverFactory solverFactory, SenseManager manager, List<Constituent> predicates) throws Exception { super(solverFactory, false); this.manager = manager; this.outputGenerator = new ILPOutput(manager); List<SenseInstance> instances = new ArrayList<>(); for (Constituent predicate : predicates) { Constituent predicateClone = predicate.cloneForNewView(predicate.getViewName()); SenseInstance x; assert predicateClone.hasAttribute(PredicateArgumentView.LemmaIdentifier); x = new SenseInstance(predicateClone, manager); x.cacheAllFeatureVectors(); instances.add(x); } ta = predicates.get(0).getTextAnnotation(); viewName = SenseManager.getPredictedViewName(); instance = new SentenceInstance(instances); numPredicates = instance.numPredicates(); }
public ILPInference(ILPSolverFactory solverFactory, SenseManager manager, List<Constituent> predicates) throws Exception { super(solverFactory, false); this.manager = manager; this.outputGenerator = new ILPOutput(manager); List<SenseInstance> instances = new ArrayList<>(); for (Constituent predicate : predicates) { Constituent predicateClone = predicate.cloneForNewView(predicate.getViewName()); SenseInstance x; assert predicateClone.hasAttribute(PredicateArgumentView.LemmaIdentifier); x = new SenseInstance(predicateClone, manager); x.cacheAllFeatureVectors(); instances.add(x); } ta = predicates.get(0).getTextAnnotation(); viewName = SenseManager.getPredictedViewName(); instance = new SentenceInstance(instances); numPredicates = instance.numPredicates(); }
public SRLILPInference(ILPSolverFactory solverFactory, SRLManager manager, List<Constituent> predicates) throws Exception { super(solverFactory, DEBUG); this.manager = manager; this.outputGenerator = new ILPOutput(manager); List<SRLPredicateInstance> instances = new ArrayList<>(); for (Constituent predicate : predicates) { Constituent predicateClone = predicate.cloneForNewView(predicate.getViewName()); SRLPredicateInstance x; assert predicateClone.hasAttribute(PredicateArgumentView.LemmaIdentifier); x = new SRLPredicateInstance(predicateClone, manager, manager.getArgumentIdentifier()); x.cacheAllFeatureVectors(false); instances.add(x); } ta = predicates.get(0).getTextAnnotation(); viewName = manager.getPredictedViewName(); instance = new SRLSentenceInstance(instances); numPredicates = instance.numPredicates(); }
public static List<Constituent> generateCandidates(Constituent predicate, Tree<String> tree){ Constituent predicateClone = predicate.cloneForNewView(viewName); TextAnnotation ta = predicateClone.getTextAnnotation(); int sentenceId = ta.getSentenceId(predicateClone);
View tokenView = ta.getView(ViewNames.TOKENS); for (int i = tokenView.getStartSpan(); i < tokenView.getEndSpan(); i++){ Constituent currentToken = tokenView.getConstituentsCoveringToken(i).get(0).cloneForNewView("BIO"); currentToken.addAttribute("GAZ", gazetteers.annotateConstituent(currentToken, false)); currentToken.addAttribute("BC", brownClusters.getPrefixesCombined(currentToken.toString()));
View tokenView = ta.getView(ViewNames.TOKENS); for (int i = tokenView.getStartSpan(); i < tokenView.getEndSpan(); i++){ Constituent currentToken = tokenView.getConstituentsCoveringToken(i).get(0).cloneForNewView("BIO"); currentToken.addAttribute("GAZ", gazetteers.annotateConstituent(currentToken, false)); currentToken.addAttribute("BC", brownClusters.getPrefixesCombined(currentToken.toString()));
View annotatedTokenView = new SpanLabelView("RE_ANNOTATED", ta); for (Constituent co : ta.getView(ViewNames.TOKENS).getConstituents()){ Constituent c = co.cloneForNewView("RE_ANNOTATED"); for (String s : co.getAttributeKeys()){ c.addAttribute(s, co.getAttribute(s));