Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
clef18
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jurica Seva
clef18
Commits
758bf220
Commit
758bf220
authored
6 years ago
by
Mario Sänger
Browse files
Options
Downloads
Patches
Plain Diff
Add reading of all french training files
parent
3ae09c9b
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code_mario/clef18_task1_data.py
+33
-11
33 additions, 11 deletions
code_mario/clef18_task1_data.py
with
33 additions
and
11 deletions
code_mario/clef18_task1_data.py
+
33
−
11
View file @
758bf220
import
os
import
os
from
typing
import
List
import
pandas
as
pd
import
pandas
as
pd
from
pandas
import
DataFrame
from
pandas
import
DataFrame
...
@@ -45,7 +47,7 @@ class Clef18Task1Data(LoggingMixin):
...
@@ -45,7 +47,7 @@ class Clef18Task1Data(LoggingMixin):
calculees_file
=
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_IT_1.csv
"
)
calculees_file
=
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_IT_1.csv
"
)
brutes_file
=
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_IT_1.csv
"
)
brutes_file
=
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_IT_1.csv
"
)
return
self
.
_read_certificates
(
calculees_file
,
brutes_file
)
return
self
.
_read_certificates
(
[
calculees_file
]
,
[
brutes_file
]
)
def
read_it_dictionary
(
self
)
->
DataFrame
:
def
read_it_dictionary
(
self
)
->
DataFrame
:
base_folder
=
"
data/train/IT/training/raw/dictionaries
"
base_folder
=
"
data/train/IT/training/raw/dictionaries
"
...
@@ -60,7 +62,7 @@ class Clef18Task1Data(LoggingMixin):
...
@@ -60,7 +62,7 @@ class Clef18Task1Data(LoggingMixin):
calculees_file
=
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_HU_1.csv
"
)
calculees_file
=
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_HU_1.csv
"
)
brutes_file
=
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_HU_1.csv
"
)
brutes_file
=
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_HU_1.csv
"
)
return
self
.
_read_certificates
(
calculees_file
,
brutes_file
)
return
self
.
_read_certificates
(
[
calculees_file
]
,
[
brutes_file
]
)
def
read_hu_dictionary
(
self
)
->
DataFrame
:
def
read_hu_dictionary
(
self
)
->
DataFrame
:
base_folder
=
"
data/train/HU/training/raw/dictionaries
"
base_folder
=
"
data/train/HU/training/raw/dictionaries
"
...
@@ -73,10 +75,19 @@ class Clef18Task1Data(LoggingMixin):
...
@@ -73,10 +75,19 @@ class Clef18Task1Data(LoggingMixin):
# FIXME: Load other training files from 2011-2015!
# FIXME: Load other training files from 2011-2015!
base_folder
=
"
data/train/FR/training/raw/corpus/
"
base_folder
=
"
data/train/FR/training/raw/corpus/
"
calculees_file
=
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_FR_2006-2012.csv
"
)
calculees_files
=
[
brutes_file
=
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_FR_2006-2012.csv
"
)
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_FR_2006-2012.csv
"
),
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_FR_2013.csv
"
),
os
.
path
.
join
(
base_folder
,
"
CausesCalculees_FR_2014.csv
"
)
]
brutes_files
=
[
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_FR_2006-2012.csv
"
),
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_FR_2013.csv
"
),
os
.
path
.
join
(
base_folder
,
"
CausesBrutes_FR_2014.csv
"
)
]
return
self
.
_read_certificates
(
calculees_file
,
brutes_file
)
return
self
.
_read_certificates
(
calculees_file
s
,
brutes_file
s
)
def
read_fr_dictionary
(
self
)
->
DataFrame
:
def
read_fr_dictionary
(
self
)
->
DataFrame
:
# FIXME: Load other training files from 2011-2015!
# FIXME: Load other training files from 2011-2015!
...
@@ -122,13 +133,24 @@ class Clef18Task1Data(LoggingMixin):
...
@@ -122,13 +133,24 @@ class Clef18Task1Data(LoggingMixin):
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
def
_read_certificates
(
self
,
calculees_file
:
str
,
brutus_file
:
str
)
->
DataFrame
:
def
_read_certificates
(
self
,
calculees_files
:
List
[
str
],
brutus_files
:
List
[
str
])
->
DataFrame
:
self
.
logger
.
info
(
"
Reading calculees file from %s
"
,
calculees_file
)
calculees_data
=
[]
calculees_data
=
pd
.
read_csv
(
calculees_file
,
sep
=
"
;
"
,
encoding
=
"
iso-8859-1
"
,
index_col
=
[
"
DocID
"
,
"
LineID
"
],
skipinitialspace
=
True
)
for
calculees_file
in
calculees_files
:
self
.
logger
.
info
(
"
Found %s death certificate lines
"
,
len
(
calculees_data
))
self
.
logger
.
info
(
"
Reading calculees file from %s
"
,
calculees_file
)
calculees_data
.
append
(
pd
.
read_csv
(
calculees_file
,
sep
=
"
;
"
,
encoding
=
"
iso-8859-1
"
,
index_col
=
[
"
YearCoded
"
,
"
DocID
"
,
"
LineID
"
],
skipinitialspace
=
True
))
self
.
logger
.
info
(
"
Found %s death certificate entries
"
,
len
(
calculees_data
[
-
1
]))
calculees_data
=
pd
.
concat
(
calculees_data
)
self
.
logger
.
info
(
"
Found %s death certificate lines in total
"
,
len
(
calculees_data
))
brutus_data
=
[]
for
brutus_file
in
brutus_files
:
self
.
logger
.
info
(
"
Reading brutus file from %s
"
,
brutus_file
)
brutus_data
.
append
(
pd
.
read_csv
(
brutus_file
,
sep
=
"
;
"
,
encoding
=
"
iso-8859-1
"
,
index_col
=
[
"
YearCoded
"
,
"
DocID
"
,
"
LineID
"
]))
self
.
logger
.
info
(
"
Found %s death certificate entries
"
,
len
(
brutus_data
[
-
1
]))
self
.
logger
.
info
(
"
Reading brutus file from %s
"
,
brutus_file
)
brutus_data
=
pd
.
concat
(
brutus_data
)
brutus_data
=
pd
.
read_csv
(
brutus_file
,
sep
=
"
;
"
,
encoding
=
"
iso-8859-1
"
,
index_col
=
[
"
DocID
"
,
"
LineID
"
])
joined_data
=
brutus_data
.
join
(
calculees_data
,
lsuffix
=
"
_b
"
,
rsuffix
=
"
_c
"
)
joined_data
=
brutus_data
.
join
(
calculees_data
,
lsuffix
=
"
_b
"
,
rsuffix
=
"
_c
"
)
joined_data
[
"
ICD10
"
]
=
joined_data
[
"
ICD10
"
].
astype
(
str
)
joined_data
[
"
ICD10
"
]
=
joined_data
[
"
ICD10
"
].
astype
(
str
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment