verbs_wordnet.py
1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/python
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from django.core.exceptions import ObjectDoesNotExist
from dictionary.models import Entry, POS
from semantics.views import location
import codecs
class Command(BaseCommand):
args = 'none'
help = ''
def handle(self, **options):
verbs_wordnet()
def verbs_wordnet():
with codecs.open('verbs_for_wordnet.txt', 'wt', 'utf-8') as outfile:
verb = POS.objects.get(tag='verb')
entries = Entry.objects.filter(pos=verb).order_by('name')
for entry in entries:
try:
lemma = entry.actual_lemma()
if lemma.status.priority == 100:
outfile.write(entry.name)
outfile.write('\n')
meanings = entry.meanings.filter(luid=-1)
if len(meanings) > 0:
for meaning in meanings:
outfile.write('\t')
outfile.write(meaning.base)
outfile.write('-')
outfile.write(meaning.sense)
outfile.write('\t')
outfile.write('{')
outfile.write(meaning.glossa)
outfile.write('}')
outfile.write('\t')
outfile.write('{')
outfile.write(location(meaning))
outfile.write('}')
outfile.write('\n')
except ObjectDoesNotExist:
continue