Skip to content

Commit

Permalink
#355 fixed bug: text_opinion actualy required information that would …
Browse files Browse the repository at this point in the history
…describe a text part, i.e. ContextID.
  • Loading branch information
nicolay-r committed Jul 26, 2022
1 parent 5d8cc48 commit 709138a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions arekit/common/evaluation/comparators/text_opinions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def context_opinion_to_id(context_opinion):
"""
assert(isinstance(context_opinion, ContextOpinion))
return "{doc_id}_{ctx_id}_{src_id}_{tgt_id}".format(
doc_id=context_opinion.DocID,
ctx_id=context_opinion.ContextID,
doc_id=context_opinion.DocId,
ctx_id=context_opinion.ContextId,
src_id=context_opinion.SourceId,
tgt_id=context_opinion.TargetId)

Expand Down
35 changes: 23 additions & 12 deletions arekit/common/evaluation/context_opinion.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
from arekit.common.text_opinions.base import TextOpinion


class ContextOpinion(TextOpinion):
class ContextOpinion(object):
""" This is a text opnion that is a part of a text piece, dubbed as context.
"""

def __int__(self, doc_id, text_opinion_id, source_id, target_id, label, context_id):
def __int__(self, doc_id, source_id, target_id, label, context_id):
""" context_id: it might be sentence index or a combination of them in case of a complex cases.
"""
super(ContextOpinion, self).__init__(doc_id=doc_id,
text_opinion_id=text_opinion_id,
source_id=source_id,
target_id=target_id,
label=label)

self.__doc_id = doc_id
self.__source_id = source_id
self.__target_id = target_id
self.__label = label
self.__context_id = context_id

@property
def ContextID(self):
def DocId(self):
return self.__doc_id

@property
def ContextId(self):
return self.__context_id

@property
def SourceId(self):
return self.__source_id

@property
def TargetId(self):
return self.__target_id

@property
def Sentiment(self):
return self.__label

0 comments on commit 709138a

Please sign in to comment.