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