Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wikstraktor
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Lex gaMe
wikstraktor
Commits
1f3789ad
Commit
1f3789ad
authored
2 years ago
by
Enzo Simonnet
Browse files
Options
Downloads
Patches
Plain Diff
Replace en_constants.py
parent
86daa52a
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
parsers/en_constants.py
+34
-80
34 additions, 80 deletions
parsers/en_constants.py
with
34 additions
and
80 deletions
parsers/en_constants.py
+
34
−
80
View file @
1f3789ad
#!/usr/bin/env python3
string_values
=
{
from
wikstraktor
import
Wikstraktor
,
Pronunciation
,
Sense
"
ety
"
:
"
Etymology
"
,
"
pro
"
:
"
Pronunciation
"
,
from
parsers.en_constants
import
string_values
"
en
"
:
"
English
"
,
"
fr
"
:
"
French
"
,
debugEty
=
0
"
t_ipa
"
:
"
IPA
"
,
#template for transcription
"
t_snd
"
:
"
audio
"
,
#template for audio
class
En_en_straktor
(
Wikstraktor
):
"
t_acc
"
:
"
a
"
,
#template for accents
def
__init__
(
self
):
"
t_deflabel
"
:
"
lb
"
,
super
().
__init__
()
"
t_ex
"
:
"
ux
"
,
self
.
wiki_language
=
"
en
"
"
POS
"
:
{
#https://en.wiktionary.org/wiki/Wiktionary:POS
self
.
entry_language
=
"
en
"
"
Adjective
"
:
"
Adj
"
,
self
.
constants
=
string_values
"
Adverb
"
:
"
Adv
"
,
self
.
site
=
self
.
pwb
.
Site
(
f
'
wiktionary:en
'
)
"
Ambiposition
"
:
"
Ambip
"
,
"
Article
"
:
"
Art
"
,
def
process_pronunciation
(
self
,
proContent
):
"
Circumposition
"
:
"
Circump
"
,
# TODO: ne marche que pour les listes à 2 niveaux, voir water pour 3 niveaux
"
Classifier
"
:
"
Class
"
,
l
=
proContent
.
get_lists
()[
0
]
"
Conjunction
"
:
"
Conj
"
,
i
=
0
"
Contraction
"
:
"
Cont
"
,
pronunciations
=
[]
"
Counter
"
:
"
Count
"
,
while
i
<
len
(
l
.
fullitems
):
"
Determiner
"
:
"
Det
"
,
p
=
Pronunciation
()
"
Ideophone
"
:
"
Ideophone
"
,
templates
=
self
.
wtp
.
parse
(
l
.
fullitems
[
i
]).
templates
"
Interjection
"
:
"
Interj
"
,
a
=
None
"
Noun
"
:
"
N
"
,
for
j
,
t
in
enumerate
(
templates
):
"
Numeral
"
:
"
Num
"
,
if
(
t
.
normal_name
()
==
self
.
constants
[
'
t_acc
'
]
and
templates
[
j
+
1
].
normal_name
()
!=
self
.
constants
[
'
t_acc
'
]):
"
Participle
"
:
"
Part
"
,
a
=
t
.
arguments
[
0
].
value
"
Particle
"
:
"
Particle
"
,
elif
t
.
normal_name
()
==
self
.
constants
[
'
t_ipa
'
]:
"
Postposition
"
:
"
Postp
"
,
p
.
set_transcription
(
t
.
arguments
[
1
].
value
)
"
Preposition
"
:
"
Prep
"
,
p
.
set_accent
(
a
)
"
Pronoun
"
:
"
Pro
"
,
elif
t
.
normal_name
()
==
self
.
constants
[
'
t_snd
'
]:
"
Proper noun
"
:
"
NP
"
,
p
.
add_sound
(
self
.
get_file_url
(
t
.
arguments
[
1
].
value
),
a
)
"
Verb
"
:
"
V
"
# TODO: compléter
if
j
==
len
(
templates
)
-
1
or
templates
[
j
+
1
].
normal_name
()
==
self
.
constants
[
'
t_acc
'
]
:
}
if
p
.
ipa
!=
None
or
p
.
accent
!=
None
:
}
pronunciations
.
append
(
p
)
p
=
Pronunciation
()
i
+=
1
return
pronunciations
def
process_etymology
(
self
,
etyContent
):
global
debugEty
debugEty
+=
1
return
"
Etymology
"
+
str
(
debugEty
)
def
process_senses
(
self
,
entry
,
pos
,
sensesContent
):
baseId
=
f
"
{
entry
}
_
{
pos
}
_
"
#here we don't look at
l
=
sensesContent
.
get_lists
()[
0
]
i
=
0
senses
=
[]
while
i
<
len
(
l
.
fullitems
):
newSense
=
Sense
(
f
"
{
baseId
}{
i
}
"
)
li
=
self
.
wtp
.
parse
(
l
.
fullitems
[
i
])
j
=
0
while
j
<
len
(
li
.
templates
)
and
li
.
templates
[
j
].
normal_name
()
!=
self
.
constants
[
'
t_deflabel
'
]:
j
+=
1
if
j
<
len
(
li
.
templates
):
newSense
.
set_domain
(
li
.
templates
[
j
].
arguments
[
-
1
].
value
)
#We could use the second parameter for a comment
newSense
.
add_def
(
self
.
wiki_language
,
self
.
wtp
.
parse
(
li
.
get_lists
()[
0
].
items
[
0
]).
plain_text
().
strip
())
while
j
<
len
(
li
.
templates
)
-
1
and
li
.
templates
[
j
+
1
].
normal_name
()
==
self
.
constants
[
'
t_ex
'
]:
newSense
.
add_example
(
li
.
templates
[
j
+
1
].
arguments
[
1
].
value
)
j
+=
1
senses
.
append
(
newSense
)
if
len
(
li
.
get_lists
(
pattern
=
'
##
'
))
>
0
:
for
cnt
,
k
in
enumerate
(
li
.
get_lists
(
pattern
=
'
##
'
)[
0
].
items
):
if
self
.
wtp
.
parse
(
k
).
templates
[
0
].
normal_name
()
==
self
.
constants
[
'
t_deflabel
'
]:
newSense2
=
Sense
(
f
"
{
baseId
}{
i
}{
cnt
}
"
)
newSense2
.
set_domain
(
self
.
wtp
.
parse
(
k
).
templates
[
0
].
arguments
[
-
1
].
value
)
#We could use the second parameter for a comment
newSense2
.
add_def
(
self
.
wiki_language
,
self
.
wtp
.
parse
(
k
).
plain_text
().
strip
())
for
a
in
self
.
wtp
.
parse
(
li
.
get_lists
(
pattern
=
'
##
'
)[
0
].
fullitems
[
cnt
]).
templates
:
if
a
.
normal_name
()
==
self
.
constants
[
'
t_ex
'
]:
newSense2
.
add_example
(
a
.
arguments
[
-
1
].
value
)
senses
.
append
(
newSense2
)
# TODO: process examples
i
+=
1
return
senses
if
__name__
==
"
__main__
"
:
ensk
=
En_en_straktor
()
print
(
ensk
.
fetch
(
"
test
"
),
"
entries added
"
)
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