@@ -0,0 +1,2193 @@
+import webbrowser%0Aimport spacy%0Anlp = spacy.load('en_core_web_sm')%0Afrom py2neo import Node, Relationship, Graph%0A%0A%0A## Importing the data%0Awith open (%22umls/entities.txt%22, %22r%22) as myfile:%0A    entities = myfile.readlines()%0Afor i in range(len(entities)):%0A    entities%5Bi%5D = entities%5Bi%5D.split()%0A%0Awith open (%22umls/entity_category.txt%22, %22r%22) as myfile:%0A    entity_category = myfile.readlines()%0Afor i in range(len(entity_category)):%0A    entity_category%5Bi%5D = entity_category%5Bi%5D.split()%0A    %0Awith open (%22umls/relations.txt%22, %22r%22) as myfile:%0A    relations = myfile.readlines()%0Afor i in range(len(relations)):%0A    relations%5Bi%5D = relations%5Bi%5D.split()%0A%0A%0Awith open (%22umls/triples.txt%22, %22r%22) as myfile:%0A    triples = myfile.readlines()%0Afor i in range(len(triples)):%0A    triples%5Bi%5D = triples%5Bi%5D.split()%0A    %0A## getting entity_to_id and id_to_entity%0Aentity_to_id = %7B%7D%0Aid_to_entity = %7B%7D%0Afor i in entities:%0A    entity_to_id%5Bi%5B1%5D%5D = i%5B0%5D%0A    id_to_entity%5Bi%5B0%5D%5D = i%5B1%5D%0A%0A## getting category_to_id and id_to_category%0Acategory_to_id = %7B%7D%0Aid_to_category = %7B%7D%0Afor i in entity_category:%0A    category_to_id%5Bi%5B1%5D%5D = i%5B0%5D%0A    id_to_category%5Bi%5B0%5D%5D = i%5B1%5D%0A    %0A## getting relation_to_id and id_to_relation%0Arelation_to_id = %7B%7D%0Aid_to_relation = %7B%7D%0Afor i in relations:%0A    relation_to_id%5Bi%5B1%5D%5D = i%5B0%5D%0A    id_to_relation%5Bi%5B0%5D%5D = i%5B1%5D%0A%0A## Creating Nodes%0Anodes_e = %5B%5D%0Anodes_c = %5B%5D%0Afor i in range(len(entities)):%0A    nodes_e.append(Node('Entity',name = entities%5Bi%5D%5B1%5D,id_e = entity_to_id%5Bentities%5Bi%5D%5B1%5D%5D))%0Afor i in range(len(entity_category)):%0A    nodes_c.append(Node('Category',name = entity_category%5Bi%5D%5B1%5D,id_c = category_to_id%5Bentity_category%5Bi%5D%5B1%5D%5D))%0A%0Arelationships = %5B%5D%0Afor i in triples:%0A    relationship = Relationship(nodes_e%5Bint(i%5B1%5D)%5D,id_to_relation%5Bi%5B0%5D%5D.replace('-','_'),nodes_e%5Bint(i%5B2%5D)%5D)%0A    relationships.append(relationship)%0A%0A# CReating the graph%0Agraph =Graph(host='localhost',user='neo4j', password=None) # initial graph from the data%0A#graph = Graph('bolt://neo4j:test@127.0.0.1:7687/db/data')%0Atx = graph.begin()%0A%0Afor node in nodes_e:%0A    tx.create(node)%0Afor relationship in relationships:%0A    tx.create(relationship)%0A    %0Atx.commit()%0A%0A#url = 'http://localhost:7474'%0A#webbrowser.open(url, new=2) # new=2 opens a new tab%0A

Create medic_graph.py