Skip to content

Commit

Permalink
#398 related solution in 0.22.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Sep 6, 2022
1 parent 59e8ae8 commit fadd6d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 0 additions & 4 deletions arekit/contrib/source/sentinerel/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def __keep_entity(self, entity):

@classmethod
def read_collection(cls, filename, version, entities_to_ignore=None):
""" You may adopt the following list of entities to ignore by default.
entities_to_ignore = ["EFFECT_NEG", "EFFECT_POS", "ARGUMENT_NEG", "ARGUMENT_POS", "EVENT"]
We setup the latter as a part of the side-project and the related experiments.
"""
assert(isinstance(filename, str))

# Since this dataset does not provide the synonyms collection by default,
Expand Down
11 changes: 9 additions & 2 deletions arekit/contrib/source/sentinerel/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@ def read_text_relations(filename, version):
version=version)

@staticmethod
def read_document(filename, doc_id):
def read_document(filename, doc_id, entities_to_ignore=None):
assert(isinstance(filename, str))
assert(isinstance(doc_id, int))

def file_to_doc(input_file):
sentences = BratDocumentSentencesReader.from_file(input_file=input_file, entities=entities)
return BratNews(doc_id=doc_id, sentences=sentences, text_relations=text_relations)

entities = SentiNerelEntityCollection.read_collection(filename=filename, version=SentiNerelVersions.V1)
# TODO. #398 issue -- in some cases entities might be nested. Therefore we limit the set
# TODO. of the potential named entities.
eti = ["EFFECT_NEG", "EFFECT_POS", "ARGUMENT_NEG", "ARGUMENT_POS", "EVENT"] \
if entities_to_ignore is None else entities_to_ignore

entities = SentiNerelEntityCollection.read_collection(
filename=filename, version=SentiNerelVersions.V1,
entities_to_ignore=eti)
text_relations = SentiNerelDocReader.read_text_relations(filename=filename, version=SentiNerelVersions.V1)

return SentiNerelIOUtils.read_from_zip(
Expand Down

0 comments on commit fadd6d8

Please sign in to comment.