Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
democrasci_preprocWP1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Marta Balode
democrasci_preprocWP1
Commits
f122b105
Commit
f122b105
authored
6 years ago
by
Lili Gasser
Browse files
Options
Downloads
Patches
Plain Diff
some comments to extractsMPs
parent
2be4f2d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/extractMPs.py
+8
-7
8 additions, 7 deletions
src/python/extractMPs.py
with
8 additions
and
7 deletions
src/python/extractMPs.py
+
8
−
7
View file @
f122b105
...
...
@@ -44,31 +44,31 @@ class MPs_Extractor(object):
str_comp
=
'
comp
'
str_canton2
=
'
canton
'
# function to split lastname and save meaningful part(s) to list
# function to split lastname and save meaningful part(s) to list
def
split_lastname
(
lastname
,
uniqueID
,
tpl_canton
,
str_canton
=
''
):
# if last name is a composite name, e.g. 'von Arx' and 'de Stoppani'
# if last name is a composite name, e.g. 'von Arx' and 'de Stoppani'
lastname_split
=
lastname
.
split
()
if
len
(
lastname_split
)
>
1
:
for
item
in
lastname_split
:
if
item
not
in
[
'
von
'
,
'
de
'
,
'
Ab
'
,
'
van
'
]:
# write distinctive item to extended list
# write distinctive item to extended list
if
str_canton
:
list_names
.
append
((
str_canton2
,
item
,
str_canton
,
uniqueID
)
+
tpl_canton
)
else
:
list_names
.
append
((
str_comp
,
item
,
lastname
,
uniqueID
)
+
tpl_canton
)
else
:
# if last name is a double name, e.g. 'Meier-Müller'
# if last name is a double name, e.g. 'Meier-Müller'
lastname_split2
=
lastname
.
replace
(
'
-
'
,
'
'
).
split
()
if
len
(
lastname_split2
)
>
1
:
# write each part of double name into corresponding list
# write each part of double name into corresponding list
for
item
in
lastname_split2
:
if
str_canton
:
list_names
.
append
((
str_canton2
,
item
,
str_canton
,
uniqueID
)
+
tpl_canton
)
else
:
list_names
.
append
((
str_double
,
item
,
lastname
,
uniqueID
)
+
tpl_canton
)
# write double name into list
# write double name into list
list_names
.
append
((
str_double
,
lastname
,
lastname
,
uniqueID
)
+
tpl_canton
)
# write double name without space into list
# write double name without space into list
list_names
.
append
((
str_double
,
''
.
join
(
lastname
.
split
(
'
-
'
)),
lastname
,
uniqueID
)
+
tpl_canton
)
else
:
if
str_canton
:
...
...
@@ -98,6 +98,7 @@ class MPs_Extractor(object):
#print(df_temp)
# if there is an extra double name
# TODO: maybe easier by just adding second part as additional term, could then also be used to account for Wohnort
if
df_temp
.
iloc
[
0
][
'
DoubleName
'
]
!=
''
:
# extract unique index
uniqueID
=
df_temp
.
iloc
[
0
][
'
uniqueIndex
'
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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