Commit 17d0d8e9 authored by Neeme Kahusk's avatar Neeme Kahusk
Browse files

musa töötab

parent 9641c970
%% 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: stream
0 @43@ WORD_MEANING
1 VARIANTS
2 LITERAL "loom"
3 SENSE 1
%% Cell type:code id: tags:
``` python
>>> print(b)
```
%%%% Output: stream
2 LITERAL "loom"
3 SENSE 1
%% Cell type:code id: tags:
``` python
>>> print(c)
```
%%%% Output: stream
2 LITERAL "elajas"
3 SENSE 2
%% Cell type:code id: tags:
``` python
>>> a.add_variant(c)
>>> print(a)
```
%%%% Output: stream
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: stream
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: stream
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: stream
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: stream
0 WORD_MEANING
1 PART_OF_SPEECH "n"
%% Cell type:code id: tags:
``` python
print(a)
```
%%%% Output: stream
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: stream
0 WORD_MEANING
%% Cell type:code id: tags:
``` python
inst = eurown.Instance()
print(inst)
```
%%%% Output: error
---------------------------------------------------------------------------
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
```
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment