/** * required: consMap *must* contain the source and target constituents for r as keys, and their values * must be non-null * @param r relation to copy * @param consMap map from original constituents to new counterparts * @return new relation with all info copied from original, but with new source and target constituents */ public static Relation copyRelation(Relation r, Map<Constituent, Constituent> consMap) { Relation newRel = null; if ( null == r.getLabelsToScores() ) newRel = new Relation(r.getRelationName(), consMap.get(r.getSource()), consMap.get(r.getTarget()), r.getScore()); else newRel = new Relation(r.getLabelsToScores(), consMap.get(r.getSource()), consMap.get(r.getTarget())); copyAttributesFromTo(r, newRel); return newRel; }
/** * required: consMap *must* contain the source and target constituents for r as keys, and their values * must be non-null * @param r relation to copy * @param consMap map from original constituents to new counterparts * @return new relation with all info copied from original, but with new source and target constituents */ public static Relation copyRelation(Relation r, Map<Constituent, Constituent> consMap) { Relation newRel = null; if ( null == r.getLabelsToScores() ) newRel = new Relation(r.getRelationName(), consMap.get(r.getSource()), consMap.get(r.getTarget()), r.getScore()); else newRel = new Relation(r.getLabelsToScores(), consMap.get(r.getSource()), consMap.get(r.getTarget())); copyAttributesFromTo(r, newRel); return newRel; }
writeAttributes(r, rJ); Map<String, Double> labelsToScores = r.getLabelsToScores();
writeAttributes(r, rJ); Map<String, Double> labelsToScores = r.getLabelsToScores();
/** * required: consMap *must* contain the source and target constituents for r as keys, and their values * must be non-null * @param r relation to copy * @param consMap list containing pairs that map from original constituents to new counterparts * @return new relation with all info copied from original, but with new source and target constituents */ public static Relation copyRelation(Relation r, List<Pair<Constituent, Constituent>> consMap) { Relation newRel = null; Constituent src = null; Constituent tgt = null; // the equality check here is VERY important. Sometimes duplicate constituents are allowed, // and we want to check OBJECT equality, not attribute equality. for(Pair<Constituent,Constituent> p : consMap){ if(r.getSource() == p.getFirst()){ src = p.getSecond(); } if(r.getTarget() == p.getFirst()){ tgt = p.getSecond(); } } if ( null == r.getLabelsToScores() ) newRel = new Relation(r.getRelationName(), src, tgt, r.getScore()); else newRel = new Relation(r.getLabelsToScores(), src, tgt); copyAttributesFromTo(r, newRel); return newRel; }
Map<String, Double> labelsToScores = relation.getLabelsToScores(); if (labelsToScores != null) { relationBuilder.putAllLabelScoreMap(labelsToScores);
Map<String, Double> labelsToScores = relation.getLabelsToScores(); if (labelsToScores != null) { relationBuilder.putAllLabelScoreMap(labelsToScores);