Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
C
ConceptExtractor
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier Rodriguez Vidal
ConceptExtractor
Commits
e1fed7d5
Commit
e1fed7d5
authored
Feb 19, 2021
by
Javier Rodriguez Vidal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Script de inserción
parent
74dfedec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
UMLS_Extractor/insertUMLSConcepts.py
UMLS_Extractor/insertUMLSConcepts.py
+56
-0
No files found.
UMLS_Extractor/insertUMLSConcepts.py
0 → 100644
View file @
e1fed7d5
import
configparser
import
mysql.connector
#Diccionario con los datos de conexion a la BBDD (se lee desde archivo de configuracion: DEFAULT --> LOCAL, TESTING --> ARES)
configuration
=
configparser
.
ConfigParser
()
configuration
.
read
(
'config.ini'
)
config2
=
{
'user'
:
configuration
[
'ARES'
][
'DB_USER'
],
'password'
:
configuration
[
'ARES'
][
'DB_PASSWORD'
],
'port'
:
configuration
[
'ARES'
][
'DB_PORT'
],
'host'
:
configuration
[
'ARES'
][
'DB_HOST'
],
'db'
:
configuration
[
'ARES'
][
'DB_NAME'
],
'auth_plugin'
:
configuration
[
'ARES'
][
'DB_AUTH_PLUGIN'
]
}
text
=
open
(
"./output2.txt"
)
.
read
()
lines
=
iter
(
text
.
split
(
"
\n
"
))
#Conectamos con nuestra BD
cnx
=
mysql
.
connector
.
connect
(
**
config2
)
#Creamos el cursor
cursor
=
cnx
.
cursor
()
try
:
for
line
in
lines
:
item
=
line
.
split
(
"
\t
"
)
query
=
""
#print(item)
if
(
"JKES"
in
item
):
#JKES
query
=
"insert ignore into concept_extraction.note_umls (note_id,umls_id,begin,end,concept_text,origin) values ('"
+
item
[
3
]
+
"','"
+
item
[
1
]
+
"','"
+
item
[
4
]
+
"','"
+
item
[
5
]
+
"','"
+
item
[
0
]
+
"','JKES');"
query2
=
"insert ignore into concept_extraction.umls (umls_id,concept) values ('"
+
item
[
1
]
+
"','"
+
item
[
0
]
+
"');"
elif
(
"UMLS"
in
item
):
#UMLS
jkes_concept
=
item
[
0
]
for
j
in
range
(
6
,
len
(
item
)):
aux
=
item
[
j
]
.
split
(
","
)
noteID
=
aux
[
0
]
.
replace
(
"("
,
""
)
.
replace
(
"'"
,
""
)
begin
=
aux
[
1
]
.
replace
(
"'"
,
""
)
.
strip
()
end
=
aux
[
2
]
.
replace
(
")"
,
""
)
.
replace
(
"'"
,
""
)
.
strip
()
print
(
item
[
4
])
query
=
"insert ignore into concept_extraction.note_umls (note_id,umls_id,levenshtein_distance,begin,end,concept_text,origin) values ('"
+
noteID
+
"','"
+
item
[
3
]
+
"','"
+
item
[
4
]
+
"','"
+
begin
+
"','"
+
end
+
"','"
+
item
[
0
]
+
"','UMLS');"
query2
=
"insert ignore into concept_extraction.umls (umls_id,concept) values ('"
+
item
[
3
]
+
"','"
+
item
[
2
]
+
"');"
print
(
query2
)
print
(
query
)
cursor
.
execute
(
query2
)
cnx
.
commit
()
cursor
.
execute
(
query
)
cnx
.
commit
()
cursor
.
close
()
cnx
.
close
()
except
mysql
.
connector
.
IntegrityError
as
err
:
print
(
"Error: {}"
.
format
(
err
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment