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
a3c5d9a3
Commit
a3c5d9a3
authored
2 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
2 level pronunciation with accent
parent
5622cf94
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
parsers/en_constants.py
+2
-1
2 additions, 1 deletion
parsers/en_constants.py
parsers/en_en.py
+16
-5
16 additions, 5 deletions
parsers/en_en.py
pronunciation.py
+5
-1
5 additions, 1 deletion
pronunciation.py
with
23 additions
and
7 deletions
parsers/en_constants.py
+
2
−
1
View file @
a3c5d9a3
...
@@ -4,5 +4,6 @@ string_values = {
...
@@ -4,5 +4,6 @@ string_values = {
"
en
"
:
"
English
"
,
"
en
"
:
"
English
"
,
"
fr
"
:
"
French
"
,
"
fr
"
:
"
French
"
,
"
t_ipa
"
:
"
IPA
"
,
#template for transcription
"
t_ipa
"
:
"
IPA
"
,
#template for transcription
"
t_snd
"
:
"
audio
"
#template for audio
"
t_snd
"
:
"
audio
"
,
#template for audio
"
t_acc
"
:
"
a
"
#template for accents
}
}
This diff is collapsed.
Click to expand it.
parsers/en_en.py
+
16
−
5
View file @
a3c5d9a3
...
@@ -3,12 +3,17 @@ from wikstraktor import Wikstraktor
...
@@ -3,12 +3,17 @@ from wikstraktor import Wikstraktor
from
parsers.en_constants
import
string_values
from
parsers.en_constants
import
string_values
from
pronunciation
import
Pronunciation
from
pronunciation
import
Pronunciation
def
debugC
(
c
):
def
debugC
(
c
,
e
):
res
=
"
Context:
"
res
=
"
Context:
"
if
len
(
c
)
==
0
:
if
len
(
c
)
==
0
:
res
+=
"
0
"
res
+=
"
0
"
else
:
else
:
res
+=
f
"
{
len
(
c
)
}
,
{
c
[
-
1
].
level
*
'
#
'
}
{
c
[
-
1
].
title
}
"
res
+=
f
"
{
len
(
c
)
}
,
{
c
[
-
1
].
level
*
'
#
'
}
{
c
[
-
1
].
title
}
"
res
+=
"
/
"
if
len
(
e
)
==
0
:
res
+=
"
0
"
else
:
res
+=
f
"
{
len
(
e
)
}
,
{
(
len
(
e
)
-
1
)
*
'
=
'
}
{
e
[
-
1
]
}
"
return
res
return
res
class
En_en_straktor
(
Wikstraktor
):
class
En_en_straktor
(
Wikstraktor
):
...
@@ -30,17 +35,22 @@ class En_en_straktor(Wikstraktor):
...
@@ -30,17 +35,22 @@ class En_en_straktor(Wikstraktor):
for
li
in
l
.
sublists
(
i
)[
0
].
items
:
for
li
in
l
.
sublists
(
i
)[
0
].
items
:
for
t
in
self
.
wtp
.
parse
(
li
).
templates
:
for
t
in
self
.
wtp
.
parse
(
li
).
templates
:
templates
.
append
(
t
)
templates
.
append
(
t
)
a
=
None
for
t
in
templates
:
for
t
in
templates
:
print
(
t
.
normal_name
())
print
(
t
.
normal_name
())
if
t
.
normal_name
()
==
self
.
constants
[
'
t_ipa
'
]:
if
t
.
normal_name
()
==
self
.
constants
[
'
t_acc
'
]:
a
=
t
.
arguments
[
0
].
value
elif
t
.
normal_name
()
==
self
.
constants
[
'
t_ipa
'
]:
p
.
set_transcription
(
t
.
arguments
[
1
].
value
)
p
.
set_transcription
(
t
.
arguments
[
1
].
value
)
p
.
set_accent
(
a
)
print
(
t
,
t
.
arguments
,
t
.
arguments
[
0
].
value
)
print
(
t
,
t
.
arguments
,
t
.
arguments
[
0
].
value
)
elif
t
.
normal_name
()
==
self
.
constants
[
'
t_snd
'
]:
elif
t
.
normal_name
()
==
self
.
constants
[
'
t_snd
'
]:
p
.
add_sound
(
self
.
get_file_url
(
t
.
arguments
[
1
].
value
))
p
.
add_sound
(
self
.
get_file_url
(
t
.
arguments
[
1
].
value
)
,
a
)
print
(
t
,
t
.
arguments
,
t
.
arguments
[
1
].
value
)
print
(
t
,
t
.
arguments
,
t
.
arguments
[
1
].
value
)
pronunciations
.
append
(
p
)
pronunciations
.
append
(
p
)
i
+=
1
i
+=
1
print
(
pronunciations
[
0
],
pronunciations
[
1
])
print
(
pronunciations
[
0
],
pronunciations
[
1
])
return
pronunciations
def
parse
(
self
,
entry
,
sections
):
def
parse
(
self
,
entry
,
sections
):
...
@@ -48,6 +58,7 @@ class En_en_straktor(Wikstraktor):
...
@@ -48,6 +58,7 @@ class En_en_straktor(Wikstraktor):
entry_context
=
[]
#todo récupérer les infos section par section et créer des entrées avec les infos des niveaux supérieurs.
entry_context
=
[]
#todo récupérer les infos section par section et créer des entrées avec les infos des niveaux supérieurs.
for
s
in
sections
:
for
s
in
sections
:
if
s
.
title
!=
None
:
if
s
.
title
!=
None
:
#handle wiki context
if
len
(
wiki_context
)
==
0
or
s
.
level
>
wiki_context
[
-
1
].
level
:
if
len
(
wiki_context
)
==
0
or
s
.
level
>
wiki_context
[
-
1
].
level
:
wiki_context
.
append
(
s
)
wiki_context
.
append
(
s
)
else
:
else
:
...
@@ -55,8 +66,8 @@ class En_en_straktor(Wikstraktor):
...
@@ -55,8 +66,8 @@ class En_en_straktor(Wikstraktor):
wiki_context
.
pop
()
wiki_context
.
pop
()
wiki_context
[
-
1
]
=
s
wiki_context
[
-
1
]
=
s
if
s
.
title
==
self
.
constants
[
'
ipa
'
]:
if
s
.
title
==
self
.
constants
[
'
ipa
'
]:
self
.
process_pronunciation
(
self
.
wtp
.
parse
(
s
.
contents
))
entry_context
.
append
(
self
.
process_pronunciation
(
self
.
wtp
.
parse
(
s
.
contents
))
)
print
(
s
.
level
,
debugC
(
wiki_context
))
print
(
s
.
level
,
debugC
(
wiki_context
,
entry_context
))
print
(
"
ok
"
)
print
(
"
ok
"
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
pronunciation.py
+
5
−
1
View file @
a3c5d9a3
...
@@ -30,7 +30,11 @@ class Pronunciation:
...
@@ -30,7 +30,11 @@ class Pronunciation:
snds
=
[]
snds
=
[]
for
s
in
self
.
sounds
:
for
s
in
self
.
sounds
:
snds
.
append
(
s
.
serializable
())
snds
.
append
(
s
.
serializable
())
return
{
"
transcript
"
:
self
.
ipa
,
"
sounds
"
:
snds
}
if
self
.
accent
==
None
:
res
=
{
"
transcript
"
:
self
.
ipa
,
"
sounds
"
:
snds
}
else
:
res
=
{
"
accent
"
:
self
.
accent
,
"
transcript
"
:
self
.
ipa
,
"
sounds
"
:
snds
}
return
res
def
__str__
(
self
):
def
__str__
(
self
):
return
f
"
{
self
.
serializable
()
}
"
return
f
"
{
self
.
serializable
()
}
"
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