Skip to content
This repository
tree: 3ba6b57c6d
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 148 lines (129 sloc) 4.796 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
from gstudio.models import *
from objectapp.models import *
from django.template.defaultfilters import slugify
import inflect


def get_lex_author(self):
         """
Generating lexicon file for authors-Proper name
"""
         author=self.authors.all()
         author_list=[]
         for each in author:
              author_each=str(each).capitalize()
              aut="pn_sg('"+author_each+"', '"+author_each+"', neutr)."
              author_list.append(aut)
         return author_list



def get_lex_GB(self):
    if self.ref.__class__.__name__ is 'Gbobject':
         a=[]
         title=self.title
         title_slug=slugify(title)
         
         alt=self.altnames
         alt_slug=slugify(alt)
         singular="pn_sg('"+title_slug.title()+"', '"+title_slug.title()+"', neutr)."
         a.append(singular)
         
         if alt:
           alts="pn_sg('"+str(alt_slug).title()+"', '"+str(alt_slug).title()+"', neutr)."
           a.append(alts)
         return a



def get_lex_RT(self):
     if self.ref.__class__.__name__ is 'Relationtype':
         p = inflect.engine()
         a=[]
         title=self.title
         st=str(title)
         rst=slugify(st)
         if '-' in rst:
           i=rst.index('-')
           j=i+1
           l=len(rst)
           ss=rst[j:l]
           lext = "adj_tr('"+rst+"', '"+rst+"', "+ss+")."
           a.append(lext)
           lex_p = "prep("+ss+", "+ss+")."
           a.append(lex_p)
         else:
           if rst[-1] == 's':
             rst_sing = p.singular_noun(rst)
             lex_tv = "tv_finsg("+rst+", "+rst_sing+")."
             a.append(lex_tv)
           else:
             lexa = "adj_tr('"+rst+"', '"+rst+"', -)."
             a.append(lexa)
         inverse=self.inverse
         if title!=inverse:
           sti=str(inverse)
           rsti=slugify(sti)
           if '-' in rsti:
             ii=rsti.index('-')
             ji=ii+1
             li=len(rsti)
             ssi=rsti[ji:li]
             lexi="adj_tr('"+rsti+"', '"+rsti+"', "+ssi+")."
             a.append(lexi)
             lex_pi = "prep("+ssi+", "+ssi+")."
             a.append(lex_pi)
           else:
            if rsti[-1] == 's':
              rsti_sing = p.singular_noun(rsti)
              lex_tvi = "tv_finsg("+rsti+", "+rsti_sing+")."
              a.append(lex_tvi)
            else:
              lexi_a = "adj_tr('"+rsti+"', '"+rsti+"', -)."
              a.append(lexi_a)
         return a


def get_lex_AT(self):
      if self.ref.__class__.__name__ is 'Attributetype':
         """Generates Lexicon entries for AT"""
         a=[]
         title = self.title
         st=str(title)
         rst=slugify(st)
         singular="noun_sg("+rst+", "+rst+", neutr)."
         a.append(singular)
         alt=self.altnames
         if alt:
           st_a=str(alt)
           rst_a=slugify(st_a)
           singular_a="noun_sg("+rst_a+", "+rst_a+", neutr)."
           a.append(singular_a)
         return a


def get_lex_MT(self):
    if self.ref.__class__.__name__ is 'Metatype':
         a=[]
         from django.template.defaultfilters import slugify
         title=self.title
         title_slug=slugify(title)
         plural=self.plural
         plural_slug=slugify(plural)
         alt=self.altnames
         alt_slug=slugify(alt)
         singular="noun_sg("+title_slug+", "+title_slug+", neutr)."
         a.append(singular)
         if plural:
           pl="noun_pl("+str(plural_slug)+", "+str(title_slug)+", neutr)."
           a.append(pl)
         if alt:
           alts="noun_sg("+str(alt_slug)+", "+str(alt_slug)+", neutr)."
           a.append(alts)
         return a



def get_lex_OT(self):
         """
Generating lexicon file for Objecttype-Noun singular, plural
"""
         a=[]
         title=self.title
         slug_title=slugify(title)
         plural=self.plural
         slug_plural=slugify(plural)
         alt=self.altnames
         slug_alt=slugify(alt)
         singular="noun_sg("+slug_title+", "+slug_title+", neutr)."
         a.append(singular)
         if plural:
            pl="noun_pl("+str(slug_plural)+", "+str(slug_title)+", neutr)."
            a.append(pl)
         if alt:
            alts="noun_sg("+str(slug_alt)+", "+str(slug_alt)+", neutr)."
            a.append(alts)
         
         return a
Something went wrong with that request. Please try again.