Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
text_translation_and_summarization
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
nwarslan
text_translation_and_summarization
Commits
235a47fb
Commit
235a47fb
authored
5 years ago
by
nwarslan
Browse files
Options
Downloads
Patches
Plain Diff
code comentation
parent
2d7f26d5
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
code/mk_keyword_dict.py
+31
-1
31 additions, 1 deletion
code/mk_keyword_dict.py
with
31 additions
and
1 deletion
code/mk_keyword_dict.py
+
31
−
1
View file @
235a47fb
...
...
@@ -3,7 +3,7 @@
"""
Created on Fri Aug 9 16:54:02 2019
@author:
n
adia
@author:
N
adia
Arslan
This module joins the german keywords of spektrum articles with their
corresponding englisch google translation to a dictionary
...
...
@@ -15,6 +15,22 @@ INPUT_PATH = '../data/spektrum_keywords'
OUTPUT
=
'
../data/spektrum_keywords/spektrum_keyword_dict.json
'
def
open_translation
(
filename
):
"""
opens a keyword file containing lines of german keywords and lines of english translations seperated by
'
\n\n\n
'
file needs to have as many german keywords as english translations
Parameters
----------
filename : str
name of file.
Returns
-------
d : dict
keyword_dict
Example: {german keyword : english translation, ...}.
"""
with
open
(
filename
,
'
r
'
)
as
f
:
data
=
f
.
read
().
strip
()
d
=
data
.
split
(
'
\n\n\n
'
)
...
...
@@ -32,6 +48,20 @@ def open_translation(filename):
return
d
def
mk_dict
(
dir_path
):
"""
iterates over files in path and makes a keyword dictionary
Parameters
----------
dir_path : str
path to keyword files.
Returns
-------
dictionary : dict
a keyword dictionary of all keywords.
"""
files
=
os
.
listdir
(
dir_path
)
dictionary
=
{}
for
file
in
files
:
...
...
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