Commit d4d42762 authored by Neeme Kahusk's avatar Neeme Kahusk
Browse files

Listid vaikimisi None

parent 0c05548f
......@@ -72,13 +72,13 @@ def format_polaris(level, field, value=None,
class Synset(object):
def __init__(self, number='', pos='n', variants=None,
internal_links=[], eq_links=[],
property_values=[]):
internal_links=None, eq_links=None,
properties=None):
self.pos = pos
self.variants = variants
self.internal_links = internal_links
self.eq_links = eq_links
self.property_values = property_values
self.variants = variants or []
self.internal_links = internal_links or []
self.eq_links = eq_links or []
self.properties = properties or []
self.number = number
# if id:
# self.id = '{}-{}'.format(id, self.pos)
......@@ -87,11 +87,8 @@ class Synset(object):
self.fieldname = 'WORD_MEANING'
def add_variant(self, variant):
if not self.variants:
self.variants = []
self.variants.append(variant)
def add_internal_link(self, internal_link):
self.internal_links.append(internal_link)
......@@ -136,6 +133,19 @@ class Synset(object):
return out
class Instance(Synset):
def __init__(self, number='', variants=None,
internal_links=None, eq_links=None,
property_values=None):
self.pos = 'pn'
self.variants = variants or []
self.internal_links = internal_links or []
self.eq_links = eq_links or []
self.property_values = property_values or []
self.number = number
self.fieldname = 'WORD_INSTANCE'
class Variant:
def __init__(self, lemma, sense,
......
%% 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)
```
%% Cell type:code id: tags:
``` python
>>> print(b)
```
%% Cell type:code id: tags:
``` python
>>> print(c)
```
%% Cell type:code id: tags:
``` python
>>> a.add_variant(c)
>>> print(a)
```
%% Cell type:code id: tags:
``` python
>>> a.variants[0].gloss = "elusorganism, mida tavaliselt iseloomustab \
vabatahtliku liikumise võime ja närvisüsteemi olemasolu"
>>> print(a)
```
%% Cell type:code id: tags:
``` python
d = eurown.Synset(44)
print(d)
```
%% 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)
```
%% Cell type:code id: tags:
``` python
snset = eurown.Synset()
print(snset)
```
%% Cell type:code id: tags:
``` python
inst = eurown.Instance()
print(inst)
```
%% Cell type:code id: tags:
``` python
aa = eurown.Variant('Aafrika',1)
inst.add_variant(aa)
print(inst)
```
%% Cell type:code id: tags:
``` python
```
......
Supports Markdown
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