Entry.py
1.41 KB
#! /usr/bin/python
# -*- coding: utf-8 -*-
from Syntax import Syntax
from Meanings import Meanings
from Semantics import Semantics
from connections.models import Entry, POS, Status
class Entry:
def __init__(self, entry_tree, entry_meanings, meanings, frames):
self._base = entry_tree._children[0]._children[0]._content
self._pos = entry_tree._children[0]._children[1]._content
self._status = entry_tree._children[1]._children[0]._children[0]._content
print self._base
self._syntax = Syntax.fromTree(entry_tree._children[2])
if len(entry_tree._children) >= 7:
self._meanings = Meanings.fromTree(entry_tree._children[5])
self._semantics = Semantics.fromTree(self._base, self._pos, entry_tree._children[4], frames, self._meanings, self._syntax, entry_tree._children[6])
else:
self._meanings = None
self._semantics = None
def store(self):
pos = POS.objects.get(tag=self._pos)
status = Status.objects.get(key=self._status)
# @TODO: nie ma frequency w xml-u
entry = Entry(name=self._base, pos=pos, status=status, frequency_1M=None, frequency_300M=None)
entry.save()
syntax.store(entry)
if self._semantics is not None:
semantics.store(entry)
def __str__(self):
return self._pos + '(' + self._base + ',' + str(self._syntax) + ').'