def _pre_interact(self): try: import gf except ImportError: print "No autocompletion available" return pgf = gf.read_pgf(self.pgf_path) langs = [l for l in pgf.languages() if `l`[-3:] == self.lang] assert len(langs) == 1, "Cannot retrieve chosen pgf language." lang = langs[0] ip = __IPYTHON__ class myCompleter: def __init__(self, pgf, lang): self.pgf = pgf self.lang = lang def complete(self, text, state,line_buffer=None): # we need the whole line; only available from readline line = ip.readline.get_line_buffer() completions = self.pgf.complete(lang, line) try: return completions[state] except IndexError: return None ip.Completer = myCompleter(pgf,lang)
def test_parse(self): pgf = gf.read_pgf(self.pgf) l = gf.read_language(self.lang) for abs,cnc in self.lexed: rabs = exp2str(abs) ps = pgf.parse(cnc['eng'], l) self.failUnless(ps) pt = rmprefix(ps[0]) self.assertEqual(pt,rabs)
def setUp(self): self.samples = samples self.pgf = gf.read_pgf('Query.pgf') self.langs = dict([(lang2iso(l),l) for l in self.pgf.languages()])
def pgf(self, path=None): path = path or self.path return gf.read_pgf(path)
def setUp(self): self.samples = samples self.pgf = gf.read_pgf('Query.pgf') self.lang = gf.read_language('QueryEng')