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
61b10d74
Commit
61b10d74
authored
Feb 19, 2021
by
Javier Rodriguez Vidal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Script que permite componer los conceptos de las anotaciones BERT (B, B+I)
parent
bf0528ec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
UMLS_Extractor/ConceptExtractor.py
UMLS_Extractor/ConceptExtractor.py
+59
-0
No files found.
UMLS_Extractor/ConceptExtractor.py
0 → 100644
View file @
61b10d74
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 27 10:26:48 2021
Library
"""
# Extract the B or B+Is concepts and their entities, starts and ends.
# Input: list of list of dictionaries where each dictionary:
# {'word' : '', 'score' : '', entity : '', index : '', start : '', end : ''}
# Output: List of tuples with four elements. [(concept, entity, start, end)]
def
extractionOfConcepts
(
annotations
):
#VARIABLES
entities
=
[]
complete_word
=
''
start
=
0
end
=
0
entity
=
''
i
=
0
for
document
in
annotations
:
i
=
i
+
1
for
word
in
document
:
#B
if
word
.
get
(
'entity'
)[
0
]
==
'B'
:
#If there was a previous concept started, finish it
if
len
(
complete_word
)
>
0
:
entities
.
append
((
complete_word
,
entity
,
start
,
end
))
complete_word
=
''
start
=
0
end
=
0
entity
=
''
#Strat a new concept
complete_word
=
word
.
get
(
'word'
)
start
=
word
.
get
(
'start'
)
end
=
word
.
get
(
'end'
)
entity
=
word
.
get
(
'entity'
)[
2
:]
#I
elif
word
.
get
(
'entity'
)[
0
]
==
'I'
:
#if there isnt a B before, ignore
if
len
(
complete_word
)
>
0
:
complete_word
=
complete_word
+
' '
+
word
.
get
(
'word'
)
#Update end
end
=
word
.
get
(
'end'
)
#O
elif
word
.
get
(
'entity'
)[
0
]
==
'O'
:
#If there was a previous concept started, finish it
if
len
(
complete_word
)
>
0
:
entities
.
append
((
complete_word
,
entity
,
start
,
end
))
complete_word
=
''
start
=
0
end
=
0
entity
=
''
return
entities
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