def attr_vals(corpname, avattr, avpattern, avmaxitems=20): attr = manatee.findPosAttr(corpname, avattr) gen = attr.regexp2ids(".*%s.*" % avpattern.strip(), True) items = [] while not gen.end() and avmaxitems > 0: items.append(attr.id2str(gen.next())) avmaxitems -= 1 if not items: return "{query:'%s',suggestions:['%s']}" % (avpattern, "--nothing found--") return "{query:'%s',suggestions:[%s]}" % (avpattern, ",".join(["'" + item + "'" for item in items]))
def attr_vals(corpname, avattr, avpattern, avmaxitems=20): attr = manatee.findPosAttr(corpname, avattr) gen = attr.regexp2ids('.*%s.*' % avpattern.strip(), True) items = [] while not gen.end() and avmaxitems > 0: items.append(attr.id2str(gen.next())) avmaxitems -= 1 if not items: return "{query:'%s',suggestions:['%s']}" % (avpattern, '--nothing found--') return "{query:'%s',suggestions:[%s]}" % \ (avpattern, ','.join(["'" + item + "'" for item in items]))
def findPosAttr(self, corpname, attrname): return manatee.findPosAttr(corpname.split(':', 1)[0], attrname)
def findPosAttr(self, corpname: str, attrname: str) -> PosAttr: return manatee.findPosAttr(corpname.split(':', 1)[0], attrname)
def findPosAttr(self, corpname, attrname): return manatee.findPosAttr(corpname.split(":", 1)[0], attrname)