word completion in the C runtime now returns multi-word expressions and the category for every expression

This commit is contained in:
kr.angelov
2013-08-19 15:34:19 +00:00
parent 043ab3e07a
commit 2d4f17e30c
4 changed files with 67 additions and 35 deletions

View File

@@ -920,9 +920,10 @@ Iter_fetch_token(IterObject* self)
if (tp == NULL)
return NULL;
PyObject* ty_tok = gu2py_string(tp->tok);
PyObject* res = Py_BuildValue("(f,O)", tp->prob, ty_tok);
Py_DECREF(ty_tok);
PyObject* py_tok = gu2py_string(tp->tok);
PyObject* py_cat = gu2py_string(tp->cat);
PyObject* res = Py_BuildValue("(f,O,O)", tp->prob, py_tok, py_cat);
Py_DECREF(py_tok);
return res;
}

View File

@@ -24,7 +24,7 @@ class Completer():
if state == 0:
line = readline.get_line_buffer()
line = line[0:readline.get_begidx()]
self.i = source_lang.getCompletions(line, prefix=prefix)
self.i = source_lang.complete(line, prefix=prefix)
self.tokens = sets.Set()
if len(self.tokens) > 50:
@@ -32,7 +32,7 @@ class Completer():
while True:
try:
(p,t) = self.i.next()
(p,t,c) = self.i.next()
if t not in self.tokens:
self.tokens.add(t)
return t