[libvoikko] The semantics of PATH argument for voikko_list_dicts()

Teemu Likonen tlikonen at iki.fi
Sun Feb 3 16:22:40 EET 2019


Hi!

After years I returned to Libvoikko's Common Lisp interface and
implemented a couple of more functions. However I am usure how
voikko_list_dicts() path argument is meant to work because it seems to
accept any kind of strings and always returns the list of dicts.

My current Common Lisp implementation actually combines the related C
functions into one Lisp function: voikko_list_dicts(),
voikko_dict_language(), voikko_dict_script(), voikko_dict_variant(),
voikko_dict_description(), voikko_free_dicts().

Here's an example session in Lisp's REPL:

    VOIKKO> (version)
    "4.1"
    VOIKKO> (list-dicts "")
    (((:LANGUAGE . "fi") (:SCRIPT . "") (:VARIANT . "standard")
      (:DESCRIPTION . "suomi (perussanasto)")))
    VOIKKO> (list-dicts "lksdjföalsfeaösdfa")
    (((:LANGUAGE . "fi") (:SCRIPT . "") (:VARIANT . "standard")
      (:DESCRIPTION . "suomi (perussanasto)")))
    VOIKKO> (list-dicts "/path/to/nowhere")
    (((:LANGUAGE . "fi") (:SCRIPT . "") (:VARIANT . "standard")
      (:DESCRIPTION . "suomi (perussanasto)")))

As you can see function's PATH argument doesn't seem to matter. How
should the PATH argument work? I'm using the default voikko-fi package
in Debian 9 without any custom dictionaries.

Below is my current LIST-DICTS implementation which uses CFFI library to
access foreign C functions and objects.


(defun list-dicts (&optional (path ""))
  (let ((dicts-ptr (foreign-funcall "voikko_list_dicts"
                                    :string path :pointer)))
    (when (proper-pointer-p dicts-ptr)
      (unwind-protect
           (loop :for i :upfrom 0
                 :for dict-ptr := (mem-aref dicts-ptr :pointer i)
                 :while (proper-pointer-p dict-ptr)
                 :collect
                 (list (cons :language (foreign-funcall
                                        "voikko_dict_language"
                                        :pointer dict-ptr :string))
                       (cons :script (foreign-funcall
                                      "voikko_dict_script"
                                      :pointer dict-ptr :string))
                       (cons :variant (foreign-funcall
                                       "voikko_dict_variant"
                                       :pointer dict-ptr :string))
                       (cons :description (foreign-funcall
                                           "voikko_dict_description"
                                           :pointer dict-ptr :string))))
        (foreign-funcall "voikko_free_dicts" :pointer dicts-ptr :void)))))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://lists.puimula.org/pipermail/libvoikko/attachments/20190203/549015f1/attachment.sig>


More information about the Libvoikko mailing list