OpinionTarget(final OpinionTarget ot, final HashMap<String, Term> terms) { /* Copy span */ final Span<Term> span = ot.span; final List<Term> targets = span.getTargets(); final List<Term> copiedTargets = new ArrayList<Term>(); for (final Term term : targets) { final Term copiedTerm = terms.get(term.getId()); if (copiedTerm == null) { throw new IllegalStateException("Term not found when copying opinion_target"); } copiedTargets.add(copiedTerm); } if (span.hasHead()) { final Term copiedHead = terms.get(span.getHead().getId()); this.span = new Span<Term>(copiedTargets, copiedHead); } else { this.span = new Span<Term>(copiedTargets); } this.externalReferences = new ArrayList<ExternalRef>(); for (final ExternalRef externalRef : ot.getExternalRefs()) { this.externalReferences.add(new ExternalRef(externalRef)); } }
private static List<ExternalRef> getRefs(final Object annotation) { List<ExternalRef> refs = ImmutableList.of(); if (annotation instanceof Term) { refs = ((Term) annotation).getExternalRefs(); } else if (annotation instanceof Entity) { refs = ((Entity) annotation).getExternalRefs(); } else if (annotation instanceof Predicate) { refs = ((Predicate) annotation).getExternalRefs(); } else if (annotation instanceof Role) { refs = ((Role) annotation).getExternalRefs(); } else if (annotation instanceof Opinion) { refs = ((Opinion) annotation).getExternalRefs(); } else if (annotation instanceof OpinionExpression) { refs = ((OpinionExpression) annotation).getExternalRefs(); } else if (annotation instanceof OpinionTarget) { refs = ((OpinionTarget) annotation).getExternalRefs(); } else if (annotation instanceof OpinionHolder) { refs = ((OpinionHolder) annotation).getExternalRefs(); } else { throw new IllegalArgumentException("Unsupported annotation object: " + annotation); } return refs; }
if (!opTarget.getExternalRefs().isEmpty()) { opinionTargetElem.addContent(externalReferencesToDOM(opTarget.getExternalRefs()));