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
28505770
Commit
28505770
authored
2 years ago
by
Enzo Simonnet
Browse files
Options
Downloads
Patches
Plain Diff
Replace wikstraktor.py
parent
017cf28e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wikstraktor.py
+23
-10
23 additions, 10 deletions
wikstraktor.py
with
23 additions
and
10 deletions
wikstraktor.py
+
23
−
10
View file @
28505770
...
...
@@ -98,7 +98,7 @@ class Example:
if
self
.
source
!=
None
:
res
[
"
source
"
]
=
self
.
source
if
self
.
url
!=
None
:
res
[
"
url
"
]
=
url
res
[
"
url
"
]
=
self
.
url
return
res
class
Sense
:
...
...
@@ -255,6 +255,7 @@ class ParserContext:
self
.
create_entry
()
def
create_entry
(
self
):
#Dans le dictionnaire de keys, il n'y a jamais de senses ou de POS
res
=
Entry
(
self
.
lemma
)
for
l
in
self
.
context
:
if
"
pro
"
in
l
.
keys
():
...
...
@@ -343,14 +344,19 @@ class Wikstraktor:
while
self
.
parserContext
.
get_level
()
>
s
.
level
:
self
.
parserContext
.
pop
()
self
.
parserContext
.
set_top_wiki
(
s
)
if
s
.
title
==
self
.
constants
[
'
pro
'
]:
if
self
.
wtp
.
parse
(
s
.
title
).
templates
==
[]:
stitle
=
s
.
title
else
:
stitle
=
self
.
wtp
.
parse
(
s
.
title
).
templates
[
0
].
arguments
[
0
].
value
if
stitle
==
self
.
constants
[
'
pro
'
]:
self
.
parserContext
.
set_top_entry_info
(
'
pro
'
,
self
.
process_pronunciation
(
self
.
wtp
.
parse
(
s
.
contents
)))
elif
self
.
constants
[
'
ety
'
]
in
s
.
title
:
elif
self
.
constants
[
'
ety
'
]
in
stitle
:
self
.
parserContext
.
set_top_entry_info
(
'
ety
'
,
self
.
process_etymology
(
self
.
wtp
.
parse
(
s
.
contents
)))
elif
s
.
title
in
self
.
constants
[
'
POS
'
].
keys
():
pos
=
self
.
constants
[
'
POS
'
][
s
.
title
]
self
.
parserContext
.
set_top_entry_info
(
'
POS
'
,
pos
,
False
)
self
.
parserContext
.
set_top_entry_info
(
'
senses
'
,
self
.
process_senses
(
entry
,
pos
+
str
(
len
(
self
.
parserContext
.
entries
)),
self
.
wtp
.
parse
(
s
.
contents
)))
elif
stitle
in
self
.
constants
[
'
POS
'
].
keys
():
if
s
.
title
in
self
.
constants
[
'
POS
'
].
keys
():
pos
=
self
.
constants
[
'
POS
'
][
stitle
]
self
.
parserContext
.
set_top_entry_info
(
'
POS
'
,
pos
,
False
)
self
.
parserContext
.
set_top_entry_info
(
'
senses
'
,
self
.
process_senses
(
entry
,
pos
+
str
(
len
(
self
.
parserContext
.
entries
)),
self
.
wtp
.
parse
(
s
.
contents
)))
res
=
len
(
self
.
parserContext
.
entries
)
if
res
>
0
:
for
e
in
self
.
parserContext
.
entries
:
...
...
@@ -374,12 +380,19 @@ class Wikstraktor:
if
__name__
==
"
__main__
"
:
e
=
Wikstraktor
.
get_instance
(
'
en
'
,
"
en
"
)
#e = Wikstraktor.get_instance('en', "en")
f
=
Wikstraktor
.
get_instance
(
'
fr
'
,
'
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"))
e
.
fetch
(
"
test
"
)
#e.fetch("water")
f
.
fetch
(
"
water
"
)
# print(e.fetch("test"), "entries added")
print
(
e
)
#print(e)
file_path
=
'
test.json
'
fichier
=
open
(
file_path
,
"
w
"
)
#fichier.write(str(f))
fichier
.
write
(
str
(
f
))
fichier
.
close
()
# site = pywikibot.Site(f'wiktionary:en')
# p = pywikibot.FilePage(site, "File:LL-Q1860 (eng)-Nattes à chat----parent.wav")
# print(p)
...
...
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