Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Goldberg - Record
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Forschungsdaten
Zeitschrift für Digitale Geisteswissenschaften
Goldberg - Record
Commits
2dbb899a
Commit
2dbb899a
authored
2 years ago
by
Marcus Baumgarten
Browse files
Options
Downloads
Patches
Plain Diff
Neue Datei hochladen
parent
715e1270
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
occuresolver.py
+59
-0
59 additions, 0 deletions
occuresolver.py
with
59 additions
and
0 deletions
occuresolver.py
0 → 100644
+
59
−
0
View file @
2dbb899a
# This module contains functions for resolve abbreviations according to the rules presented in:
# http://wiki-de.genealogy.net/Kartei_Leipziger_Familien
import
collections
import
re
from
functools
import
lru_cache
@lru_cache
(
maxsize
=
None
)
def
resolveroccu
(
occu
):
"""
This function is used for the actual resolving of the abbreviation. It checks if the given occupational designation
matches any of the abbreviation rules and resolves them accordingly.
:param name: the input name
:return: the resolved abbreviation
"""
# abbreviation dictionary
abbreviationdict
=
collections
.
OrderedDict
({
"
- u.
"
:
"
$
"
,
# extension of the specifications of the KLF; Problem: problem: e.g. red and tan tanners, "$" to recognise that it is not a separate profession
"
B.
"
:
"
&Bürger
"
,
# "&" to be able to distinguish legal status from profession
"
Bg.
"
:
"
Bürger
"
,
# extension of the specifications of the KLF
"
Bgmstr.
"
:
"
Bürgermeister
"
,
# extension of the specifications of the KLF
"
Br.
"
:
"
Brauer
"
,
"
Brbr.
"
:
"
Branntweinbrenner
"
,
"
E.
"
:
"
Einwohner
"
,
# "&" to be able to distinguish legal status from profession
"
Fl.
"
:
"
Fleischer
"
,
"
Gl.
"
:
"
Glaser
"
,
"
GuS.
"
:
"
Gold- und Silberdrahtzieher
"
,
"
h.
"
:
"
händler
"
,
# ending of word
"
Kr.
"
:
"
Kramer
"
,
"
L.
"
:
"
Leinenweber
"
,
"
m.
"
:
"
macher
"
,
# ending of word
"
Z.
"
:
"
Zimmermann
"
,
"
Zg.
"
:
"
Zimmergeselle
"
,
"
u.
"
:
""
,
# "u." stands for "und" (and) and have to deleted, extension of the specifications of the KLF
"
-
"
:
"
"
,
# extension of the specifications of the KLF; occupations are partly separated with a hyphen and not with a "u."
"
,
"
:
""
,
# extension of the specifications of the KLF; if there are more than two professions, there is a comma as a separator
"
zu
"
:
"
@
"
# extension of the specifications of the KLF; place indication is not a profession, "@" to recognise place indication
})
# patterns
# not all the rules are implemented yet, mainly the ones found in the sample
bracketpattern
=
re
.
compile
(
r
"
[(].*[)]
"
)
occupattern
=
re
.
compile
(
r
"
[A-Za-z]+[.]
"
)
# pattern.search was used to check if a pattern matches since pattern.match only checks if the string is beginning
# with the pattern
if
occupattern
.
search
(
occu
):
for
abbreviation
,
resolve
in
abbreviationdict
.
items
():
occu
=
occu
.
replace
(
abbreviation
,
resolve
)
# get rid of brackets
if
bracketpattern
.
search
(
occu
):
occu
=
occu
.
replace
(
"
(
"
,
""
)
occu
=
occu
.
replace
(
"
)
"
,
""
)
return
occu
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