Skip to content

Commit

Permalink
Merge pull request #232 from narekgharibyan/completions_hanging
Browse files Browse the repository at this point in the history
completions hanging
  • Loading branch information
narekgharibyan committed Apr 3, 2017
2 parents c43fb32 + 8b3d207 commit c37c073
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ final {
: fsa_(f),
priority_queue_(top_number_of_results) {
current_state_ = start_state;
if (0 == current_state_) {
at_end_ = true;
}

TRACE("BoundedWeightedStateTraverser starting with Start state %d", current_state_);
GetNextTransitionsInSortedOrder(0);
Expand Down Expand Up @@ -123,7 +126,7 @@ final {
void operator++(int) {

// ignore cases where we are already at the end
if (current_state_ == 0) {
if (at_end_) {
TRACE("end of traversal");
return;
}
Expand Down
6 changes: 4 additions & 2 deletions pykeyvi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,15 @@ def run(self):

PACKAGE_NAME = 'pykeyvi'

version = '0.2.2'

install_requires = [
'msgpack-python',
]

setup(
name=PACKAGE_NAME,
version='0.2.1',
version=version,
description='Python package for keyvi',
author='Hendrik Muhs',
author_email='hendrik.muhs@gmail.com',
Expand All @@ -238,7 +240,7 @@ def run(self):
ext_modules=ext_modules,
zip_safe=False,
url='https://github.com/cliqz/keyvi',
download_url='https://github.com/cliqz/keyvi/tarball/v0.2.1',
download_url='https://github.com/cliqz/keyvi/tarball/v{}'.format(version),
keywords=['FST'],
classifiers=[
'Programming Language :: C++',
Expand Down
13 changes: 12 additions & 1 deletion pykeyvi/tests/completion/multiword_completion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,15 @@ def test_overlong_completion():
assert len(matches) == 3
assert matches[0][1] == b'html disable'
assert matches[1][1] == b'html disabled'
assert matches[2][1] == b"html display=main&referer=3c6120640656e466f726e26616d703b726566657265723d336336313230363436313734363132643631366136313738336432373636363136633733363532373230363837323635363633643237326636363732363136643635326536613733373032373230373436393734366336353364323735333734363137323734373336353639373436353237336535333734363137323734373336353639373436353363326636313365323032363637373433623230336336313230363436313734363132643631366136313738336432373636363136633733363532373230363837323635363632303364323732663733363537323736366336353734326636363666373236353665336636663730363536653436366637323635366535343732363536353364333132363631366437303362363436393733373036633631373933643664363136393665323636313664373033623734363137323637363537343639363433643330323636313664373033623734363137323637363537343734373937303635336433303236363136643730336236333664363433643338333032373230373436393734366336353364323737613735373232363735373536643663336236333662323037613735373232303436366637323635366532363735373536643663336236323635373237333639363336383734323733653436366637323635366532363735373536643663336236323635373237333639363336383734336332663631336532303230323636373734336232303463363536383732363736313665363737333636366637323635366526616d703b616a61783d3126616d703b6d6f62696c653d3026616d703b706167653d3026616d703b6f70656e466f72656e547265653d3127203e204c65687267616e6773666f72656e3c2f613e20&openforentree=1&targetid=130&targettype=1&cmd=6&page=null&fromhistory=1"
assert matches[2][1] == b"html display=main&referer=3c6120640656e466f726e26616d703b726566657265723d336336313230363436313734363132643631366136313738336432373636363136633733363532373230363837323635363633643237326636363732363136643635326536613733373032373230373436393734366336353364323735333734363137323734373336353639373436353237336535333734363137323734373336353639373436353363326636313365323032363637373433623230336336313230363436313734363132643631366136313738336432373636363136633733363532373230363837323635363632303364323732663733363537323736366336353734326636363666373236353665336636663730363536653436366637323635366535343732363536353364333132363631366437303362363436393733373036633631373933643664363136393665323636313664373033623734363137323637363537343639363433643330323636313664373033623734363137323637363537343734373937303635336433303236363136643730336236333664363433643338333032373230373436393734366336353364323737613735373232363735373536643663336236333662323037613735373232303436366637323635366532363735373536643663336236323635373237333639363336383734323733653436366637323635366532363735373536643663336236323635373237333639363336383734336332663631336532303230323636373734336232303463363536383732363736313665363737333636366637323635366526616d703b616a61783d3126616d703b6d6f62696c653d3026616d703b706167653d3026616d703b6f70656e466f72656e547265653d3127203e204c65687267616e6773666f72656e3c2f613e20&openforentree=1&targetid=130&targettype=1&cmd=6&page=null&fromhistory=1"


def test_exact_match_without_completion():
c = pykeyvi.CompletionDictionaryCompiler({"memory_limit_mb": "10"})
c.Add("mr" + '\x1b' + "mr", 80)
c.Add("mozilla firefox" + '\x1b' + "mozilla firefox", 80)
c.Add("maa" + '\x1b' + "maa", 80)
with tmp_dictionary(c, 'test_exact_match_without_completion.kv') as d:
mw = pykeyvi.MultiWordCompletion(d)
for m in mw.GetCompletions("mr "):
assert m.GetMatchedString() == b'mr'

0 comments on commit c37c073

Please sign in to comment.