public SemEvalMentionReader(String file_path, String mode){ initExternalTools(); relations = new ArrayList<>(); List<TextAnnotation> tas = readTrainFile(file_path, mode); System.out.println(tas.size()); for (TextAnnotation ta : tas){ for (Relation r : ta.getView("MENTIONS").getRelations()) { relations.add(r); } } } public void close(){}
/** * generate the target label/feature counts. * @param annotationViews map from doc id to set of views containing the annotations (constituents, relations) * that will be split. */ @Override public void populateLabelCounts(Map<String, Set<View>> annotationViews) { for (String docId : annotationViews.keySet()) { Counter<String> docLabelCount = new Counter<>(); labelCounts.put(docId, docLabelCount); for (View v : annotationViews.get(docId)) { for (Relation r : v.getRelations()) { String label = r.getRelationName(); if (useAllLabels || labelsToConsider.contains(label)) { docLabelCount.incrementCount(label); labelTotals.incrementCount(label); } } for (Constituent c: v.getConstituents()) { String label = c.getLabel(); if (useAllLabels || labelsToConsider.contains(label)) { docLabelCount.incrementCount(label); labelTotals.incrementCount(label); } } } } }
/** * generate the target label/feature counts. * @param annotationViews map from doc id to set of views containing the annotations (constituents, relations) * that will be split. */ @Override public void populateLabelCounts(Map<String, Set<View>> annotationViews) { for (String docId : annotationViews.keySet()) { Counter<String> docLabelCount = new Counter<>(); labelCounts.put(docId, docLabelCount); for (View v : annotationViews.get(docId)) { for (Relation r : v.getRelations()) { String label = r.getRelationName(); if (useAllLabels || labelsToConsider.contains(label)) { docLabelCount.incrementCount(label); labelTotals.incrementCount(label); } } for (Constituent c: v.getConstituents()) { String label = c.getLabel(); if (useAllLabels || labelsToConsider.contains(label)) { docLabelCount.incrementCount(label); labelTotals.incrementCount(label); } } } } }
List<Relation> relations = view.getRelations();
List<Relation> relations = view.getRelations();
mentionAnnotator.addView(ta); relationAnnotator.addView(ta); total_labeled += ta.getView(ViewNames.MENTION_ACE).getRelations().size(); total_predicted += ta.getView(ViewNames.RELATION).getRelations().size(); for (Relation pr : ta.getView(ViewNames.RELATION).getRelations()){ for (Relation gr : ta.getView(ViewNames.MENTION_ACE).getRelations()){ Constituent prSourceHead = RelationFeatureExtractor.getEntityHeadForConstituent(pr.getSource(), ta, ""); Constituent grSourceHead = RelationFeatureExtractor.getEntityHeadForConstituent(gr.getSource(), ta, "");
mentionAnnotator.addView(ta); relationAnnotator.addView(ta); for (Relation r : ta.getView(ViewNames.RELATION).getRelations()){ IOHelper.printRelation(r);
List<Relation> predictedRelations = mentionView.getRelations();
newVu.addConstituent(newC); for (Relation r : vu.getRelations()) {
for (Relation relation: view.getRelations()) { RelationProto.Builder relationBuilder = RelationProto.newBuilder();
newVu.addConstituent(newC); for (Relation r : vu.getRelations()) {
for (Relation relation: view.getRelations()) { RelationProto.Builder relationBuilder = RelationProto.newBuilder();
List<Relation> existRelations = entityView.getRelations(); for (int i = 0; i < ta.getNumberOfSentences(); i++){ Sentence curSentence= ta.getSentence(i);
size_of_gold_relations += goldView.getRelations().size(); for (int i = 0; i < ta.getNumberOfSentences(); i++){ Sentence curSentence = ta.getSentence(i); for (Relation r : goldView.getRelations()){
for (Relation r : vu.getRelations()) {
for (Relation r : vu.getRelations()) {