if (opinion.getLabel().equals("gold-influencer")) { Opinion.OpinionExpression expression = opinion.getOpinionExpression(); if (expression.getPolarity().equals("reverse")) { influenceRev.add(spanToLemmas(expression.getSpan())); if (expression.getPolarity().equals("retain")) { influenceRet.add(spanToLemmas(expression.getSpan())); if (expression.getPolarity().equals("goodfor")) { goodFor.add(spanToLemmas(expression.getSpan())); if (expression.getPolarity().equals("badfor")) { badFor.add(spanToLemmas(expression.getSpan()));
continue; for (final Term term : opinion.getOpinionExpression().getTerms()) { if (this.sentenceIDs[term.getSent()]) { processOpinion(opinion);
opinionExpression.setPolarity(expressionNode.attributes.get("pol")); opinionExpression.setStrength(expressionNode.attributes.get("int")); opinionExpression.setSentimentProductFeature(hiddenAgents.get(agentID)); break holders; attitude.setLabel("gold-eu.fbk.dkm.pikes.resources.mpqa-attitude-" + type); Opinion.OpinionExpression attitudeExpression = attitude.createOpinionExpression((Span<Term>) target.get("expression")); attitudeExpression.setPolarity(expressionNode.attributes.get("pol")); attitudeExpression.setStrength(expressionNode.attributes.get("int")); opinionExpression.setPolarity(expressionNode.attributes.get("pol")); opinionExpression.setStrength(expressionNode.attributes.get("int")); opinionExpression.setSentimentProductFeature(hiddenAgents.get(agentID)); break holders; opinionExpression.setSentimentProductFeature(hiddenAgents.get(agentID)); break holders;
Opinion.OpinionExpression opinionExpression = opinion.createOpinionExpression(span); if (polarity != null) { opinionExpression.setPolarity(polarity); opinionExpression.setStrength(strength); opinionExpression.setSubjectivity(subjectivity); opinionExpression.setSentimentSemanticType(sentimentSemanticType); opinionExpression.setSentimentProductFeature(sentimentProductFeature); if (expressionExternalRefs.size() > 0) { opinionExpression .addExternalRefs(getExternalReferences(expressionExternalRefs.get(0), kaf));
if (expression != null) { Element opinionExpressionElem = new Element("opinion_expression"); Comment comment = new Comment(StringEscapeUtils.escapeXml11(opinion.getSpanStr(opinion.getOpinionExpression().getSpan()))); opinionExpressionElem.addContent(comment); if (expression.hasPolarity()) { opinionExpressionElem.setAttribute("polarity", expression.getPolarity()); if (expression.hasStrength()) { opinionExpressionElem.setAttribute("strength", expression.getStrength()); if (expression.hasSubjectivity()) { opinionExpressionElem.setAttribute("subjectivity", expression.getSubjectivity()); if (expression.hasSentimentSemanticType()) { opinionExpressionElem.setAttribute("sentiment_semantic_type", expression.getSentimentSemanticType()); if (expression.hasSentimentProductFeature()) { opinionExpressionElem.setAttribute("sentiment_product_feature", expression.getSentimentProductFeature()); List<Term> targets = expression.getTerms(); Span<Term> span = expression.getSpan(); if (targets.size() > 0) { Element spanElem = new Element("span");
Opinion.OpinionExpression opinionExpression = opinion.createOpinionExpression(span); if (polarity != null) { opinionExpression.setPolarity(polarity); opinionExpression.setStrength(strength); opinionExpression.setSubjectivity(subjectivity); opinionExpression.setSentimentSemanticType(sentimentSemanticType); opinionExpression.setSentimentProductFeature(sentimentProductFeature);
if (expression != null) { Element opinionExpressionElem = new Element("opinion_expression"); Comment comment = new Comment(opinion.getSpanStr(opinion.getOpinionExpression().getSpan())); opinionExpressionElem.addContent(comment); if (expression.hasPolarity()) { opinionExpressionElem.setAttribute("polarity", expression.getPolarity()); if (expression.hasStrength()) { opinionExpressionElem.setAttribute("strength", expression.getStrength()); if (expression.hasSubjectivity()) { opinionExpressionElem.setAttribute("subjectivity", expression.getSubjectivity()); if (expression.hasSentimentSemanticType()) { opinionExpressionElem .setAttribute("sentiment_semantic_type", expression.getSentimentSemanticType()); if (expression.hasSentimentProductFeature()) { opinionExpressionElem .setAttribute("sentiment_product_feature", expression.getSentimentProductFeature()); List<Term> targets = expression.getTerms(); Span<Term> span = expression.getSpan(); if (targets.size() > 0) { Element spanElem = new Element("span"); if (!expression.getExternalRefs().isEmpty()) { opinionExpressionElem.addContent(externalReferencesToDOM(expression.getExternalRefs()));
opinion.getOpinionExpression().setPolarity(properties.get("sentiment")); opinion.getOpinionExpression().setStrength(properties.get("intensity"));
Opinion.OpinionExpression expression = opinion.createOpinionExpression(termSpan); if (markable.get("polarity") != null) { expression.setPolarity(markable.get("polarity")); expression.setStrength(markable.get("strength"));
opinion.getOpinionExpression().setPolarity(record.getValue(attribute));
for (Term term : opinion.getOpinionExpression().getTerms()) { termSpan.addTarget(nafTerms.get(idConverter.get(term.getId()))); expression.setPolarity(opinion.getOpinionExpression().getPolarity());
return "opinion holder '" + ((OpinionHolder) annotation).getSpan().getStr() + "'"; } else if (annotation instanceof OpinionExpression) { return "opinion expression '" + ((OpinionExpression) annotation).getSpan().getStr() + "'"; } else if (annotation instanceof Factuality) {
private void processOpinion(final Opinion opinion) { final int sentenceID = opinion.getOpinionExpression().getTerms().get(0).getSent(); opinion.getOpinionExpression().getSpan(), sentenceID); final Set<Term> exprHeads = exprSpan == null ? ImmutableSet.<Term>of() : NAFUtils .extractHeads(this.document, null, exprSpan.getTargets(),
OpinionExpression(final OpinionExpression oe, final HashMap<String, Term> terms) { this.polarity = oe.polarity; this.strength = oe.strength; this.subjectivity = oe.subjectivity; this.sentimentSemanticType = oe.sentimentSemanticType; this.sentimentProductFeature = oe.sentimentProductFeature; /* Copy span */ final Span<Term> span = oe.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_expression"); } 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 : oe.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; }
public String getStr() { return getSpanStr(getOpinionExpression().getSpan()); }
public Span<Term> getExpressionSpan() { return this.opinionExpression == null ? null : this.opinionExpression.getSpan(); }
public String getStr() { return getSpanStr(this.getOpinionExpression().getSpan()); }
Opinion(final Opinion opinion, final HashMap<String, Term> terms) { this.id = opinion.id; if (opinion.opinionHolder != null) { this.opinionHolder = new OpinionHolder(opinion.opinionHolder, terms); } if (opinion.opinionTarget != null) { this.opinionTarget = new OpinionTarget(opinion.opinionTarget, terms); } if (opinion.opinionExpression != null) { this.opinionExpression = new OpinionExpression(opinion.opinionExpression, terms); } this.externalReferences = new ArrayList<ExternalRef>(); for (final ExternalRef externalRef : opinion.getExternalRefs()) { this.externalReferences.add(new ExternalRef(externalRef)); } }