Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
EWOK
Manage
Activity
Members
Labels
Plan
Issues
2
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
EWOK
Commits
c13887b2
Commit
c13887b2
authored
1 year ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
clean (a little bit)
6c829c43
parent
d9ffba47
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
src/wiktextract_wrapper.py
+23
-20
23 additions, 20 deletions
src/wiktextract_wrapper.py
with
24 additions
and
20 deletions
.gitignore
+
1
−
0
View file @
c13887b2
...
...
@@ -136,6 +136,7 @@ celerybeat.pid
env/
venv/
ENV/
liveq/
env.bak/
venv.bak/
...
...
This diff is collapsed.
Click to expand it.
src/wiktextract_wrapper.py
+
23
−
20
View file @
c13887b2
import
sys
import
os
# Specify the path to your project directory
project_directory
=
'
/home/enzosim/live-query-wiktextract
'
if
__name__
==
"
__main__
"
:
import
os
import
argparse
from
argparse
import
RawTextHelpFormatter
#pour le formattage de l'aide
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
RawTextHelpFormatter
,
description
=
"""
Wiktextract wrapper
\033
[1m
\033
[32mex :
\033
[0m
‣
\033
[0m
\033
[32m./wiktextract_wrapper.py -l en -w fr -e yellow
\033
[0m
"""
)
parser
.
add_argument
(
"
-l
"
,
"
--word_language
"
,
help
=
"
language of the sought entry
"
,
type
=
str
,
default
=
"
en
"
)
parser
.
add_argument
(
"
-w
"
,
"
--wikt_language
"
,
help
=
"
language of the wiktionary
"
,
type
=
str
,
default
=
"
en
"
)
parser
.
add_argument
(
"
-e
"
,
"
--entry
"
,
help
=
"
the entry
"
,
type
=
str
,
default
=
None
)
parser
.
add_argument
(
"
-z
"
,
"
--zero_config
"
,
help
=
"
Don
'
t use if you know how to configure a server (this changes the working directory)
"
,
action
=
"
store_true
"
)
args
=
parser
.
parse_args
()
formerdir
=
None
if
args
.
zero_config
:
import
sys
import
pathlib
#print(f"zero config {pathlib.Path(__file__).parent.parent.resolve()}")
formerdir
=
os
.
getcwd
()
os
.
chdir
(
pathlib
.
Path
(
__file__
).
parent
.
parent
.
resolve
())
# Change the current working directory
os
.
chdir
(
project_directory
)
from
wiktextract.page
import
parse_page
from
wiktextract_context
import
get_wiktextract_context
...
...
@@ -24,8 +36,8 @@ class Wiktextract:
page
=
self
.
wxr
.
wtp
.
get_page
(
title
)
if
not
page
:
return
None
result
=
parse_page
(
self
.
wxr
,
title
,
page
.
body
)
#print(json.dumps(result), "\n\n\n")
...
...
@@ -99,20 +111,11 @@ class Wiktextract:
if
__name__
==
"
__main__
"
:
import
argparse
from
argparse
import
RawTextHelpFormatter
#pour le formattage de l'aide
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
RawTextHelpFormatter
,
description
=
"""
Wiktextract wrapper
\033
[1m
\033
[32mex :
\033
[0m
‣
\033
[0m
\033
[32m./wiktextract_wrapper.py -l en -w fr -e yellow
\033
[0m
"""
)
parser
.
add_argument
(
"
-l
"
,
"
--word_language
"
,
help
=
"
language of the sought entry
"
,
type
=
str
,
default
=
"
en
"
)
parser
.
add_argument
(
"
-w
"
,
"
--wikt_language
"
,
help
=
"
language of the wiktionary
"
,
type
=
str
,
default
=
"
en
"
)
parser
.
add_argument
(
"
-e
"
,
"
--entry
"
,
help
=
"
the entry
"
,
type
=
str
,
default
=
None
)
args
=
parser
.
parse_args
()
if
args
.
entry
!=
None
:
wkstrkt
=
Wiktextract
(
args
.
wikt_language
,
args
.
word_language
)
result
=
wkstrkt
.
parse_page
(
args
.
entry
)
print
(
json
.
dumps
(
result
,
ensure_ascii
=
False
))
else
:
print
(
"
{
'
err
'
:
'
You need to specify a word
'
}
"
)
if
formerdir
!=
None
:
os
.
chdir
(
formerdir
)
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