def wordnet_dump(): out_file = args.output mentions_file = args.mentions logger.info('Loading mentions files...') mentions = MentionData.read_mentions_json_to_mentions_data_list(mentions_file) logger.info('Done loading mentions files, starting local dump creation...') result_dump = dict() wordnet = WordnetOnline() for mention in mentions: page = wordnet.get_pages(mention) result_dump[page.orig_phrase] = page with open(out_file, 'w') as out: json.dump(result_dump, out, default=json_dumper) logger.info('Wordnet Dump Created Successfully, ' 'extracted total of %d wn pages', len(result_dump)) logger.info('Saving dump to file-%s', out_file)
def __init__(self, method: OnlineOROfflineMethod, wn_file: str = None): """ Extract Relation between two mentions according to Word Embedding cosine distance Args: method (required): OnlineOROfflineMethod.{ONLINE/OFFLINE} run against full wordnet or a sub-set of it wn_file (required on OFFLINE mode): str Location of wordnet subset file to work with """ logger.info('Loading Wordnet module') self.connectivity = method if self.connectivity == OnlineOROfflineMethod.ONLINE: self.wordnet_impl = WordnetOnline() elif self.connectivity == OnlineOROfflineMethod.OFFLINE: self.wordnet_impl = WordnetOffline(wn_file) logger.info('Wordnet module lead successfully') super(WordnetRelationExtraction, self).__init__()
def __init__(self, method: OnlineOROfflineMethod, wn_file: str = None): """ Extract Relation between two mentions according to Word Embedding cosine distance Args: method (required): OnlineOROfflineMethod.{ONLINE/OFFLINE} run against full wordnet or a sub-set of it wn_file (required on OFFLINE mode): str Location of wordnet subset file to work with """ logger.info('Loading Wordnet module') self.connectivity = method if self.connectivity == OnlineOROfflineMethod.ONLINE: self.wordnet_impl = WordnetOnline() elif self.connectivity == OnlineOROfflineMethod.OFFLINE: if wn_file is not None and os.path.isdir(wn_file): self.wordnet_impl = WordnetOffline(wn_file) else: raise FileNotFoundError( 'WordNet resource directory not found or not in path') logger.info('Wordnet module lead successfully') super(WordnetRelationExtraction, self).__init__()