예제 #1
0
 def words1(self, h, options):
     langs = tt.F_ENGLISH + tt.F_FRENCH
     d = {}
     for lang in langs:
         d[lang] = []
     for leUid in self.leUids:
         le = h.leGet(leUid, options)
         lang = tt.featureGet(le.feat, tt.FT_LANG, langs[0])
         if d.has_key(lang):
             for leo in le.leos:
                 if leo.objname != self.objname: continue
                 word = leo.expword
                 if word not in d[lang]:
                     d[lang].append(word)
     r = ''
     first = 1
     for lang in langs:
         if len(d[lang]) == 0: continue
         if len(langs) > 1:
             if first: first = 0
             else: r = r + '; '
             r = r + '[' + featExpand(lang) + '] ' + string.join(
                 d[lang], ', ')
         else:
             r = r + string.join(d[lang], ', ')
     return r
예제 #2
0
def dumpdenotationtheta(h, out, word, con):
    for (sensenum, leo, lefeat) in word.senses:
        lang = tt.featureGet(lefeat, tt.FT_LANG, '')
        pos = tt.featureGet(lefeat, tt.FT_POS, '')
        gmt = langToGMt(lang)
        concept = '#$' + ttnameToCycName(leo.objname)
        obj = h.objGet(leo.objname)
        cycpos = ttPosToCycPos(pos)
        if cycpos == None:
            continue
        if leo.le.word == leo.expword:
            cycassert(out,
                      ['#$TT-denotation', con, cycpos,
                       str(sensenum), concept], gmt)
        for c in leo.feat:
            if tt.FEATDICT.has_key(c):
                pred = '#$TT-thetaRoleFeat-' + toPredName(tt.FEATDICT[c])
                cycassert(out, [pred, con, cycpos, str(sensenum)], gmt)
        for theta in leo.thetas:
            slotnum = str(theta.slotnum)
            case = '#$' + ttnameToCycName(theta.case)
            if theta.leUid != '':
                t = leuid2citationForm(theta.leUid)
                if word != None:
                    word = '"' + t + '"'
                else:
                    word = '""'
            else:
                word = '""'
            trpos = '"' + theta.trpos + '"'
            optional = str(theta.optional)
            selres = selrestrict(h, obj, theta.slotnum)
            for c in theta.subcat:
                if tt.FEATDICT.has_key(c):
                    pred = '#$TT-thetaRoleSubcat-' + toPredName(tt.FEATDICT[c])
                    cycassert(out, [pred, con, cycpos,
                                    str(sensenum), slotnum], gmt)
            cycassert(out, [
                '#$TT-thetaRole', con, cycpos,
                str(sensenum), concept, slotnum, case, selres, word, trpos,
                optional
            ], gmt)
예제 #3
0
파일: ttkb.py 프로젝트: plucena2/talkagent
def descendantWords(h,objname,langs):
  objs=descendants(h,objname)
  r=[]
  for objname in objs:
    obj=h.objGet(objname)
    if not obj: continue
    for leUid in obj.leUids:
      w=leUidToWord(leUid)
      f=leUidToFeat(leUid)
      if tt.featureGet(f, tt.FT_LANG, tt.F_NULL) in langs:
        if w not in r: r.append(w)
  return r
예제 #4
0
def dumpdenotationtheta(h, out, word, con):
    for (sensenum, leo, lefeat) in word.senses:
        lang = tt.featureGet(lefeat, tt.FT_LANG, "")
        pos = tt.featureGet(lefeat, tt.FT_POS, "")
        gmt = langToGMt(lang)
        concept = "#$" + ttnameToCycName(leo.objname)
        obj = h.objGet(leo.objname)
        cycpos = ttPosToCycPos(pos)
        if cycpos == None:
            continue
        if leo.le.word == leo.expword:
            cycassert(out, ["#$TT-denotation", con, cycpos, str(sensenum), concept], gmt)
        for c in leo.feat:
            if tt.FEATDICT.has_key(c):
                pred = "#$TT-thetaRoleFeat-" + toPredName(tt.FEATDICT[c])
                cycassert(out, [pred, con, cycpos, str(sensenum)], gmt)
        for theta in leo.thetas:
            slotnum = str(theta.slotnum)
            case = "#$" + ttnameToCycName(theta.case)
            if theta.leUid != "":
                t = leuid2citationForm(theta.leUid)
                if word != None:
                    word = '"' + t + '"'
                else:
                    word = '""'
            else:
                word = '""'
            trpos = '"' + theta.trpos + '"'
            optional = str(theta.optional)
            selres = selrestrict(h, obj, theta.slotnum)
            for c in theta.subcat:
                if tt.FEATDICT.has_key(c):
                    pred = "#$TT-thetaRoleSubcat-" + toPredName(tt.FEATDICT[c])
                    cycassert(out, [pred, con, cycpos, str(sensenum), slotnum], gmt)
            cycassert(
                out,
                ["#$TT-thetaRole", con, cycpos, str(sensenum), concept, slotnum, case, selres, word, trpos, optional],
                gmt,
            )
