Skip to content

Commit

Permalink
rename compiler methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmuhs committed Jan 18, 2025
1 parent 434d87a commit f1ab2f4
Show file tree
Hide file tree
Showing 32 changed files with 321 additions and 235 deletions.
20 changes: 13 additions & 7 deletions python/src/addons/CompletionDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def compile(self, *args):
Expand All @@ -22,8 +22,14 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self):
return call_deprecated_method("Compile", "compile", self.compile)

def Add(self):
return call_deprecated_method("Add", "add", self.add)
def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)
17 changes: 14 additions & 3 deletions python/src/addons/FloatVectorDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def Compile(self, *args):
def compile(self, *args):
if not args:
with nogil:
self.inst.get().Compile()
Expand All @@ -22,3 +22,14 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)
18 changes: 15 additions & 3 deletions python/src/addons/IntDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def Compile(self, *args):
def compile(self, *args):
if not args:
with nogil:
self.inst.get().Compile()
Expand All @@ -22,3 +22,15 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)

18 changes: 15 additions & 3 deletions python/src/addons/IntDictionaryCompilerSmallData.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def Compile(self, *args):
def compile(self, *args):
if not args:
with nogil:
self.inst.get().Compile()
Expand All @@ -22,3 +22,15 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)

18 changes: 15 additions & 3 deletions python/src/addons/JsonDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def Compile(self, *args):
def compile(self, *args):
if not args:
with nogil:
self.inst.get().Compile()
Expand All @@ -22,3 +22,15 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)

17 changes: 14 additions & 3 deletions python/src/addons/JsonDictionaryCompilerSmallData.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def Add(self, key , value ):
Expand All @@ -27,7 +27,7 @@
self.inst.get().Add(input_in_0, input_in_1)


def Compile(self, *args):
def compile(self, *args):
if not args:
with nogil:
self.inst.get().Compile()
Expand All @@ -37,3 +37,14 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)
17 changes: 14 additions & 3 deletions python/src/addons/KeyOnlyDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def Compile(self, *args):
def compile(self, *args):
if not args:
with nogil:
self.inst.get().Compile()
Expand All @@ -22,3 +22,14 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)
17 changes: 14 additions & 3 deletions python/src/addons/StringDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


def __setitem__(self, key, value):
self.Add(key, value)
self.add(key, value)


def __exit__(self, type, value, traceback):
self.Compile()
self.compile()


def Compile(self, *args):
def compile(self, *args):
if not args:
with nogil:
self.inst.get().Compile()
Expand All @@ -22,3 +22,14 @@
with nogil:
self.inst.get().Compile(progress_compiler_callback, callback)

def Compile(self, *args):
return call_deprecated_method("Compile", "compile", self.compile, *args)

def Add(self, *args):
return call_deprecated_method("Add", "add", self.add, *args)

def SetManifest(self, *args):
return call_deprecated_method("SetManifest", "set_manifest", self.set_manifest, *args)

def WriteToFile(self, *args):
return call_deprecated_method("WriteToFile", "write_to_file", self.write_to_file, *args)
14 changes: 7 additions & 7 deletions python/src/pxds/dictionary_compiler.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
void Compile() nogil # wrap-ignore
void Compile(callback_t, void*) nogil # wrap-ignore
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void WriteToFile(libcpp_utf8_string) except +
void WriteToFile(libcpp_utf8_string) except + # wrap-as:write_to_file

cdef cppclass IntDictionaryCompiler:
IntDictionaryCompiler() except +
Expand All @@ -31,7 +31,7 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
void Compile() nogil # wrap-ignore
void Compile(callback_t, void*) nogil # wrap-ignore
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void WriteToFile(libcpp_utf8_string) except +
void WriteToFile(libcpp_utf8_string) except + # wrap-as:write_to_file

cdef cppclass IntDictionaryCompilerSmallData:
IntDictionaryCompilerSmallData() except +
Expand All @@ -40,7 +40,7 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
void Compile() nogil # wrap-ignore
void Compile(callback_t, void*) nogil # wrap-ignore
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void WriteToFile(libcpp_utf8_string) except +
void WriteToFile(libcpp_utf8_string) except + # wrap-as:write_to_file

cdef cppclass KeyOnlyDictionaryCompiler:
KeyOnlyDictionaryCompiler() except +
Expand All @@ -49,7 +49,7 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
void Compile() nogil # wrap-ignore
void Compile(callback_t, void*) nogil # wrap-ignore
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void WriteToFile(libcpp_utf8_string) except +
void WriteToFile(libcpp_utf8_string) except + # wrap-as:write_to_file

cdef cppclass JsonDictionaryCompiler:
JsonDictionaryCompiler() except +
Expand All @@ -58,7 +58,7 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
void Compile() nogil # wrap-ignore
void Compile(callback_t, void*) nogil # wrap-ignore
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void WriteToFile(libcpp_utf8_string) except +
void WriteToFile(libcpp_utf8_string) except + # wrap-as:write_to_file

cdef cppclass JsonDictionaryCompilerSmallData:
JsonDictionaryCompilerSmallData() except +
Expand All @@ -67,7 +67,7 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
void Compile() nogil # wrap-ignore
void Compile(callback_t, void*) nogil # wrap-ignore
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void WriteToFile(libcpp_utf8_string) except +
void WriteToFile(libcpp_utf8_string) except + # wrap-as:write_to_file

cdef cppclass StringDictionaryCompiler:
StringDictionaryCompiler() except +
Expand All @@ -76,7 +76,7 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
void Compile() nogil # wrap-ignore
void Compile(callback_t, void*) nogil # wrap-ignore
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void WriteToFile(libcpp_utf8_string) except +
void WriteToFile(libcpp_utf8_string) except + # wrap-as:write_to_file

cdef cppclass SecondaryKeyCompletionDictionaryCompiler:
SecondaryKeyCompletionDictionaryCompiler(libcpp_vector[libcpp_utf8_string] secondary_keys) except +
Expand Down
8 changes: 4 additions & 4 deletions python/tests/completion/forward_backward_completion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

def test_forward_backward_completion():
c = CompletionDictionaryCompiler({"memory_limit_mb":"10"})
c.Add("bayern munich vs. real madrid", 80)
c.Add("munich vs. real madrid", 30)
c.add("bayern munich vs. real madrid", 80)
c.add("munich vs. real madrid", 30)

c_bw = CompletionDictionaryCompiler({"memory_limit_mb":"10"})
c_bw.Add("bayern munich vs. real madrid"[::-1], 80)
c_bw.Add("munich vs. real madrid"[::-1], 30)
c_bw.add("bayern munich vs. real madrid"[::-1], 80)
c_bw.add("munich vs. real madrid"[::-1], 30)

with tmp_dictionary(c, 'fw_bw_completion.kv') as d:
with tmp_dictionary(c_bw, 'fw_bw_completion_bw.kv') as d2:
Expand Down
Loading

0 comments on commit f1ab2f4

Please sign in to comment.