forked from aitalvivem/AitalvivemBot
-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.py
40 lines (32 loc) · 999 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python3
import logging
import LexData
from LexData.language import en
logging.basicConfig(level=logging.INFO)
repo = LexData.WikidataSession("MichaelSchoenitzer", "foobar")
# Open a Lexeme
L2 = LexData.Lexeme(repo, "L2")
# Access the claims
print(L2.claims.keys())
# and Forms
print(len(L2.forms))
F1 = L2.forms[0]
print(F1.claims.keys())
# and senses
print(len(L2.senses))
S1 = L2.senses[0]
print(S1.claims.keys())
# Find or create a Lexeme by lemma, language and grammatical form
L2 = LexData.get_or_create_lexeme(repo, "first", en, "Q1084")
# You can easily create forms…
if len(L2.forms) == 0:
L2.createForm("firsts", ["Q146786"])
# …or senses, with or without additional claims
if len(L2.senses) == 0:
L2.createSense(
{
"en": "Element in an ordered list which comes before all others according to the ordering",
"de": "einer Ordnung folgend das Element vor allen anderen",
},
claims={"P5137": ["Q19269277"]},
)