-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
111 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
arekit/contrib/experiment_rusentrel/labels/scalers/ruattitudes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from arekit.common.labels.scaler.base import BaseLabelScaler | ||
from arekit.common.opinions.base import Opinion | ||
from arekit.common.text_opinions.base import TextOpinion | ||
from arekit.contrib.source.ruattitudes.sentence.opinion import SentenceOpinion | ||
|
||
|
||
class RuAttitudesSentenceOpinionConverter: | ||
|
||
@staticmethod | ||
def to_text_opinion(sentence_opinion, doc_id, end_to_doc_id_func, text_opinion_id, label_scaler): | ||
""" | ||
Converts opinion into document-level referenced opinion | ||
""" | ||
assert(isinstance(sentence_opinion, SentenceOpinion)) | ||
assert (isinstance(label_scaler, BaseLabelScaler)) | ||
|
||
return TextOpinion(doc_id=doc_id, | ||
text_opinion_id=text_opinion_id, | ||
source_id=end_to_doc_id_func(sentence_opinion.SourceID), | ||
target_id=end_to_doc_id_func(sentence_opinion.TargetID), | ||
owner=None, | ||
label=label_scaler.int_to_label(sentence_opinion.Label)) | ||
|
||
@staticmethod | ||
def to_opinion(sentence_opinion, source_value, target_value, label_scaler): | ||
""" | ||
Converts onto document, non referenced opinion | ||
(non bounded to the text). | ||
""" | ||
assert(isinstance(sentence_opinion, SentenceOpinion)) | ||
assert (isinstance(label_scaler, BaseLabelScaler)) | ||
|
||
opinion = Opinion(source_value=source_value, | ||
target_value=target_value, | ||
sentiment=label_scaler.int_to_label(sentence_opinion.Label)) | ||
|
||
# Using this tag allows to perform a revert operation, | ||
# i.e. to find opinion_ref by opinion. | ||
opinion.set_tag(sentence_opinion.Tag) | ||
|
||
return opinion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.