Skip to content

Commit

Permalink
#161 Refactoring API for opinion collection creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Dec 26, 2021
1 parent 41ba3d4 commit 075412d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion arekit/common/experiment/api/ops_opin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_result_opinion_collection(self, doc_id, data_type, epoch_index):

# region creation

def create_opinion_collection(self):
def create_opinion_collection(self, opinions):
raise NotImplementedError("Collection creation does not supported by experiment.")

# endregion
4 changes: 2 additions & 2 deletions arekit/contrib/experiment_rusentrel/exp_joined/opinions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_result_opinion_collection(self, doc_id, data_type, epoch_index):
data_type=data_type,
epoch_index=epoch_index)

def create_opinion_collection(self):
return self.__rusentrel_op.create_opinion_collection()
def create_opinion_collection(self, opinions):
return self.__rusentrel_op.create_opinion_collection(opinions)

# endregion
4 changes: 2 additions & 2 deletions arekit/contrib/experiment_rusentrel/exp_sl/opinions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def get_etalon_opinion_collection(self, doc_id):
version=self.__version)
return self.__create_collection(opins_iter)

def create_opinion_collection(self):
return self.__create_collection(None)
def create_opinion_collection(self, opinions):
return self.__create_collection(opinions)

def get_result_opinion_collection(self, doc_id, data_type, epoch_index):
""" Since evaluation supported only for neural networks,
Expand Down
14 changes: 5 additions & 9 deletions examples/network/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def iter_opinions_for_extraction(self, doc_id, data_type):
create_collection_func=self.create_opinion_collection)

def get_etalon_opinion_collection(self, doc_id):
return self.create_opinion_collection()
return self.create_opinion_collection(None)

def get_result_opinion_collection(self, doc_id, data_type, epoch_index):
raise Exception("Not Supported")

def create_opinion_collection(self):
return OpinionCollection(opinions=None,
def create_opinion_collection(self, opinions=None):
return OpinionCollection(opinions=[] if opinions is None else opinions,
synonyms=self.__synonyms,
error_on_duplicates=True,
error_on_synonym_end_missed=True)
Expand All @@ -92,14 +92,10 @@ def get_experiment_sources_dir(self):
return "data"

def create_opinion_collection_target(self, doc_id, data_type, check_existance=False):
self.__create_target(doc_id=doc_id,
data_type=data_type,
epoch_index=0)
return self.__create_target(doc_id=doc_id, data_type=data_type, epoch_index=0)

def create_result_opinion_collection_target(self, doc_id, data_type, epoch_index):
self.__create_target(doc_id=doc_id,
data_type=data_type,
epoch_index=epoch_index)
return self.__create_target(doc_id=doc_id, data_type=data_type, epoch_index=epoch_index)


class CustomExperiment(BaseExperiment):
Expand Down

0 comments on commit 075412d

Please sign in to comment.