/** * Adds a new view identified by {@code viewName} and sets the top K values for this view. * * @param viewName The name of the new view to be added. * @param view The top K views */ public void addTopKView(String viewName, List<View> view) { if (this instanceof TextAnnotation && view.get(0).getTextAnnotation() != this) { throw new IllegalArgumentException( "Trying to add a view belonging to a different TextAnnotation!"); } // sort in descending order by score Collections.sort(view, new Comparator<View>() { public int compare(View o1, View o2) { if (o1.getScore() > o2.getScore()) return -1; else if (o1.getScore() == o2.getScore()) return 0; else return 1; } }); views.put(viewName, view); }
/** * Adds a new view identified by {@code viewName} and sets the top K values for this view. * * @param viewName The name of the new view to be added. * @param view The top K views */ public void addTopKView(String viewName, List<View> view) { if (this instanceof TextAnnotation && view.get(0).getTextAnnotation() != this) { throw new IllegalArgumentException( "Trying to add a view belonging to a different TextAnnotation!"); } // sort in descending order by score Collections.sort(view, new Comparator<View>() { public int compare(View o1, View o2) { if (o1.getScore() > o2.getScore()) return -1; else if (o1.getScore() == o2.getScore()) return 0; else return 1; } }); views.put(viewName, view); }
/** * Creates a view for {@code text} called {@code viewName} which is created using a view * generator called {@code ViewGenerator} and is assigned a score {@code score} * * @param viewName The name of this view * @param viewGenerator The source of this view * @param text The text annotation that this view annotates * @param score The score of this view */ public View(String viewName, String viewGenerator, TextAnnotation text, double score) { this.viewName = viewName; this.viewGenerator = viewGenerator; this.textAnnotation = text; this.score = score; constituents = new QueryableList<>(); relations = new QueryableList<>(); startSpan = Integer.MAX_VALUE; endSpan = -1; this.tokensToConstituents = new ArrayList[this.getTextAnnotation().size()]; }
/** * Creates a view for {@code text} called {@code viewName} which is created using a view * generator called {@code ViewGenerator} and is assigned a score {@code score} * * @param viewName The name of this view * @param viewGenerator The source of this view * @param text The text annotation that this view annotates * @param score The score of this view */ public View(String viewName, String viewGenerator, TextAnnotation text, double score) { this.viewName = viewName; this.viewGenerator = viewGenerator; this.textAnnotation = text; this.score = score; constituents = new QueryableList<>(); relations = new QueryableList<>(); startSpan = Integer.MAX_VALUE; endSpan = -1; this.tokensToConstituents = new ArrayList[this.getTextAnnotation().size()]; }
new Constituent(entityType, view.getViewName(), view.getTextAnnotation(), offsets.getFirst(), offsets.getSecond() + 1); mentionConstituent.addAttribute(EntityMentionTypeAttribute, noun_type);
new Constituent(fillerType, view.getViewName(), view.getTextAnnotation(), offsets.getFirst(), offsets.getSecond() + 1); fillerConstituent.addAttribute(EntityMentionIdAttribute, fillerId);
new Constituent(entityType, view.getViewName(), view.getTextAnnotation(), offsets.getFirst(), offsets.getSecond() + 1); mentionConstituent.addAttribute(EntityMentionTypeAttribute, noun_type);
new Constituent(fillerType, view.getViewName(), view.getTextAnnotation(), offsets.getFirst(), offsets.getSecond() + 1); fillerConstituent.addAttribute(EntityMentionIdAttribute, fillerId);
TextAnnotation ta = view.getTextAnnotation();
if(consSet.size() < constituents.size()) { logger.error("There are "+(constituents.size()-consSet.size())+" duplicates constituents in the '" + view.getViewName() + "' view. " + "You have to fix this otherwise things will be messed up, upon deserialization : "+view.getTextAnnotation().getId());
if(consSet.size() < constituents.size()) { logger.error("There are "+(constituents.size()-consSet.size())+" duplicates constituents in the '" + view.getViewName() + "' view. " + "You have to fix this otherwise things will be messed up, upon deserialization : "+view.getTextAnnotation().getId());