Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Patientenbriefe
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
Service Desk
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
Nina Brolich
Patientenbriefe
Commits
f0e4d76e
Commit
f0e4d76e
authored
2 years ago
by
Nina Brolich
Browse files
Options
Downloads
Patches
Plain Diff
added commentary
parent
88cfb557
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
plain_text.py
+8
-3
8 additions, 3 deletions
plain_text.py
with
8 additions
and
3 deletions
plain_text.py
+
8
−
3
View file @
f0e4d76e
...
...
@@ -4,7 +4,7 @@ import re
import
os
from
tqdm
import
tqdm
#helper-methode zum oeffnen der xml-files
def
openXML
(
filepath
):
with
open
(
filepath
,
mode
=
'
r
'
,
encoding
=
'
utf-8
'
)
as
file
:
content
=
file
.
read
()
...
...
@@ -12,7 +12,7 @@ def openXML(filepath):
doc
=
BeautifulSoup
(
content
,
'
xml
'
)
return
doc
#helper-methode zum schreiben der outputfiles in xml-format
def
writeXML
(
outputpath
,
outputdir
,
doc
):
if
not
os
.
path
.
isdir
(
outputdir
):
os
.
makedirs
(
outputdir
)
...
...
@@ -20,6 +20,7 @@ def writeXML(outputpath, outputdir, doc):
file
.
write
(
str
(
doc
))
file
.
close
()
#helper-methode zum schreiben der outputfiles in txt-format
def
writeTXT
(
outputpath
,
outputdir
,
doc
):
if
not
os
.
path
.
isdir
(
outputdir
):
os
.
makedirs
(
outputdir
)
...
...
@@ -28,6 +29,7 @@ def writeTXT(outputpath, outputdir, doc):
file
.
write
(
str
(
doc
))
file
.
close
()
#umwandlung in plain text
def
toPlainText
(
doc
):
# hand arzt
for
hand
in
doc
.
findAll
(
"
add
"
,
hand
=
"
arzt
"
):
...
...
@@ -72,12 +74,14 @@ def toPlainText(doc):
return
doctext
.
strip
()
#helper-methode um eckige klammern hinzuzufuegen
def
addbrackets
(
tag
,
symbol
):
rep
=
"
[
"
+
symbol
+
"
]
"
tag
.
insert
(
0
,
rep
)
tag
.
append
(
rep
)
#beginn main
#aktueller timestamp fuer ordnerbennenung
dt
=
datetime
.
now
().
strftime
(
"
%Y-%m-%d-%H-%M-%S
"
)
cwd
=
os
.
getcwd
()
...
...
@@ -85,6 +89,7 @@ dir = os.path.join(cwd, "teis")
outputdir
=
os
.
path
.
join
(
cwd
,
"
teis_converted
"
+
"
_
"
+
dt
)
directorylist
=
os
.
listdir
(
dir
)
#alle input directories durchgehen, fuer alle files umwandeln und in output-directory schreiben
for
directory
in
tqdm
(
directorylist
):
directorypath
=
os
.
path
.
join
(
dir
,
directory
)
filelist
=
os
.
listdir
(
directorypath
)
...
...
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