/** * Given a mention, it returns the list of canonical mentions of the coref chains which overlap * with the input constituent * * @param c the input constituent * @return canonical consittuents of the overlalpping chains with the input constituent */ public HashSet<Constituent> getOverlappingChainsCanonicalMentions(Constituent c) { List<Constituent> overlappingCons = c.getView().getConstituentsCovering(c); HashSet<Constituent> canonicalCons = new HashSet<>(); for (Constituent cc : overlappingCons) canonicalCons.addAll(getCanonicalEntitySetViaRelation(cc)); return canonicalCons; }
/** * Given a mention, it returns the list of canonical mentions of the coref chains which overlap * with the input constituent * * @param c the input constituent * @return canonical consittuents of the overlalpping chains with the input constituent */ public HashSet<Constituent> getOverlappingChainsCanonicalMentions(Constituent c) { List<Constituent> overlappingCons = c.getView().getConstituentsCovering(c); HashSet<Constituent> canonicalCons = new HashSet<>(); for (Constituent cc : overlappingCons) canonicalCons.addAll(getCanonicalEntitySetViaRelation(cc)); return canonicalCons; }
@Override public Set<Feature> getFeatures(Constituent instance) throws EdisonException { Set<Feature> features = new LinkedHashSet<Feature>(); TextAnnotation ta = instance.getTextAnnotation(); View view = ta.getView(viewName); List<Constituent> lsc = view.getConstituentsCovering(instance); if (lsc.size() == 0) { features.add(N); return features; } boolean contains = false; for (Constituent c : lsc) if (contained.contains(c.getTokenizedSurfaceForm()) || contained.contains(c.getLabel())) { contains = true; break; } if (contains) features.add(Y); else features.add(N); return features; } }
@Override public Set<Feature> getFeatures(Constituent instance) throws EdisonException { Set<Feature> features = new LinkedHashSet<Feature>(); TextAnnotation ta = instance.getTextAnnotation(); View view = ta.getView(viewName); List<Constituent> lsc = view.getConstituentsCovering(instance); if (lsc.size() == 0) { features.add(N); return features; } boolean contains = false; for (Constituent c : lsc) if (contained.contains(c.getTokenizedSurfaceForm()) || contained.contains(c.getLabel())) { contains = true; break; } if (contains) features.add(Y); else features.add(N); return features; } }
if (trueCaseView.getConstituentsCovering(tokens.get(consIdx)).size() > 0){ String trueCaseCurToken = trueCaseView.getConstituentsCovering(tokens.get(consIdx)).get(0).getLabel(); if (curToken.length() == trueCaseCurToken.length()){ curToken = trueCaseCurToken;
if (trueCaseView.getConstituentsCovering(tokens.get(consIdx)).size() > 0){ String trueCaseCurToken = trueCaseView.getConstituentsCovering(tokens.get(consIdx)).get(0).getLabel(); if (curToken.length() == trueCaseCurToken.length()){ curToken = trueCaseCurToken;
if (trueCaseView.getConstituentsCovering(tokens.get(consIdx)).size() > 0){ String trueCaseCurToken = trueCaseView.getConstituentsCovering(tokens.get(consIdx)).get(0).getLabel(); if (curToken.length() == trueCaseCurToken.length()){ curToken = trueCaseCurToken;
View ner = sent.getTextAnnotation().getView(ViewNames.NER_CONLL); List<Constituent> nercons = ner.getConstituentsCovering(sent); totaltokens += sent.size(); View ner = sent.getTextAnnotation().getView(ViewNames.NER_CONLL); List<Constituent> nercons = ner.getConstituentsCovering(sent); for (Constituent nercon : nercons) { labeledtokens += nercon.size();
List<Constituent> nerConsts = nerView.getConstituentsCovering(constituent); List<Constituent> posConsts = posView.getConstituentsCovering(constituent); for (int i = 0; i < posConsts.size(); i++) { Constituent posConst = posConsts.get(i);
List<Constituent> nerConsts = nerView.getConstituentsCovering(constituent); List<Constituent> posConsts = posView.getConstituentsCovering(constituent); for (int i = 0; i < posConsts.size(); i++) { Constituent posConst = posConsts.get(i);
List<Constituent> nerc = ner.getConstituentsCovering(sent); for (Constituent name : nerc) { String surf = name.getTokenizedSurfaceForm();
List<Constituent> overlapCons = gazView.getConstituentsCovering(c);
List<Constituent> overlapCons = gazView.getConstituentsCovering(c);
List<Constituent> nercons = sent.getTextAnnotation().getView(ViewNames.NER_CONLL).getConstituentsCovering(sent); for (Constituent nercon : nercons) {
public static void save(String origfolder, String romanfolder, String outfolder) throws IOException { if((new File(outfolder)).exists()) { CoNLLNerReader cnl = new CoNLLNerReader(romanfolder); while (cnl.hasNext()) { TextAnnotation ta = cnl.next(); View ner = ta.getView(ViewNames.NER_CONLL); TextAnnotation taorig = new CoNLLNerReader(origfolder + "/" + ta.getId()).next(); // this should overwrite the (empty) NER_CONLL view. taorig.addView(ViewNames.NER_CONLL, ner); View nerorig = taorig.getView(ViewNames.NER_CONLL); View sents = taorig.getView(ViewNames.SENTENCE); for (Constituent sent : sents.getConstituents()) { String sentid = getSentId(sent); if(nerorig.getConstituentsCovering(sent).size() == 0) continue; // how to rewrite this sentence as a textannotation. SentToConll(sent, outfolder); } } }else{ System.out.println(outfolder + " does not exist. Not doing anything."); } }
c.getTextAnnotation().getView(ViewNames.SENTENCE).getConstituentsCovering(c); if (sentences.isEmpty()) throw new IllegalStateException("Constituent " + c.getSurfaceForm()
c.getTextAnnotation().getView(ViewNames.SENTENCE).getConstituentsCovering(c); if (sentences.isEmpty()) throw new IllegalStateException("Constituent " + c.getSurfaceForm()