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
04b44fa5
Commit
04b44fa5
authored
1 year ago
by
Empiriker
Browse files
Options
Downloads
Patches
Plain Diff
Use parse_page instead of page_handler
parent
1069396e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app.py
+3
-1
3 additions, 1 deletion
src/app.py
src/wiktextract_wrapper.py
+11
-17
11 additions, 17 deletions
src/wiktextract_wrapper.py
with
14 additions
and
18 deletions
src/app.py
+
3
−
1
View file @
04b44fa5
...
...
@@ -35,7 +35,9 @@ def search(wiktlang, wordlang, word):
return
jsonify
({
"
error
"
:
"
Parsing page resulted in error:
"
+
str
(
e
)}),
500
finally
:
wiktextractor
.
page_handler
.
wxr
.
wtp
.
db_conn
.
close
()
wiktextractor
.
wxr
.
wtp
.
db_conn
.
close
()
if
wiktextractor
.
wxr
.
thesaurus_db_conn
:
wiktextractor
.
wxr
.
thesaurus_db_conn
.
close
()
else
:
return
(
...
...
This diff is collapsed.
Click to expand it.
src/wiktextract_wrapper.py
+
11
−
17
View file @
04b44fa5
from
wiktextract.wiktionary
import
page_handler
from
wikitextprocessor
import
Page
from
wiktextract.page
import
parse_page
from
wiktextract_context
import
get_wiktextract_context
db_path
=
"
./sqlite.db
"
DEFAULT_PAGE_VALUES
=
{
...
...
@@ -16,33 +15,28 @@ class Wiktextract:
self
.
wiktlang
=
wiktlang
self
.
wordlang
=
wordlang
self
.
page_handler
=
page_handler
self
.
page_handler
.
wxr
=
get_wiktextract_context
(
wiktlang
,
wordlang
)
# self.page_handler = page_handler
# self.page_handler.wxr : WiktextractContext =
self
.
wxr
=
get_wiktextract_context
(
wiktlang
,
wordlang
)
def
parse_page
(
self
,
title
:
str
,
wikicode
:
str
):
# add page to the database (making it accessible to LUA templates)
self
.
page_handler
.
wxr
.
wtp
.
add_page
(
self
.
wxr
.
wtp
.
add_page
(
title
=
title
,
namespace_id
=
DEFAULT_PAGE_VALUES
[
"
namespace_id
"
],
body
=
wikicode
,
model
=
DEFAULT_PAGE_VALUES
[
"
model
"
],
)
# create a page object (for parsing)
page
=
Page
(
title
,
0
,
None
,
True
,
wikicode
,
"
wikitext
"
)
self
.
wxr
.
wtp
.
start_page
(
title
)
# parse the page
success
,
ret
,
err
=
self
.
page_handler
(
page
)
result
,
parsing_errors
=
ret
result
=
parse_page
(
self
.
wxr
,
title
,
wikicode
)
# remove the page from the database
self
.
page_handler
.
wxr
.
wtp
.
db_conn
.
execute
(
self
.
wxr
.
wtp
.
db_conn
.
execute
(
"
DELETE FROM pages WHERE title = ? AND model = ?
"
,
(
title
,
DEFAULT_PAGE_VALUES
[
"
model
"
]),
)
self
.
page_handler
.
wxr
.
wtp
.
db_conn
.
commit
()
self
.
wxr
.
wtp
.
db_conn
.
commit
()
if
success
:
return
result
else
:
raise
Exception
(
err
)
return
result
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