Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Analysing and Mitigating Origin Bias in German Word Embeddings
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aileen Reichelt
Analysing and Mitigating Origin Bias in German Word Embeddings
Commits
25623fb7
Commit
25623fb7
authored
1 year ago
by
Aileen Reichelt
Browse files
Options
Downloads
Patches
Plain Diff
Attempt to read Wiki in chunks
parent
98ce9184
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
count_name_occurrences.py
+16
-7
16 additions, 7 deletions
count_name_occurrences.py
with
16 additions
and
7 deletions
count_name_occurrences.py
+
16
−
7
View file @
25623fb7
...
...
@@ -4,16 +4,25 @@ occurr in the Wikipedia snapshot used for GloVe training."""
import
pandas
as
pd
df
=
pd
.
read_csv
(
"
../data/names_nationality.csv
"
,
usecols
=
[
"
name
"
,
"
nationality
"
,
"
gender
"
])
df
[
"
occurrences_in_wikipedia
"
]
=
0
with
open
(
"
../data/wikipedia/wikipedia_corpus.txt
"
,
encoding
=
"
utf-8
"
)
as
f
:
wikipedia_text
=
f
.
read
()
CHUNK_SIZE
=
1024
*
1024
# 1 MB
df
[
"
occurrences_in_wikipedia
"
]
=
0
with
open
(
"
../data/wikipedia/wikipedia_corpus.txt
"
,
"
rb
"
,
encoding
=
"
utf-8
"
)
as
f
:
CHUNK_NO
=
1
while
True
:
print
(
f
"
reading Wikipedia data: approx.
{
CHUNK_NO
}
MB/8100 MB
"
,
end
=
"
\r
"
)
wikipedia_text
=
f
.
read
(
CHUNK_SIZE
)
if
not
wikipedia_text
:
print
(
"
reading completed
"
)
break
for
index
,
row
in
df
.
iterrows
():
name
=
row
[
'
name
'
]
count
=
wikipedia_text
.
count
(
name
)
df
.
at
[
index
,
"
occurrences_in_wikipedia
"
]
=
count
for
index
,
row
in
df
.
iterrows
():
name
=
row
[
'
name
'
]
count
=
wikipedia_text
.
count
(
name
)
df
.
at
[
index
,
"
occurrences_in_wikipedia
"
]
+=
count
CHUNK_NO
+=
1
df
.
to_csv
(
"
./data/names_nationality_wikipedia.csv
"
,
index
=
False
)
...
...
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