Skip to content
GitLab
Menu
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
e099d1b1
Commit
e099d1b1
authored
Nov 16, 2016
by
Neeme Kahusk
Browse files
eurown algus Synset
parent
a809c402
Changes
1
Hide whitespace changes
Inline
Side-by-side
eurown.py
View file @
e099d1b1
...
...
@@ -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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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