From 4da94c660b50d09f3b71c6e0014576e8ed1ec94c Mon Sep 17 00:00:00 2001 From: vysitor Date: Mon, 17 Mar 2025 01:48:52 +0100 Subject: [PATCH] Added NLP Entities --- .../gruppe_05_1/domain/nlp/AudioToken.java | 87 +++++++++++++ .../gruppe_05_1/domain/nlp/Dependency.java | 64 ++++++++++ .../gruppe_05_1/domain/nlp/NamedEntity.java | 55 ++++++++ .../gruppe_05_1/domain/nlp/NlpInfo.java | 105 ++++++++++++++++ .../project/gruppe_05_1/domain/nlp/Pos.java | 119 ++++++++++++++++++ .../gruppe_05_1/domain/nlp/Sentence.java | 44 +++++++ .../gruppe_05_1/domain/nlp/Sentiment.java | 97 ++++++++++++++ .../project/gruppe_05_1/domain/nlp/Token.java | 64 ++++++++++ .../project/gruppe_05_1/domain/nlp/Topic.java | 65 ++++++++++ .../domain/nlp/VideoInformation.java | 43 +++++++ .../domain/nlp/html/SentimentOfSentence.java | 112 +++++++++++++++++ 11 files changed, 855 insertions(+) create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/AudioToken.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Dependency.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NamedEntity.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NlpInfo.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Pos.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentence.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentiment.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Token.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Topic.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/VideoInformation.java create mode 100644 src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/html/SentimentOfSentence.java diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/AudioToken.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/AudioToken.java new file mode 100644 index 0000000..de72e1d --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/AudioToken.java @@ -0,0 +1,87 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class AudioToken { + + private int begin; + private int end; + private double timeStart; + private double timeEnd; + private String value; + + public AudioToken() { + } + + public AudioToken(int begin, int end, double timeStart, double timeEnd, String value) { + this.begin = begin; + this.end = end; + this.timeStart = timeStart; + this.timeEnd = timeEnd; + this.value = value; + } + + public int getBegin() { + return begin; + } + + public void setBegin(int begin) { + this.begin = begin; + } + + public int getEnd() { + return end; + } + + public void setEnd(int end) { + this.end = end; + } + + public double getTimeStart() { + return timeStart; + } + + public void setTimeStart(double timeStart) { + this.timeStart = timeStart; + } + + public double getTimeEnd() { + return timeEnd; + } + + public void setTimeEnd(double timeEnd) { + this.timeEnd = timeEnd; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof AudioToken that)) return false; + return begin == that.begin && end == that.end && Double.compare(timeStart, that.timeStart) == 0 && Double.compare(timeEnd, that.timeEnd) == 0 && Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return Objects.hash(begin, end, timeStart, timeEnd, value); + } + + @Override + public String toString() { + return new StringJoiner(", ", AudioToken.class.getSimpleName() + "[", "]") + .add("begin=" + begin) + .add("end=" + end) + .add("timeStart=" + timeStart) + .add("timeEnd=" + timeEnd) + .add("value='" + value + "'") + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Dependency.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Dependency.java new file mode 100644 index 0000000..ad5ead6 --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Dependency.java @@ -0,0 +1,64 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class Dependency { + String type; + String governor; + String dependent; + + public Dependency() { + } + + public Dependency(String type, String governor, String dependent) { + this.type = type; + this.governor = governor; + this.dependent = dependent; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getGovernor() { + return governor; + } + + public void setGovernor(String governor) { + this.governor = governor; + } + + public String getDependent() { + return dependent; + } + + public void setDependent(String dependent) { + this.dependent = dependent; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Dependency that)) return false; + return Objects.equals(type, that.type) && Objects.equals(governor, that.governor) && Objects.equals(dependent, that.dependent); + } + + @Override + public int hashCode() { + return Objects.hash(type, governor, dependent); + } + + @Override + public String toString() { + return new StringJoiner(", ", Dependency.class.getSimpleName() + "[", "]") + .add("type='" + type + "'") + .add("governor='" + governor + "'") + .add("dependent='" + dependent + "'") + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NamedEntity.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NamedEntity.java new file mode 100644 index 0000000..0f3ec5d --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NamedEntity.java @@ -0,0 +1,55 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class NamedEntity { + String type; // PER, LOC etc. + // int begin; // TODO: momentan nicht in MongoDB + // int end; // TODO: momentan nicht in MongoDB + String text; + + public NamedEntity() { + } + + public NamedEntity(String type, String text) { + this.type = type; + this.text = text; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof NamedEntity that)) return false; + return Objects.equals(type, that.type) && Objects.equals(text, that.text); + } + + @Override + public int hashCode() { + return Objects.hash(type, text); + } + + @Override + public String toString() { + return new StringJoiner(", ", NamedEntity.class.getSimpleName() + "[", "]") + .add("type='" + type + "'") + .add("text='" + text + "'") + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NlpInfo.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NlpInfo.java new file mode 100644 index 0000000..442bca8 --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/NlpInfo.java @@ -0,0 +1,105 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.List; +import java.util.Objects; + +public class NlpInfo { + List tokens; + List sentences; + List dependencies; + List namedEntities; + Sentiment overallSentiment; // Sentiment for the whole text ; kann null sein! + List sentiments; // sentiments for the respective sentences (eine Liste von 0..n Elementen) + List topic; + List posList; + + VideoInformation videoInformation; + + public List getTokens() { + return tokens; + } + + public void setTokens(List tokens) { + this.tokens = tokens; + } + + public List getSentences() { + return sentences; + } + + public void setSentences(List sentences) { + this.sentences = sentences; + } + + public List getDependencies() { + return dependencies; + } + + public void setDependencies(List dependencies) { + this.dependencies = dependencies; + } + + public List getNamedEntities() { + return namedEntities; + } + + public void setNamedEntities(List namedEntities) { + this.namedEntities = namedEntities; + } + + public Sentiment getOverallSentiment() { + return overallSentiment; + } + + public void setOverallSentiment(Sentiment overallSentiment) { + this.overallSentiment = overallSentiment; + } + + public List getSentiments() { + return sentiments; + } + + public void setSentiments(List sentiments) { + this.sentiments = sentiments; + } + + public List getTopic() { + return topic; + } + + public void setTopic(List topic) { + this.topic = topic; + } + + public List getPosList() { + return posList; + } + + public void setPosList(List posList) { + this.posList = posList; + } + + public VideoInformation getVideoInformation() { + return videoInformation; + } + + public void setVideoInformation(VideoInformation videoInformation) { + this.videoInformation = videoInformation; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof NlpInfo nlpInfo)) return false; + return Objects.equals(tokens, nlpInfo.tokens) && Objects.equals(sentences, nlpInfo.sentences) + && Objects.equals(dependencies, nlpInfo.dependencies) && Objects.equals(namedEntities, nlpInfo.namedEntities) + && Objects.equals(overallSentiment, nlpInfo.overallSentiment) && Objects.equals(sentiments, nlpInfo.sentiments) + && Objects.equals(topic, nlpInfo.topic) && Objects.equals(posList, nlpInfo.posList) + && Objects.equals(videoInformation, nlpInfo.videoInformation); + } + + @Override + public int hashCode() { + return Objects.hash(tokens, sentences, dependencies, namedEntities, overallSentiment, sentiments, topic, posList, videoInformation); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Pos.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Pos.java new file mode 100644 index 0000000..74f027a --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Pos.java @@ -0,0 +1,119 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class Pos { + String posValue; // ART, NN... + String coarseValue; // PROPN... + int begin; + int end; + String coveredText; + + // Am Dateiende stehen beispiele für mögliche Werte + + + public Pos() { + } + + public Pos(String posValue, String coarseValue, int begin, int end, String coveredText) { + this.posValue = posValue; + this.coarseValue = coarseValue; + this.begin = begin; + this.end = end; + this.coveredText = coveredText; + } + + public String getPosValue() { + return posValue; + } + + public void setPosValue(String posValue) { + this.posValue = posValue; + } + + public String getCoarseValue() { + return coarseValue; + } + + public void setCoarseValue(String coarseValue) { + this.coarseValue = coarseValue; + } + + public int getBegin() { + return begin; + } + + public void setBegin(int begin) { + this.begin = begin; + } + + public int getEnd() { + return end; + } + + public void setEnd(int end) { + this.end = end; + } + + public String getCoveredText() { + return coveredText; + } + + public void setCoveredText(String coveredText) { + this.coveredText = coveredText; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Pos pos)) return false; + return begin == pos.begin && end == pos.end && Objects.equals(posValue, pos.posValue) && Objects.equals(coarseValue, pos.coarseValue) && Objects.equals(coveredText, pos.coveredText); + } + + @Override + public int hashCode() { + return Objects.hash(posValue, coarseValue, begin, end, coveredText); + } + + @Override + public String toString() { + return new StringJoiner(", ", Pos.class.getSimpleName() + "[", "]") + .add("posValue='" + posValue + "'") + .add("coarseValue='" + coarseValue + "'") + .add("begin=" + begin) + .add("end=" + end) + .add("coveredText='" + coveredText + "'") + .toString(); + } + + /* Beispielswerte: + + MyPos{posValue='ART', coarseValue='DET', begin=0, end=3, coveredText='Die'}, + MyPos{posValue='NN', coarseValue='NOUN', begin=4, end=8, coveredText='Idee'}, + MyPos{posValue='APPR', coarseValue='ADP', begin=9, end=12, coveredText='von'}, + MyPos{posValue='NE', coarseValue='PROPN', begin=13, end=16, coveredText='Joe'}, + MyPos{posValue='NN', coarseValue='PROPN', begin=17, end=22, coveredText='Biden'}, + MyPos{posValue='APPR', coarseValue='ADP', begin=23, end=26, coveredText='aus'}, + MyPos{posValue='NE', coarseValue='PROPN', begin=27, end=36, coveredText='Bucharest'}, + MyPos{posValue='$,', coarseValue='PUNCT', begin=36, end=37, coveredText=','}, + MyPos{posValue='NE', coarseValue='PROPN', begin=38, end=46, coveredText='Rumänien'}, + MyPos{posValue='$,', coarseValue='PUNCT', begin=46, end=47, coveredText=','}, + MyPos{posValue='VVFIN', coarseValue='VERB', begin=48, end=53, coveredText='finde'}, + MyPos{posValue='PPER', coarseValue='PRON', begin=54, end=57, coveredText='ich'}, + MyPos{posValue='ADJD', coarseValue='ADV', begin=58, end=61, coveredText='gut'}, + MyPos{posValue='$.', coarseValue='PUNCT', begin=61, end=62, coveredText='.'}, + MyPos{posValue='ART', coarseValue='DET', begin=63, end=66, coveredText='Den'}, + MyPos{posValue='NN', coarseValue='NOUN', begin=67, end=76, coveredText='Vorschlag'}, + MyPos{posValue='APPR', coarseValue='ADP', begin=77, end=80, coveredText='von'}, + MyPos{posValue='NE', coarseValue='PROPN', begin=81, end=87, coveredText='Donald'}, + MyPos{posValue='NE', coarseValue='PROPN', begin=88, end=93, coveredText='Trump'}, + MyPos{posValue='APPR', coarseValue='ADP', begin=94, end=97, coveredText='aus'}, + MyPos{posValue='NE', coarseValue='PROPN', begin=98, end=108, coveredText='Frankreich'}, + MyPos{posValue='VVFIN', coarseValue='VERB', begin=109, end=114, coveredText='finde'}, + MyPos{posValue='PPER', coarseValue='PRON', begin=115, end=118, coveredText='ich'}, + MyPos{posValue='ADV', coarseValue='ADV', begin=119, end=126, coveredText='weniger'}, + MyPos{posValue='ADJD', coarseValue='ADV', begin=127, end=130, coveredText='gut'}, + MyPos{posValue='$.', coarseValue='PUNCT', begin=130, end=131, coveredText='.'}], + */ +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentence.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentence.java new file mode 100644 index 0000000..213f58e --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentence.java @@ -0,0 +1,44 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class Sentence { + // int begin; // TODO: momentan nicht in MongoDB + // int end; // TODO: momentan nicht in MongoDB + String text; + + public Sentence() { + } + + public Sentence(String text) { + this.text = text; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Sentence sentence)) return false; + return Objects.equals(text, sentence.text); + } + + @Override + public int hashCode() { + return Objects.hash(text); + } + + @Override + public String toString() { + return new StringJoiner(", ", Sentence.class.getSimpleName() + "[", "]") + .add("text='" + text + "'") + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentiment.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentiment.java new file mode 100644 index 0000000..a2f04e3 --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Sentiment.java @@ -0,0 +1,97 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class Sentiment { + int begin; + int end; + double sentiment; // overall sentiment + double negative; + double neutral; + double positive; + + public Sentiment() { + } + + public Sentiment(int begin, int end, double sentiment, double negative, double neutral, double positive) { + this.begin = begin; + this.end = end; + this.sentiment = sentiment; + this.negative = negative; + this.neutral = neutral; + this.positive = positive; + } + + public int getBegin() { + return begin; + } + + public void setBegin(int begin) { + this.begin = begin; + } + + public int getEnd() { + return end; + } + + public void setEnd(int end) { + this.end = end; + } + + public double getSentiment() { + return sentiment; + } + + public void setSentiment(double sentiment) { + this.sentiment = sentiment; + } + + public double getNegative() { + return negative; + } + + public void setNegative(double negative) { + this.negative = negative; + } + + public double getNeutral() { + return neutral; + } + + public void setNeutral(double neutral) { + this.neutral = neutral; + } + + public double getPositive() { + return positive; + } + + public void setPositive(double positive) { + this.positive = positive; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Sentiment sentiment1)) return false; + return begin == sentiment1.begin && end == sentiment1.end && Double.compare(sentiment, sentiment1.sentiment) == 0 && Double.compare(negative, sentiment1.negative) == 0 && Double.compare(neutral, sentiment1.neutral) == 0 && Double.compare(positive, sentiment1.positive) == 0; + } + + @Override + public int hashCode() { + return Objects.hash(begin, end, sentiment, negative, neutral, positive); + } + + @Override + public String toString() { + return new StringJoiner(", ", Sentiment.class.getSimpleName() + "[", "]") + .add("begin=" + begin) + .add("end=" + end) + .add("sentiment=" + sentiment) + .add("negative=" + negative) + .add("neutral=" + neutral) + .add("positive=" + positive) + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Token.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Token.java new file mode 100644 index 0000000..d751320 --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Token.java @@ -0,0 +1,64 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class Token { + String text; + String pos; + String lemma; + + public Token() { + } + + public Token(String text, String pos, String lemma) { + this.text = text; + this.pos = pos; + this.lemma = lemma; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getPos() { + return pos; + } + + public void setPos(String pos) { + this.pos = pos; + } + + public String getLemma() { + return lemma; + } + + public void setLemma(String lemma) { + this.lemma = lemma; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Token token)) return false; + return Objects.equals(text, token.text) && Objects.equals(pos, token.pos) && Objects.equals(lemma, token.lemma); + } + + @Override + public int hashCode() { + return Objects.hash(text, pos, lemma); + } + + @Override + public String toString() { + return new StringJoiner(", ", Token.class.getSimpleName() + "[", "]") + .add("text='" + text + "'") + .add("pos='" + pos + "'") + .add("lemma='" + lemma + "'") + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Topic.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Topic.java new file mode 100644 index 0000000..3a363e4 --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/Topic.java @@ -0,0 +1,65 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.Objects; +import java.util.StringJoiner; + +public class Topic { + String topic; + double score; + // tags TODO + String text; + + public Topic() { + } + + public Topic(String topic, double score, String text) { + this.topic = topic; + this.score = score; + this.text = text; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public double getScore() { + return score; + } + + public void setScore(double score) { + this.score = score; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Topic topic1)) return false; + return Double.compare(score, topic1.score) == 0 && Objects.equals(topic, topic1.topic) && Objects.equals(text, topic1.text); + } + + @Override + public int hashCode() { + return Objects.hash(topic, score, text); + } + + @Override + public String toString() { + return new StringJoiner(", ", Topic.class.getSimpleName() + "[", "]") + .add("topic='" + topic + "'") + .add("score=" + score) + .add("text='" + text + "'") + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/VideoInformation.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/VideoInformation.java new file mode 100644 index 0000000..e33db12 --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/VideoInformation.java @@ -0,0 +1,43 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp; + +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +public class VideoInformation { + List audioTokens; + + public VideoInformation() { + } + + public VideoInformation(List audioTokens) { + this.audioTokens = audioTokens; + } + + public List getAudioTokens() { + return audioTokens; + } + + public void setAudioTokens(List audioTokens) { + this.audioTokens = audioTokens; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof VideoInformation that)) return false; + return Objects.equals(audioTokens, that.audioTokens); + } + + @Override + public int hashCode() { + return Objects.hash(audioTokens); + } + + @Override + public String toString() { + return new StringJoiner(", ", VideoInformation.class.getSimpleName() + "[", "]") + .add("audioTokens=" + audioTokens) + .toString(); + } +} diff --git a/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/html/SentimentOfSentence.java b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/html/SentimentOfSentence.java new file mode 100644 index 0000000..d96dcf0 --- /dev/null +++ b/src/main/java/org/texttechnologylab/project/gruppe_05_1/domain/nlp/html/SentimentOfSentence.java @@ -0,0 +1,112 @@ +package org.texttechnologylab.project.gruppe_05_1.domain.nlp.html; + +import java.util.Objects; + +/** + * Diese Klasse ordnet das entspreche Sentiment zu einem Satz zu. + * Sie ist ein Datencontainer für die Darstellung über FreeMarker + */ +public class SentimentOfSentence { + int begin; + int end; + String text; + // RGBA Werte für die Darstellung + float sentiment; // overall sentiment --> wird für den alpha (Opaque) Wert verwendet --> 0..1 + int negative; // red --> 0..255 + int neutral; // 0..255, wird momentan nicht benutzt + int positive; // green --> 0..255 + + public SentimentOfSentence() {} + + public SentimentOfSentence(int begin, int end, String text, float sentiment, int negative, int neutral, int positive) { + this.begin = begin; + this.end = end; + this.text = text; + this.sentiment = sentiment; + this.negative = negative; + this.neutral = neutral; + this.positive = positive; + } + + public int getBegin() { + return begin; + } + + public void setBegin(int begin) { + this.begin = begin; + } + + public int getEnd() { + return end; + } + + public void setEnd(int end) { + this.end = end; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public float getSentiment() { + return sentiment; + } + + public void setSentiment(float sentiment) { + this.sentiment = sentiment; + } + + public int getNegative() { + return negative; + } + + public void setNegative(int negative) { + this.negative = negative; + } + + public int getNeutral() { + return neutral; + } + + public void setNeutral(int neutral) { + this.neutral = neutral; + } + + public int getPositive() { + return positive; + } + + public void setPositive(int positive) { + this.positive = positive; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof SentimentOfSentence that)) return false; + return begin == that.begin && end == that.end && Double.compare(sentiment, that.sentiment) == 0 && Double.compare(negative, that.negative) == 0 && Double.compare(neutral, that.neutral) == 0 && Double.compare(positive, that.positive) == 0 && Objects.equals(text, that.text); + } + + @Override + public int hashCode() { + return Objects.hash(begin, end, text, sentiment, negative, neutral, positive); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("SentimentOfSentence{"); + sb.append("begin=").append(begin); + sb.append(", end=").append(end); + sb.append(", text='").append(text).append('\''); + sb.append(", sentiment=").append(sentiment); + sb.append(", negative=").append(negative); + sb.append(", neutral=").append(neutral); + sb.append(", positive=").append(positive); + sb.append('}'); + return sb.toString(); + } +} +