def main(argv=sys.argv): ''' NeuroNER main method Args: parameters_filepath the path to the parameters file output_folder the path to the output folder ''' arguments = parse_arguments(argv[1:]) # fetch data and models from the package if arguments['fetch_data'] or arguments['fetch_trained_model']: if arguments['fetch_data']: neuromodel.fetch_data(arguments['fetch_data']) if arguments['fetch_trained_model']: neuromodel.fetch_model(arguments['fetch_trained_model']) msg = """When the fetch_data and fetch_trained_model arguments are specified, other arguments are ignored. Remove these arguments to train or apply a model.""" print(msg) sys.exit(0) # create the model nn = neuromodel.NeuroNER(**arguments) nn.fit() nn.close()
def entity_detect(sentence): # print("Building model") with HiddenPrints(): neuromodel.fetch_data(dataset) neuromodel.fetch_model(model) nn = neuromodel.NeuroNER(train_model=False, use_pretrained_model=True) # print("predicting") entities = nn.predict(sentence) return entities
dataset = 'conll2003' # 'conll2003' # 'example_unannotated_texts' # 'i2b2_2014_deid' model = 'conll_2003_en' # 'conll_2003_en' # 'i2b2_2014_glove_spacy_bioes' # 'i2b2_2014_glove_stanford_bioes' # 'mimic_glove_spacy_bioes' # 'mimic_glove_stanford_bioes' print("Building model") with HiddenPrints(): neuromodel.fetch_data(dataset) neuromodel.fetch_model(model) nn = neuromodel.NeuroNER(train_model=False, use_pretrained_model=True) def entity_detect(sentence): print("predicting") with HiddenPrints(): entity = nn.predict(sentence) entities = [] for i in range(len(entity)): entities.append(entity[i]['text']) return entities if __name__ == '__main__': with open("parsed_json_93.json", 'r') as load_f: