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
33cfdfc9
Commit
33cfdfc9
authored
2 years ago
by
Enzo Simonnet
Browse files
Options
Downloads
Patches
Plain Diff
Replace wikstraktor.py
parent
e05cda9c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wikstraktor.py
+29
-8
29 additions, 8 deletions
wikstraktor.py
with
29 additions
and
8 deletions
wikstraktor.py
+
29
−
8
View file @
33cfdfc9
...
@@ -258,6 +258,7 @@ class ParserContext:
...
@@ -258,6 +258,7 @@ class ParserContext:
#Dans le dictionnaire de keys, il n'y a jamais de senses ou de POS
#Dans le dictionnaire de keys, il n'y a jamais de senses ou de POS
res
=
Entry
(
self
.
lemma
)
res
=
Entry
(
self
.
lemma
)
for
l
in
self
.
context
:
for
l
in
self
.
context
:
print
(
l
.
keys
())
if
"
pro
"
in
l
.
keys
():
if
"
pro
"
in
l
.
keys
():
res
.
set_pronunciations
(
l
[
'
pro
'
])
res
.
set_pronunciations
(
l
[
'
pro
'
])
if
"
ety
"
in
l
.
keys
():
if
"
ety
"
in
l
.
keys
():
...
@@ -344,17 +345,19 @@ class Wikstraktor:
...
@@ -344,17 +345,19 @@ class Wikstraktor:
while
self
.
parserContext
.
get_level
()
>
s
.
level
:
while
self
.
parserContext
.
get_level
()
>
s
.
level
:
self
.
parserContext
.
pop
()
self
.
parserContext
.
pop
()
self
.
parserContext
.
set_top_wiki
(
s
)
self
.
parserContext
.
set_top_wiki
(
s
)
if
self
.
wtp
.
parse
(
s
.
title
).
templates
==
[]:
stitle
=
self
.
wtp
.
parse
(
s
.
title
).
templates
if
stitle
==
[]:
stitle
=
s
.
title
stitle
=
s
.
title
else
:
else
:
stitle
=
s
elf
.
wtp
.
parse
(
s
.
title
).
templates
[
0
].
arguments
[
0
].
value
stitle
=
s
title
[
0
].
arguments
[
0
].
value
if
s
title
==
self
.
constants
[
'
pro
'
]
:
if
s
elf
.
isPro
(
stitle
)
:
self
.
parserContext
.
set_top_entry_info
(
'
pro
'
,
self
.
process_pronunciation
(
self
.
wtp
.
parse
(
s
.
contents
)))
self
.
parserContext
.
set_top_entry_info
(
'
pro
'
,
self
.
process_pronunciation
(
self
.
wtp
.
parse
(
s
.
contents
)))
elif
self
.
constants
[
'
ety
'
]
in
stitle
:
elif
self
.
isEty
(
stitle
)
:
self
.
parserContext
.
set_top_entry_info
(
'
ety
'
,
self
.
process_etymology
(
self
.
wtp
.
parse
(
s
.
contents
)))
self
.
parserContext
.
set_top_entry_info
(
'
ety
'
,
self
.
process_etymology
(
self
.
wtp
.
parse
(
s
.
contents
)))
elif
stitle
in
self
.
constants
[
'
POS
'
].
keys
():
# elif stitle in self.constants['POS'].keys():
if
s
.
title
in
self
.
constants
[
'
POS
'
].
keys
():
else
:
pos
=
self
.
constants
[
'
POS
'
][
stitle
]
pos
=
self
.
process_POS
(
stitle
)
if
pos
!=
None
:
self
.
parserContext
.
set_top_entry_info
(
'
POS
'
,
pos
,
False
)
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
)))
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
)
res
=
len
(
self
.
parserContext
.
entries
)
...
@@ -363,6 +366,24 @@ class Wikstraktor:
...
@@ -363,6 +366,24 @@ class Wikstraktor:
self
.
entries
.
append
(
e
)
self
.
entries
.
append
(
e
)
return
res
return
res
def
isPro
(
self
,
title
):
if
type
(
self
.
constants
[
'
pro
'
])
==
str
:
res
=
title
==
self
.
constants
[
'
pro
'
]
else
:
res
=
title
in
self
.
constants
[
'
pro
'
]
print
(
title
,
res
)
return
res
def
isEty
(
self
,
title
):
if
type
(
self
.
constants
[
'
ety
'
])
==
str
:
res
=
title
==
self
.
constants
[
'
ety
'
]
else
:
res
=
title
in
self
.
constants
[
'
ety
'
]
return
res
def
process_POS
(
self
,
parsedwikitext
):
pass
#in subclass
def
process_pronunciation
(
self
,
parsedwikitext
):
def
process_pronunciation
(
self
,
parsedwikitext
):
pass
#in subclass
pass
#in subclass
...
@@ -385,7 +406,7 @@ if __name__ == "__main__":
...
@@ -385,7 +406,7 @@ if __name__ == "__main__":
# 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.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("water")
#e.fetch("water")
f
.
fetch
(
"
water
"
)
f
.
fetch
(
"
blue
"
)
# print(e.fetch("test"), "entries added")
# print(e.fetch("test"), "entries added")
#print(e)
#print(e)
file_path
=
'
test.json
'
file_path
=
'
test.json
'
...
...
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