public String getPredicateSense(Constituent predicate) { if (predicate.hasAttribute(SenseIdentifer)) return predicate.getAttribute(SenseIdentifer); else return ""; }
public String getPredicateSense(Constituent predicate) { if (predicate.hasAttribute(SenseIdentifer)) return predicate.getAttribute(SenseIdentifer); else return ""; }
public String getPredicateLemma(Constituent predicate) { if (predicate.hasAttribute(LemmaIdentifier)) return predicate.getAttribute(LemmaIdentifier); else return predicate.getTokenizedSurfaceForm().toLowerCase().trim(); }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { Set<Feature> set = new LinkedHashSet<>(); if (c.hasAttribute(attributeName)) { set.add(DiscreteFeature.create(c.getAttribute(attributeName))); } return set; }
public String getPredicateLemma(Constituent predicate) { if (predicate.hasAttribute(LemmaIdentifier)) return predicate.getAttribute(LemmaIdentifier); else return predicate.getTokenizedSurfaceForm().toLowerCase().trim(); }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { Set<Feature> set = new LinkedHashSet<>(); if (c.hasAttribute(attributeName)) { set.add(DiscreteFeature.create(c.getAttribute(attributeName))); } return set; }
/** * Generates SRL examples using the predicate detector to identify predicates */ private void getExamples(TextAnnotation ta, List<SenseInstance> predicates) throws Exception { PredicateDetector predicateDetector = manager.getPredicateDetector(); for (Constituent predicate : predicateDetector.getPredicates(ta)) { if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(predicate + " has no lemma!"); assert false; } SenseInstance x = new SenseInstance(predicate, manager); predicates.add(x); } }
/** * Generates SRL examples using the predicate detector to identify predicates */ private void getExamples(TextAnnotation ta, List<SRLPredicateInstance> predicates) throws Exception { AbstractPredicateDetector predicateDetector = manager.getLearnedPredicateDetector(); for (Constituent predicate : predicateDetector.getPredicates(ta)) { if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(predicate + " has no lemma!"); assert false; } SRLPredicateInstance x = new SRLPredicateInstance(predicate, manager); predicates.add(x); } }
/** * Generates SRL examples using the predicate detector to identify predicates */ private void getExamples(TextAnnotation ta, List<SenseInstance> predicates) throws Exception { PredicateDetector predicateDetector = manager.getPredicateDetector(); for (Constituent predicate : predicateDetector.getPredicates(ta)) { if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(predicate + " has no lemma!"); assert false; } SenseInstance x = new SenseInstance(predicate, manager); predicates.add(x); } }
private void getTreebankExamples(TextAnnotation ta, List<SenseInstance> predicates, List<SenseStructure> structures) { TokenLabelView view = (TokenLabelView) ta.getView(SenseManager.getGoldViewName()); for (Constituent predicate : view.getConstituents()) { if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(view); System.out.println(predicate + " has no lemma!"); assert false; } SenseInstance x = new SenseInstance(predicate, manager); int sense = manager.getSenseId(predicate.getLabel()); SenseStructure y = new SenseStructure(x, sense, manager); predicates.add(x); structures.add(y); } } }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { int tokenId = c.getEndSpan() - 1; TextAnnotation ta = c.getTextAnnotation(); String predicateWord = ta.getToken(tokenId).toLowerCase().trim(); String predicateLemma; if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier)) predicateLemma = c.getAttribute(PredicateArgumentView.LemmaIdentifier); else predicateLemma = WordHelpers.getLemma(ta, tokenId); NomLexReader nomLex = NomLexReader.getInstance(); List<NomLexEntry> nomLexEntries = nomLex.getNomLexEntries(predicateWord, predicateLemma); Set<Feature> features = new LinkedHashSet<>(); if (nomLexEntries.size() > 0) { for (NomLexEntry e : nomLexEntries) { features.add(DiscreteFeature.create("nom-cls:" + e.nomClass)); if (NomLexEntry.VERBAL.contains(e.nomClass)) { features.add(DE_VERBAL); features.add(DiscreteFeature.create("nom-vb:" + e.verb)); } else if (NomLexEntry.ADJECTIVAL.contains(e.nomClass)) { features.add(DE_ADJECTIVAL); features.add(DiscreteFeature.create("nom-adj:" + e.adj)); } } } return features; }
private void getTreebankExamples(TextAnnotation ta, List<SenseInstance> predicates, List<SenseStructure> structures) { TokenLabelView view = (TokenLabelView) ta.getView(SenseManager.getGoldViewName()); for (Constituent predicate : view.getConstituents()) { if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(view); System.out.println(predicate + " has no lemma!"); assert false; } SenseInstance x = new SenseInstance(predicate, manager); int sense = manager.getSenseId(predicate.getLabel()); SenseStructure y = new SenseStructure(x, sense, manager); predicates.add(x); structures.add(y); } } }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { int tokenId = c.getEndSpan() - 1; TextAnnotation ta = c.getTextAnnotation(); String predicateWord = ta.getToken(tokenId).toLowerCase().trim(); String predicateLemma; if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier)) predicateLemma = c.getAttribute(PredicateArgumentView.LemmaIdentifier); else predicateLemma = WordHelpers.getLemma(ta, tokenId); NomLexReader nomLex = NomLexReader.getInstance(); List<NomLexEntry> nomLexEntries = nomLex.getNomLexEntries(predicateWord, predicateLemma); Set<Feature> features = new LinkedHashSet<>(); if (nomLexEntries.size() > 0) { for (NomLexEntry e : nomLexEntries) { features.add(DiscreteFeature.create("nom-cls:" + e.nomClass)); if (NomLexEntry.VERBAL.contains(e.nomClass)) { features.add(DE_VERBAL); features.add(DiscreteFeature.create("nom-vb:" + e.verb)); } else if (NomLexEntry.ADJECTIVAL.contains(e.nomClass)) { features.add(DE_ADJECTIVAL); features.add(DiscreteFeature.create("nom-adj:" + e.adj)); } } } return features; }
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(); }
if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(pav);
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(); }
private String getLemma(Constituent c) { if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { return c.getAttribute(PredicateArgumentView.LemmaIdentifier); } else if (c.getTextAnnotation().hasView(ViewNames.LEMMA)) { return WordHelpers.getLemma(c.getTextAnnotation(), c.getEndSpan() - 1); } else return null; }
private String getLemma(Constituent c) { if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { return c.getAttribute(PredicateArgumentView.LemmaIdentifier); } else if (c.getTextAnnotation().hasView(ViewNames.LEMMA)) { return WordHelpers.getLemma(c.getTextAnnotation(), c.getEndSpan() - 1); } else return null; }
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(); }
return MentionAnnotator.getHeadConstituent(extentConstituent, viewName); if (!extentConstituent.hasAttribute(ACEReader.EntityHeadStartCharOffset)){ return extentConstituent;