예제 #5
0
def dumpposinflections(h, out, word, con):
    for (infl, feat) in word.infls:
        lang = tt.featureGet(feat, tt.FT_LANG, "")
        pos = tt.featureGet(feat, tt.FT_POS, "")
        gmt = langToGMt(lang)
        cycpos = ttPosToCycPos(pos)
        if cycpos != None:
            cycassert(out, ["#$TT-posForms", con, cycpos], gmt)
        gender = tt.featureGet(feat, tt.FT_GENDER, "")
        person = tt.featureGet(feat, tt.FT_PERSON, "")
        number = tt.featureGet(feat, tt.FT_NUMBER, "")
        tense = tt.featureGet(feat, tt.FT_TENSE, "")
        mood = tt.featureGet(feat, tt.FT_MOOD, "")
        degree = tt.featureGet(feat, tt.FT_DEGREE, "")
        checked = tt.F_INFL_CHECKED in feat
        pred = "#$TT-infl" + featsToCyc(pos, gender, person, number, tense, mood, degree, checked)
        cycassert(out, [pred, con, '"' + infl + '"'], gmt)
예제 #6
0
파일: ttkb.py 프로젝트: plucena2/talkagent
def featExpand(feat):
  pos=tt.featureGet(feat,tt.FT_POS,tt.F_NULL)
  feat=stringElim(feat,'¸%@'+tt.FT_POS)
  if pos!=tt.F_NULL: feat=feat+pos
  r=[]
  for f in feat:
    if tt.FEATDICT.has_key(f):
      r.append(tt.FEATDICT[f])
  if pos==tt.F_NULL:
    return string.join(r,', ')
  if len(r)==0:
    return ''
  elif len(r)==1:
    return r[0]
  else:
    return string.join(r[:-1],', ')+' '+r[-1:][0]
예제 #7
0
def dumpposinflections(h, out, word, con):
    for (infl, feat) in word.infls:
        lang = tt.featureGet(feat, tt.FT_LANG, '')
        pos = tt.featureGet(feat, tt.FT_POS, '')
        gmt = langToGMt(lang)
        cycpos = ttPosToCycPos(pos)
        if cycpos != None:
            cycassert(out, ['#$TT-posForms', con, cycpos], gmt)
        gender = tt.featureGet(feat, tt.FT_GENDER, '')
        person = tt.featureGet(feat, tt.FT_PERSON, '')
        number = tt.featureGet(feat, tt.FT_NUMBER, '')
        tense = tt.featureGet(feat, tt.FT_TENSE, '')
        mood = tt.featureGet(feat, tt.FT_MOOD, '')
        degree = tt.featureGet(feat, tt.FT_DEGREE, '')
        checked = tt.F_INFL_CHECKED in feat
        pred = '#$TT-infl' + featsToCyc(pos, gender, person, number, tense,
                                        mood, degree, checked)
        cycassert(out, [pred, con, '"' + infl + '"'], gmt)
예제 #8
0
파일: ttkb.py 프로젝트: plucena/talkagent
 def words1(self,h,options):
   langs=tt.F_ENGLISH+tt.F_FRENCH
   d={}
   for lang in langs: d[lang]=[]
   for leUid in self.leUids:
     le=h.leGet(leUid, options)
     lang=tt.featureGet(le.feat,tt.FT_LANG,langs[0])
     if d.has_key(lang):
       for leo in le.leos:
         if leo.objname != self.objname: continue
         word=leo.expword
         if word not in d[lang]:
           d[lang].append(word)
   r=''
   first=1
   for lang in langs:
     if len(d[lang])==0: continue
     if len(langs)>1:
       if first: first=0
       else: r=r+'; '
       r=r+'['+featExpand(lang)+'] '+string.join(d[lang],', ')
     else:
       r=r+string.join(d[lang],', ')
   return r