Skip to content

Commit

Permalink
#331 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Jun 12, 2022
1 parent 5dac076 commit 09a50c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
6 changes: 5 additions & 1 deletion arekit/contrib/source/ruattitudes/news/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def __extract_opinion_with_related_sentences(news, sentence_opin_tag):
if opinion is not None:
continue

opinion = sentence_opin.to_opinion()
source, target = sentence.get_objects(sentence_opin)

opinion = sentence_opin.to_opinion(
source_value=source.Value,
target_value=target.Value)

return opinion, related_sentences

Expand Down
9 changes: 2 additions & 7 deletions arekit/contrib/source/ruattitudes/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def iter_news(input_file, get_news_index_func, label_converter):

if RuAttitudesFormatReader.OPINION_KEY in line:
sentence_opin = RuAttitudesFormatReader.__parse_sentence_opin(
line=line,
objects_list=objects_list,
label_converter=label_converter)
line=line, label_converter=label_converter)
opinions_list.append(sentence_opin)

if RuAttitudesFormatReader.FRAMEVAR_TITLE in line:
Expand Down Expand Up @@ -175,8 +173,7 @@ def __parse_sentence(line, is_title):
return text.strip()

@staticmethod
def __parse_sentence_opin(line, objects_list, label_converter):
assert(isinstance(objects_list, list))
def __parse_sentence_opin(line, label_converter):
assert(isinstance(label_converter, RuAttitudesLabelConverter))

line = line[len(RuAttitudesFormatReader.OPINION_KEY):]
Expand All @@ -198,8 +195,6 @@ def __parse_sentence_opin(line, objects_list, label_converter):

sentence_opin = SentenceOpinion(source_id=source_object_id_in_sentence,
target_id=target_object_id_in_sentence,
source_value=objects_list[source_object_id_in_sentence].Value,
target_value=objects_list[target_object_id_in_sentence].Value,
sentiment=label,
tag=opninion_key)

Expand Down
12 changes: 4 additions & 8 deletions arekit/contrib/source/ruattitudes/sentence/opinion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ class SentenceOpinion(object):
Specific for RuAttitudes collection, as the latter provides connections within a sentence.
"""

def __init__(self, source_id, target_id, source_value, target_value, sentiment, tag):
def __init__(self, source_id, target_id, sentiment, tag):
assert(isinstance(source_id, int))
assert(isinstance(target_id, int))
assert(isinstance(source_value, str))
assert(isinstance(target_value, str))
assert(isinstance(sentiment, Label))

self.__source_id = source_id
self.__target_id = target_id
self.__source_value = source_value
self.__target_value = target_value
self.__sentiment = sentiment
self.__tag = tag

Expand Down Expand Up @@ -54,13 +50,13 @@ def to_text_opinion(self, doc_id, end_to_doc_id_func, text_opinion_id):
owner=None,
label=self.__sentiment)

def to_opinion(self):
def to_opinion(self, source_value, target_value):
"""
Converts onto document, non referenced opinion
(non bounded to the text).
"""
opinion = Opinion(source_value=self.__source_value,
target_value=self.__target_value,
opinion = Opinion(source_value=source_value,
target_value=target_value,
sentiment=self.__sentiment)

# Using this tag allows to perform a revert operation,
Expand Down

0 comments on commit 09a50c7

Please sign in to comment.