def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'sym' wrd.save() sym = Sym() sym.parent = wrd sym.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'punct' wrd.save() punct = Punct() punct.parent = wrd punct.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'num' wrd.save() if self.form.is_valid(): num = self.form.save() num.parent = wrd num.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'part' wrd.save() if self.form.is_valid(): part = self.form.save() part.parent = wrd part.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'adv' wrd.save() if self.form.is_valid(): adv = self.form.save() adv.parent = wrd adv.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'sconj' wrd.save() if self.form.is_valid(): sconj = self.form.save() sconj.parent = wrd sconj.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'pron' wrd.save() if self.form.is_valid(): pron = self.form.save() pron.parent = wrd pron.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'x' wrd.save() if self.form.is_valid(): x = self.form.save() x.parent = wrd x.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'det' wrd.save() if self.form.is_valid(): det = self.form.save() det.parent = wrd det.save()
def save(self): wrd = Word() wrd.word = self.post.get('word') wrd.pos = 'intj' wrd.save() if self.form.is_valid(): intj = self.form.save() intj.parent = wrd intj.value_sym = ''.join( filter(lambda x: x not in '՛՜', self.post.get('word'))) intj.save()
def sync(self, drop=False): if drop: for _w in Word.objects.all(): if len(Punct.objects.filter(parent=_w)): _a = Punct.objects.filter(parent=_w)[0] _a.delete() _w.delete() for u_p, _ in self.punctuations: wrd = Word() wrd.word = u_p wrd.pos = 'punct' wrd.save() pnct = Punct() pnct.parent = wrd pnct.save()
def parse(self): attr = self.tpl.split('.') arr = [] if len(attr) == 3: if '|' in attr[-1]: conj = attr[-1].split('|')[0] root = attr[-1].split('|')[-1] m_conj = self.MAP_VERB.get(conj) if m_conj: for i in m_conj: l = 0 lemma = False form = i for j in m_conj[i]: type = j for k in range(len(m_conj[i][j])): c = m_conj[i][j][k] if len(m_conj[i][j]) == 6: demq = k % 3 + 1 elif len(m_conj[i][j]) == 2: demq = 2 else: demq = '' wrd = Word() wrd.pos = 'verb' wrd.word = c.format(root) if l == 1: wrd.lemma = lemma wrd.save() verb = Verb() verb.parent = wrd verb.root = root verb.type = form verb.form = type verb.quantity = int( k / (len(m_conj[i][j]) / 2)) + 1 if len( m_conj[i][j]) > 1 else '' verb.demq = demq verb.ending = conj verb.save() if l == 0: lemma = wrd l = 1
def sync(self, drop=False): if drop: for _w in Word.objects.all(): if len(Intj.objects.filter(parent=_w)): _a = Intj.objects.filter(parent=_w)[0] _a.delete() _w.delete() for intj in self.interjections: clean = ''.join(filter(lambda x: x not in '՛՜', list(intj))) try: Word.objects.get(word=clean) except: wrd = Word() wrd.word = clean wrd.pos = 'intj' wrd.save() pnct = Intj() pnct.parent = wrd pnct.value_sym = intj pnct.save()
def sync(self, drop=False): if drop: for _w in Word.objects.all(): if len(Adv.objects.filter(parent=_w)): _a = Adv.objects.filter(parent=_w)[0] _a.delete() _w.delete() dir_path = os.path.abspath(os.path.dirname(__file__)) csv_path = os.path.join(dir_path, '../', 'sync/hy_adj_adv.csv') with open(csv_path, 'r+', encoding='utf-8') as in_file: csvreader = csv.reader(in_file, delimiter=',') for row in csvreader: if isinstance(row, list) and len(row) == 2: wrd = Word() wrd.word = row[0] wrd.pos = 'adv' wrd.save() adv = Adv() adv.parent = wrd adv.lemma = row[0] adv.save()