Commit ea719d88a4d40dac9b72df1b24a78276ebb37e60

Authored by Tomasz Bartosiak
1 parent a9e3ece4

lista czasowników i znaczeń dla Słowosieci

semantics/management/commands/verbs_wordnet.py 0 → 100644
  1 +#! /usr/bin/python
  2 +# -*- coding: utf-8 -*-
  3 +
  4 +from django.core.management.base import BaseCommand
  5 +
  6 +from django.core.exceptions import ObjectDoesNotExist
  7 +from dictionary.models import Entry, POS
  8 +from semantics.views import location
  9 +import codecs
  10 +
  11 +
  12 +class Command(BaseCommand):
  13 + args = 'none'
  14 + help = ''
  15 +
  16 + def handle(self, **options):
  17 + verbs_wordnet()
  18 +
  19 +
  20 +def verbs_wordnet():
  21 + with codecs.open('verbs_for_wordnet.txt', 'wt', 'utf-8') as outfile:
  22 + verb = POS.objects.get(tag='verb')
  23 + entries = Entry.objects.filter(pos=verb).order_by('name')
  24 + for entry in entries:
  25 + try:
  26 + lemma = entry.actual_lemma()
  27 + if lemma.status.priority == 100:
  28 + outfile.write(entry.name)
  29 + outfile.write('\n')
  30 + meanings = entry.meanings.filter(luid=-1)
  31 + if len(meanings) > 0:
  32 + for meaning in meanings:
  33 + outfile.write('\t')
  34 + outfile.write(meaning.base)
  35 + outfile.write('-')
  36 + outfile.write(meaning.sense)
  37 + outfile.write('\t')
  38 + outfile.write('{')
  39 + outfile.write(meaning.glossa)
  40 + outfile.write('}')
  41 + outfile.write('\t')
  42 + outfile.write('{')
  43 + outfile.write(location(meaning))
  44 + outfile.write('}')
  45 + outfile.write('\n')
  46 +
  47 + except ObjectDoesNotExist:
  48 + continue
... ...
semantics/views.py
... ... @@ -331,16 +331,16 @@ def create_units_context(lemma_id):
331 331  
332 332 def location(lexical_unit):
333 333 if lexical_unit.synset is None:
334   - return ""
  334 + return u""
335 335 if lexical_unit.luid >= 0:
336   - return ""
  336 + return u""
337 337 where = Synonymy.objects.filter(parent=lexical_unit.synset)
338 338 if len(where) > 0:
339   - return "synonim " + unicode(where[0].child)
  339 + return u"synonim " + unicode(where[0].child)
340 340 where = Hypernymy.objects.filter(parent=lexical_unit.synset)
341 341 if len(where) > 0:
342   - return "hiponim " + unicode(where[0].child)
343   - return "nieznana lokacja w Słowosieci"
  342 + return u"hiponim " + unicode(where[0].child)
  343 + return u"nieznana lokacja w Słowosieci"
344 344  
345 345 @ajax(method='get')
346 346 def ajax_predefined_preferences(request):
... ...