Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neeme Kahusk
eurown
Commits
17d0d8e9
Commit
17d0d8e9
authored
Dec 01, 2016
by
Neeme Kahusk
Browse files
musa töötab
parent
9641c970
Changes
1
Hide whitespace changes
Inline
Side-by-side
eurown_test.ipynb
View file @
17d0d8e9
...
...
@@ -103,12 +103,12 @@
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed":
tru
e
"collapsed":
fals
e
},
"outputs": [],
"source": [
">>> a.variants[0].gloss = \"elusorganism, mida tavaliselt iseloomustab \\\n",
"vabatahtliku liikumise võime ja närvisüsteemi olemasolu
\"
"
">>> a.variants[0].gloss =
'
\"elusorganism
\"
, mida tavaliselt iseloomustab \\\n",
"vabatahtliku liikumise võime ja närvisüsteemi olemasolu
'
"
]
},
{
...
...
@@ -132,7 +132,7 @@
"outputs": [],
"source": [
"a.variants[0].add_external_info(eurown.ExternalInfo(2))\n",
"a.variants[0].external_info[-1].text_key = 'testime veel'"
"a.variants[0].external_info[-1].text_key = 'testime
\"
veel
\"
'"
]
},
{
...
...
@@ -172,7 +172,7 @@
" 1 VARIANTS\n",
" 2 LITERAL \"loom\"\n",
" 3 SENSE 1\n",
" 3 DEFINITION \"elusorganism, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu\"\n",
" 3 DEFINITION
\"
\"elusorganism
\"
, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu\"\n",
" 3 EXAMPLES\n",
" 4 EXAMPLE \"Loomad on lahti!\"\n",
" 4 EXAMPLE \"Kelle \"loomad\" need on?\"\n",
...
...
@@ -180,7 +180,7 @@
" 4 SOURCE_ID 1\n",
" 5 TEXT_KEY \"testime\"\n",
" 4 SOURCE_ID 2\n",
" 5 TEXT_KEY \"testime veel\"\n",
" 5 TEXT_KEY \"testime
\"
veel\"\
"\
n",
" 2 LITERAL \"elajas\"\n",
" 3 SENSE 2\n"
]
...
...
@@ -286,7 +286,7 @@
" 1 VARIANTS\n",
" 2 LITERAL \"loom\"\n",
" 3 SENSE 1\n",
" 3 DEFINITION \"elusorganism, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu\"\n",
" 3 DEFINITION
\"
\"elusorganism
\"
, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu\"\n",
" 3 EXAMPLES\n",
" 4 EXAMPLE \"Loomad on lahti!\"\n",
" 4 EXAMPLE \"Kelle \"loomad\" need on?\"\n",
...
...
@@ -294,7 +294,7 @@
" 4 SOURCE_ID 1\n",
" 5 TEXT_KEY \"testime\"\n",
" 4 SOURCE_ID 2\n",
" 5 TEXT_KEY \"testime veel\"\n",
" 5 TEXT_KEY \"testime
\"
veel\"\
"\
n",
" 2 LITERAL \"elajas\"\n",
" 3 SENSE 2\n",
" 1 INTERNAL_LINKS\n",
...
...
%% Cell type:markdown id: tags:
# Eurown testing
%% Cell type:code id: tags:
```
python
>>>
import
eurown
>>>
a
=
eurown
.
Synset
(
43
)
>>>
b
=
eurown
.
Variant
(
'loom'
,
1
)
>>>
c
=
eurown
.
Variant
(
'elajas'
,
2
)
>>>
a
.
add_variant
(
b
)
>>>
print
(
a
)
```
%% Output
0 @43@ WORD_MEANING
1 VARIANTS
2 LITERAL "loom"
3 SENSE 1
%% Cell type:code id: tags:
```
python
>>>
print
(
b
)
```
%% Output
2 LITERAL "loom"
3 SENSE 1
%% Cell type:code id: tags:
```
python
>>>
print
(
c
)
```
%% Output
2 LITERAL "elajas"
3 SENSE 2
%% Cell type:code id: tags:
```
python
>>>
a
.
add_variant
(
c
)
>>>
print
(
a
)
```
%% Output
0 @43@ WORD_MEANING
1 VARIANTS
2 LITERAL "loom"
3 SENSE 1
2 LITERAL "elajas"
3 SENSE 2
%% Cell type:code id: tags:
```
python
>>>
a
.
variants
[
0
].
gloss
=
"elusorganism, mida tavaliselt iseloomustab
\
vabatahtliku liikumise võime ja närvisüsteemi olemasolu
"
>>>
a
.
variants
[
0
].
gloss
=
'
"elusorganism
"
, mida tavaliselt iseloomustab
\
vabatahtliku liikumise võime ja närvisüsteemi olemasolu
'
```
%% Cell type:code id: tags:
```
python
a
.
variants
[
0
].
add_external_info
(
eurown
.
ExternalInfo
(
1
))
a
.
variants
[
0
].
external_info
[
-
1
].
text_key
=
'testime'
```
%% Cell type:code id: tags:
```
python
a
.
variants
[
0
].
add_external_info
(
eurown
.
ExternalInfo
(
2
))
a
.
variants
[
0
].
external_info
[
-
1
].
text_key
=
'testime veel'
a
.
variants
[
0
].
external_info
[
-
1
].
text_key
=
'testime
"
veel
"
'
```
%% Cell type:code id: tags:
```
python
a
.
variants
[
0
].
add_example
(
eurown
.
Example
(
'Loomad on lahti!'
))
```
%% Cell type:code id: tags:
```
python
a
.
variants
[
0
].
add_example
(
eurown
.
Example
(
'Kelle "loomad" need on?'
))
```
%% Cell type:code id: tags:
```
python
>>>
print
(
a
)
```
%% Output
0 @43@ WORD_MEANING
1 VARIANTS
2 LITERAL "loom"
3 SENSE 1
3 DEFINITION "elusorganism, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu"
3 DEFINITION
"
"elusorganism
"
, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu"
3 EXAMPLES
4 EXAMPLE "Loomad on lahti!"
4 EXAMPLE "Kelle "loomad" need on?"
3 EXTERNAL_INFO
4 SOURCE_ID 1
5 TEXT_KEY "testime"
4 SOURCE_ID 2
5 TEXT_KEY "testime veel"
5 TEXT_KEY "testime
"
veel"
"
2 LITERAL "elajas"
3 SENSE 2
%% Cell type:code id: tags:
```
python
d
=
eurown
.
Synset
(
44
)
print
(
d
)
```
%% Output
0 @44@ WORD_MEANING
%% Cell type:code id: tags:
```
python
d
.
add_variant
(
eurown
.
Variant
(
'elusolend'
,
1
))
d
.
add_variant
(
eurown
.
Variant
(
'organism'
,
2
))
d
.
variants
[
0
].
gloss
=
'elusorganism, hrl. inimene v. loom'
print
(
d
)
```
%% Output
0 @44@ WORD_MEANING
1 VARIANTS
2 LITERAL "elusolend"
3 SENSE 1
3 DEFINITION "elusorganism, hrl. inimene v. loom"
2 LITERAL "organism"
3 SENSE 2
%% Cell type:code id: tags:
```
python
a
.
add_internal_link
(
eurown
.
InternalLink
(
'has_hyponym'
,
d
))
```
%% Cell type:code id: tags:
```
python
e
=
eurown
.
Synset
(
pos
=
'n'
,
wordnet_offset
=
'88123456'
)
a
.
add_eq_link
(
eurown
.
EqLink
(
'eq_synonym'
,
e
))
print
(
e
)
```
%% Output
0 WORD_MEANING
1 PART_OF_SPEECH "n"
%% Cell type:code id: tags:
```
python
print
(
a
)
```
%% Output
0 @43@ WORD_MEANING
1 VARIANTS
2 LITERAL "loom"
3 SENSE 1
3 DEFINITION "elusorganism, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu"
3 DEFINITION
"
"elusorganism
"
, mida tavaliselt iseloomustab vabatahtliku liikumise võime ja närvisüsteemi olemasolu"
3 EXAMPLES
4 EXAMPLE "Loomad on lahti!"
4 EXAMPLE "Kelle "loomad" need on?"
3 EXTERNAL_INFO
4 SOURCE_ID 1
5 TEXT_KEY "testime"
4 SOURCE_ID 2
5 TEXT_KEY "testime veel"
5 TEXT_KEY "testime
"
veel"
"
2 LITERAL "elajas"
3 SENSE 2
1 INTERNAL_LINKS
2 RELATION "has_hyponym"
3 TARGET_CONCEPT
4 PART_OF_SPEECH
4 LITERAL "elusolend"
5 SENSE 1
1 EQ_LINKS
2 EQ_RELATION "eq_synonym"
3 TARGET_ILI
4 PART_OF_SPEECH "n"
4 WORDNET_OFFSET 88123456
%% Cell type:code id: tags:
```
python
snset
=
eurown
.
Synset
()
print
(
snset
)
```
%% Output
0 WORD_MEANING
%% Cell type:code id: tags:
```
python
inst
=
eurown
.
Instance
()
print
(
inst
)
```
%% Output
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-17-64e3c612e741> in <module>()
----> 1 inst = eurown.Instance()
2 print(inst)
AttributeError: 'module' object has no attribute 'Instance'
%% Cell type:code id: tags:
```
python
aa
=
eurown
.
Variant
(
'Aafrika'
,
1
)
inst
.
add_variant
(
aa
)
print
(
inst
)
```
%% Cell type:markdown id: tags:
# Leksikon
%% Cell type:code id: tags:
```
python
lex
=
eurown
.
Lexicon
(
'kb73'
,
'../Estwn/kb73/kb73-utf8.norm'
,
'est'
,
'73'
)
lex
.
read_file
()
print
(
"leksikon {} loetud!"
.
format
(
lex
.
name
))
```
%% Cell type:code id: tags:
```
python
from
parser
import
find_parent
,
read_synset
```
%% Cell type:code id: tags:
```
python
snset_indexes
=
[[
j
,
i
]
for
j
,
i
in
enumerate
(
lex
.
data
)
if
'level'
in
i
and
i
[
'level'
]
==
0
]
```
%% Cell type:code id: tags:
```
python
print
(
len
(
snset_indexes
))
```
%% Cell type:code id: tags:
```
python
print
(
snset_indexes
[:
5
])
```
%% Cell type:code id: tags:
```
python
snsets
=
[
read_synset
(
i
[
0
],
lex
.
data
)
for
i
in
snset_indexes
]
```
%% Cell type:code id: tags:
```
python
for
i
in
snsets
[:
3
]:
print
(
i
)
```
%% Cell type:code id: tags:
```
python
```
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment