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
5622cf94
Commit
5622cf94
authored
2 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
get sounds urls
parent
20b5b9a8
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_en.py
+2
-2
2 additions, 2 deletions
parsers/en_en.py
pronunciation.py
+22
-3
22 additions, 3 deletions
pronunciation.py
wikstraktor.py
+18
-0
18 additions, 0 deletions
wikstraktor.py
with
42 additions
and
5 deletions
parsers/en_en.py
+
2
−
2
View file @
5622cf94
...
@@ -17,7 +17,7 @@ class En_en_straktor(Wikstraktor):
...
@@ -17,7 +17,7 @@ class En_en_straktor(Wikstraktor):
self
.
wiki_language
=
"
en
"
self
.
wiki_language
=
"
en
"
self
.
entry_language
=
"
en
"
self
.
entry_language
=
"
en
"
self
.
constants
=
string_values
self
.
constants
=
string_values
self
.
site
=
self
.
pwb
.
Site
(
f
'
wiktionary:
{
self
.
wiki_language
}
'
)
self
.
site
=
self
.
pwb
.
Site
(
f
'
wiktionary:
en
'
)
def
process_pronunciation
(
self
,
proContent
):
def
process_pronunciation
(
self
,
proContent
):
l
=
proContent
.
get_lists
()[
0
]
l
=
proContent
.
get_lists
()[
0
]
...
@@ -36,7 +36,7 @@ class En_en_straktor(Wikstraktor):
...
@@ -36,7 +36,7 @@ class En_en_straktor(Wikstraktor):
p
.
set_transcription
(
t
.
arguments
[
1
].
value
)
p
.
set_transcription
(
t
.
arguments
[
1
].
value
)
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
(
t
.
arguments
[
1
].
value
)
p
.
add_sound
(
self
.
get_file_url
(
t
.
arguments
[
1
].
value
)
)
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
...
...
This diff is collapsed.
Click to expand it.
pronunciation.py
+
22
−
3
View file @
5622cf94
#!/usr/bin/env python3
#!/usr/bin/env python3
class
Sound
:
def
__init__
(
self
,
url
,
accent
):
self
.
url
=
url
self
.
accent
=
accent
def
serializable
(
self
):
if
self
.
accent
==
None
:
res
=
{
"
url
"
:
self
.
url
}
else
:
res
=
{
"
accent
"
:
self
.
accent
,
"
url
"
:
self
.
url
}
return
res
class
Pronunciation
:
class
Pronunciation
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
ipa
=
None
self
.
ipa
=
None
self
.
sounds
=
[]
self
.
sounds
=
[]
self
.
accent
=
None
def
set_transcription
(
self
,
tscpt
):
def
set_transcription
(
self
,
tscpt
):
self
.
ipa
=
tscpt
self
.
ipa
=
tscpt
def
add_sound
(
self
,
url
):
def
set_accent
(
self
,
accent
):
self
.
sounds
.
append
(
url
)
self
.
accent
=
accent
def
add_sound
(
self
,
url
,
accent
=
None
):
self
.
sounds
.
append
(
Sound
(
url
,
accent
))
def
serializable
(
self
):
def
serializable
(
self
):
return
{
"
transcript
"
:
self
.
ipa
,
"
sounds
"
:
self
.
sounds
}
snds
=
[]
for
s
in
self
.
sounds
:
snds
.
append
(
s
.
serializable
())
return
{
"
transcript
"
:
self
.
ipa
,
"
sounds
"
:
snds
}
def
__str__
(
self
):
def
__str__
(
self
):
return
f
"
{
self
.
serializable
()
}
"
return
f
"
{
self
.
serializable
()
}
"
This diff is collapsed.
Click to expand it.
wikstraktor.py
+
18
−
0
View file @
5622cf94
...
@@ -21,6 +21,15 @@ class Wikstraktor:
...
@@ -21,6 +21,15 @@ class Wikstraktor:
instance
=
None
instance
=
None
return
instance
return
instance
def
get_file_url
(
self
,
file_page_name
):
res
=
None
try
:
f
=
self
.
pwb
.
FilePage
(
self
.
site
,
file_page_name
)
res
=
f
.
get_file_url
()
except
pywikibot
.
exceptions
.
NoPageError
:
print
(
f
"
{
file_page_name
}
does not exist in
{
self
.
site
}
.
"
)
return
res
def
__init__
(
self
):
def
__init__
(
self
):
self
.
entries
=
[]
self
.
entries
=
[]
self
.
pwb
=
pywikibot
self
.
pwb
=
pywikibot
...
@@ -58,6 +67,15 @@ class Wikstraktor:
...
@@ -58,6 +67,15 @@ class Wikstraktor:
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
e
=
Wikstraktor
.
get_instance
(
'
en
'
,
"
en
"
)
e
=
Wikstraktor
.
get_instance
(
'
en
'
,
"
en
"
)
print
(
e
.
get_file_url
(
"
File:LL-Q1860 (eng)-Nattes à chat----parent.wav
"
))
print
(
e
.
get_file_url
(
"
File:LL-Q1860 (eng)-Nattes à chat-parent.wav
"
))
print
(
e
.
fetch
(
"
test
"
),
"
entries added
"
)
print
(
e
.
fetch
(
"
test
"
),
"
entries added
"
)
# site = pywikibot.Site(f'wiktionary:en')
# p = pywikibot.FilePage(site, "File:LL-Q1860 (eng)-Nattes à chat----parent.wav")
# print(p)
# if not p.exists():
# site = pywikibot.Site('commons')
# p = pywikibot.FilePage(site, "File:LL-Q1860 (eng)-Nattes à chat-parent.wav")
# print(p.get_file_url())
#print(e)
#print(e)
#Entry("test", wtp.parse(page.text)))
#Entry("test", wtp.parse(page.text)))
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