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
4944a70d
Commit
4944a70d
authored
1 year ago
by
Aileen Reichelt
Browse files
Options
Downloads
Patches
Plain Diff
Add script to count name occurrences in Wiki dump
parent
cbe49f51
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
+20
-0
20 additions, 0 deletions
count_name_occurrences.py
with
20 additions
and
0 deletions
count_name_occurrences.py
0 → 100644
+
20
−
0
View file @
4944a70d
"""
Check how often the most common names of each nationality
occurr in the Wikipedia snapshot used for GloVe training.
"""
import
pandas
as
pd
df
=
pd
.
read_csv
(
"
../data/names_nationality.csv
"
,
usecols
=
[
"
name
"
,
"
nationality
"
])
with
open
(
"
../data/wikipedia/wikipedia_corpus.txt
"
,
encoding
=
"
utf-8
"
)
as
f
:
wikipedia_text
=
f
.
read
()
df
[
"
occurrences_in_wikipedia
"
]
=
0
for
index
,
row
in
df
.
iterrows
():
name
=
row
[
'
name
'
]
count
=
wikipedia_text
.
count
(
name
)
df
.
at
[
index
,
"
occurrences_in_wikipedia
"
]
=
count
avg_occurrences
=
df
.
groupby
(
"
nationality
"
)[
"
occurrences_in_wikipedia
"
].
mean
()
for
nationality
,
avg_count
in
avg_occurrences
.
items
():
print
(
f
"
Nationality:
{
nationality
}
, Average Occurrences in Wikipedia:
{
avg_count
:
.
2
f
}
"
)
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