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
7c707d79
Commit
7c707d79
authored
1 year ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
Reporting manually
842647de
parent
37085a49
No related branches found
Branches containing commit
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
+6
-8
6 additions, 8 deletions
parsers/en_en.py
wikstraktor.py
+19
-17
19 additions, 17 deletions
wikstraktor.py
wikstraktor.sqlite
+0
-0
0 additions, 0 deletions
wikstraktor.sqlite
with
25 additions
and
25 deletions
parsers/en_en.py
+
6
−
8
View file @
7c707d79
...
...
@@ -24,18 +24,16 @@ class En_en_straktor(Wikstraktor):
acc
=
None
for
j
,
t
in
enumerate
(
templates
):
if
(
t
.
normal_name
()
==
self
.
constants
[
'
t_acc
'
]
and
templates
[
j
+
1
].
normal_name
()
!=
self
.
constants
[
'
t_acc
'
]):
acc
=
t
.
arguments
for
a
in
t
.
arguments
:
p
.
set_accent
(
a
.
value
)
elif
t
.
normal_name
()
==
self
.
constants
[
'
t_ipa
'
]:
p
.
set_transcription
(
t
.
arguments
[
1
].
value
)
if
acc
!=
None
:
for
a
in
acc
:
p
.
set_accent
(
a
.
value
)
elif
t
.
normal_name
()
==
self
.
constants
[
'
t_snd
'
]:
p
.
add_sound
(
self
.
get_file_url
(
t
.
arguments
[
1
].
value
),
t
.
arguments
[
2
].
value
)
if
j
==
len
(
templates
)
-
1
or
templates
[
j
+
1
].
normal_name
()
==
self
.
constants
[
'
t_acc
'
]
:
if
p
.
ipa
!=
None
or
p
.
has_accents
():
pronunciations
.
append
(
p
)
p
=
Pronunciation
(
)
if
p
.
ipa
!=
None
or
p
.
has_accents
()
or
p
.
has_sounds
()
:
pronunciations
.
append
(
p
)
else
:
self
.
log
.
add_log
(
"
En_en_straktor.process_pronunciation
"
,
f
"
“
{
l
.
fullitems
[
i
]
}
” processed as empty →
{
p
}
"
)
i
+=
1
return
pronunciations
...
...
This diff is collapsed.
Click to expand it.
wikstraktor.py
+
19
−
17
View file @
7c707d79
...
...
@@ -27,27 +27,28 @@ class SubInfo:
cls
.
next_id
=
0
def
__init__
(
self
,
prefix
=
None
):
self
.
id
=
None
self
.
id
=
self
.
__class__
.
next_id
self
.
__class__
.
inc_n_id
()
self
.
label
=
None
self
.
set_id
(
prefix
)
def
set_id
(
self
,
prefix
):
if
self
.
id
==
None
and
prefix
!=
None
:
self
.
id
=
f
"
{
prefix
}
_
{
self
.
__class__
.
prfx
}{
self
.
__class__
.
next_id
}
"
self
.
__class__
.
inc_n_id
()
return
self
.
id
def
set_id
(
self
,
prefix
,
force
=
False
):
if
(
self
.
label
==
None
or
force
)
and
prefix
!=
None
:
self
.
label
=
f
"
{
prefix
}
_
{
self
.
__class__
.
prfx
}{
self
.
id
}
"
return
self
.
label
def
replace_src_in_id
(
self
,
former_src
,
new_src
):
##Attention si on nettoie en mettant des sources partout, il faudra changer
res
=
None
if
self
.
id
!=
None
and
former_src
!=
None
and
new_src
!=
None
:
self
.
id
=
re
.
sub
(
r
'
^([\w\.]+)-(
'
+
str
(
former_src
)
+
'
)
'
,
r
"
\1-
"
+
str
(
new_src
),
self
.
id
)
res
=
self
.
id
if
self
.
label
!=
None
and
former_src
!=
None
and
new_src
!=
None
:
self
.
label
=
re
.
sub
(
r
'
^([\w\.]+)-(
'
+
str
(
former_src
)
+
'
)
'
,
r
"
\1-
"
+
str
(
new_src
),
self
.
label
)
res
=
self
.
label
return
res
def
get_src_from_id
(
self
):
res
=
None
if
self
.
id
!=
None
:
gp
=
re
.
match
(
r
'
^[\w\.]+-(\d{1,2})
'
,
self
.
id
)
if
self
.
label
!=
None
:
gp
=
re
.
match
(
r
'
^[\w\.]+-(\d{1,2})
'
,
self
.
label
)
if
gp
:
res
=
int
(
gp
.
group
(
1
))
return
res
...
...
@@ -96,6 +97,9 @@ class Pronunciation(SubInfo):
def
has_accents
(
self
):
return
len
(
self
.
accents
)
>
0
def
has_sounds
(
self
):
return
len
(
self
.
sounds
)
>
0
def
add_sound
(
self
,
url
,
accent
=
None
):
self
.
sounds
.
append
(
Sound
(
url
,
accent
))
...
...
@@ -249,7 +253,6 @@ class Sense(SubInfo):
else
:
theDef
=
Definition
(
lang
,
definition
)
if
theDef
!=
None
and
theDef
not
in
self
.
definitions
:
print
(
"
def set id
"
,
self
.
get_id
())
##
theDef
.
set_id
(
self
.
get_id
())
self
.
definitions
.
append
(
theDef
)
...
...
@@ -394,7 +397,7 @@ class Entry:
def
add_pronunciation
(
self
,
p
):
if
p
not
in
self
.
pronunciations
:
p
.
set_id
(
self
.
get_prefix
()
)
p
.
set_id
(
self
.
get_prefix
()
,
True
)
#pro often parsed without context
self
.
pronunciations
.
append
(
p
)
def
set_senses
(
self
,
senses
):
...
...
@@ -835,10 +838,9 @@ if __name__ == "__main__":
\033
[1m
\033
[32mex :
\033
[0m
‣
\033
[0m
\033
[32m./wikstraktor.py -m blue
\033
[0m
‣
\033
[0m
\033
[32m./wikstraktor.py -m blue -f blue.json -A -C
\033
[0m
‣
\033
[0m
\033
[32m./wikstraktor.py -l en -w fr -m blue -f blue.json -n -A -C
\033
[0m
‣
\033
[0m
\033
[32m./wikstraktor.py -l en -w fr+en -m particular -f particular.json
\033
[0m
"""
)
parser
.
add_argument
(
"
-l
"
,
"
--language
"
,
help
=
"
la ou les langue(s) du mot (séparées par des “+”)
"
,
type
=
str
,
default
=
"
en
"
)
parser
.
add_argument
(
"
-w
"
,
"
--wiki_language
"
,
help
=
"
la ou les langue(s) du wiki (séparées par des “+”)
"
,
type
=
str
,
default
=
"
en
"
)
‣
\033
[0m
\033
[32m./wikstraktor.py -l en -w fr -m blue -f blue.json -n -A -C
\033
[0m
"""
)
parser
.
add_argument
(
"
-l
"
,
"
--language
"
,
help
=
"
la langue du mot
"
,
type
=
str
,
default
=
"
en
"
)
parser
.
add_argument
(
"
-w
"
,
"
--wiki_language
"
,
help
=
"
la langue du wiki
"
,
type
=
str
,
default
=
"
en
"
)
parser
.
add_argument
(
"
-m
"
,
"
--mot
"
,
help
=
"
le mot à chercher
"
,
type
=
str
,
default
=
None
)
parser
.
add_argument
(
"
-f
"
,
"
--destination_file
"
,
help
=
"
le fichier dans lequel stocker le résultat
"
,
type
=
str
,
default
=
None
)
parser
.
add_argument
(
"
-A
"
,
"
--force_ascii
"
,
help
=
"
json avec que des caractères ascii
"
,
action
=
"
store_true
"
)
...
...
This diff is collapsed.
Click to expand it.
wikstraktor.sqlite
+
0
−
0
View file @
7c707d79
No preview for this file type
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