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

eurown algus Synset

parent a809c402
......@@ -5,14 +5,62 @@
This is the new eurown module.
"""
def format_polaris(level, field, value=None,
record=None, quot=True,
ident=2):
"""Format Polaris export line
>>> format_polaris(0, 'WORD_MEANING', record=222)
'0 @222@ WORD_MEANING'
>>> format_polaris(3, 'DEFINITION', 'This is the definition')
' 3 DEFINITION "This is the definition"'
"""
if record:
out = ident*level*' ' + '{} @{}@ {}'.format(level, record, field)
return out
if value:
if quot:
out = ident*level*' ' + '{} {} "{}"'.format(level, field, value)
else:
out = ident*level*' ' + '{} {} {}'.format(level, field, value)
else:
out = ident*level*' ' + '{} {}'.format(level, field)
return out
class Synset:
def __init__(self, pos, variants,
internal_links, eq_links,
property_values):
ids = []
def __init__(self, id='', pos='n', variants=[],
internal_links=[], eq_links=[],
property_values=[]):
self.pos = pos
self.variants = variants
self.internal_links = internal_links
self.eq_links = eq_links
self.property_values = property_values
if not id:
self.id = '{}-{}'.format(1, self.pos)
# def __str__(self):
class Variant:
def __init__(self, lemma, sense,
gloss, examples):
self.lemma = lemma
self.sense = sense
self.gloss = gloss
self.examples = examples
class InternalLink:
def __init__(self, name=None):
self.name = name
if __name__ == '__main__':
print(format_polaris(0, 'WORD_MEANING', record=222))
import doctest
doctest.testmod()
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