bindings-friso (empty) → 0.1.0.0
raw patch · 6 files changed
+412/−0 lines, 6 filesdep +basedep +bindings-DSLsetup-changed
Dependencies added: base, bindings-DSL
Files
- Bindings/Friso/Raw.hsc +189/−0
- Bindings/Friso/Raw/FrisoAPI.hsc +148/−0
- LICENSE +13/−0
- README.md +28/−0
- Setup.hs +2/−0
- bindings-friso.cabal +32/−0
+ Bindings/Friso/Raw.hsc view
@@ -0,0 +1,189 @@+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+#include <bindings.dsl.h>+#include <friso/friso.h>+module Bindings.Friso.Raw where+import Foreign.Ptr+#strict_import++import Bindings.Friso.Raw.FrisoAPI+{- typedef enum {+ __LEX_CJK_WORDS__ = 0,+ __LEX_CJK_UNITS__ = 1,+ __LEX_ECM_WORDS__ = 2,+ __LEX_CEM_WORDS__ = 3,+ __LEX_CN_LNAME__ = 4,+ __LEX_CN_SNAME__ = 5,+ __LEX_CN_DNAME1__ = 6,+ __LEX_CN_DNAME2__ = 7,+ __LEX_CN_LNA__ = 8,+ __LEX_STOPWORDS__ = 9,+ __LEX_ENPUN_WORDS__ = 10,+ __LEX_EN_WORDS__ = 11,+ __LEX_OTHER_WORDS__ = 15,+ __LEX_NCSYN_WORDS__ = 16,+ __LEX_PUNC_WORDS__ = 17,+ __LEX_UNKNOW_WORDS__ = 18+ } friso_lex_t; -}+#integral_t friso_lex_t+#num __LEX_CJK_WORDS__+#num __LEX_CJK_UNITS__+#num __LEX_ECM_WORDS__+#num __LEX_CEM_WORDS__+#num __LEX_CN_LNAME__+#num __LEX_CN_SNAME__+#num __LEX_CN_DNAME1__+#num __LEX_CN_DNAME2__+#num __LEX_CN_LNA__+#num __LEX_STOPWORDS__+#num __LEX_ENPUN_WORDS__+#num __LEX_EN_WORDS__+#num __LEX_OTHER_WORDS__+#num __LEX_NCSYN_WORDS__+#num __LEX_PUNC_WORDS__+#num __LEX_UNKNOW_WORDS__+{- typedef friso_hash_t * friso_dic_t; -}+#synonym_t friso_dic_t , <friso_hash_cdt>+{- typedef struct {+ uchar_t length;+ uchar_t rlen;+ uchar_t type;+ uchar_t ctrlMask;+ uint_t offset;+ fstring word;+ friso_array_t syn;+ friso_array_t pos;+ uint_t fre;+ } lex_entry_cdt; -}+#starttype lex_entry_cdt+#field length , CUChar+#field rlen , CUChar+#field type , CUChar+#field ctrlMask , CUChar+#field offset , CUInt+#field word , CString+#field syn , <friso_array_entry>+#field pos , <friso_array_entry>+#field fre , CUInt+#stoptype+{- typedef lex_entry_cdt * lex_entry_t; -}+#synonym_t lex_entry_t , <lex_entry_cdt>+{- typedef enum {+ FRISO_UTF8 = 0, FRISO_GBK = 1+ } friso_charset_t; -}+#integral_t friso_charset_t+#num FRISO_UTF8+#num FRISO_GBK+{- typedef struct {+ friso_dic_t dic; friso_charset_t charset;+ } friso_entry; -}+#starttype friso_entry+#field dic , <friso_hash_cdt>+#field charset , <friso_charset_t>+#stoptype+{- typedef friso_entry * friso_t; -}+#synonym_t friso_t , <friso_entry>+{- typedef enum {+ __FRISO_SIMPLE_MODE__ = 1, __FRISO_COMPLEX_MODE__ = 2+ } friso_mode_t; -}+#integral_t friso_mode_t+#num __FRISO_SIMPLE_MODE__+#num __FRISO_COMPLEX_MODE__+{- typedef struct {+ ushort_t max_len;+ ushort_t r_name;+ ushort_t mix_len;+ ushort_t lna_len;+ ushort_t add_syn;+ ushort_t clr_stw;+ ushort_t keep_urec;+ ushort_t spx_out;+ ushort_t en_sseg;+ ushort_t st_minl;+ uint_t nthreshold;+ friso_mode_t mode;+ char kpuncs[13];+ } friso_config_entry; -}+#starttype friso_config_entry+#field max_len , CUShort+#field r_name , CUShort+#field mix_len , CUShort+#field lna_len , CUShort+#field add_syn , CUShort+#field clr_stw , CUShort+#field keep_urec , CUShort+#field spx_out , CUShort+#field en_sseg , CUShort+#field st_minl , CUShort+#field nthreshold , CUInt+#field mode , <friso_mode_t>+#array_field kpuncs , CString+#stoptype+{- typedef friso_config_entry * friso_config_t; -}+#synonym_t friso_config_t , <friso_config_entry>+{- typedef struct {+ uchar_t type;+ uchar_t length;+ uchar_t rlen;+ char pos;+ int offset;+ char word[128];+ } friso_hits_entry; -}+#starttype friso_hits_entry+#field type , CUChar+#field length , CUChar+#field rlen , CUChar+#field pos , CString+#field offset , CInt+#array_field word , CString+#stoptype+{- typedef friso_hits_entry * friso_hits_t; -}+#synonym_t friso_hits_t , <friso_hits_entry>+{- typedef struct {+ fstring text;+ uint_t idx;+ uint_t length;+ uint_t bytes;+ uint_t unicode;+ uint_t ctrlMask;+ friso_link_t pool;+ string_buffer_t sbuf;+ friso_hits_t hits;+ char buffer[7];+ } friso_task_entry; -}+#starttype friso_task_entry+#field text , CString+#field idx , CUInt+#field length , CUInt+#field bytes , CUInt+#field unicode , CUInt+#field ctrlMask , CUInt+#field pool , <friso_link_entry>+#field sbuf , <string_buffer_entry>+#field hits , <friso_hits_entry>+#array_field buffer , CString+#stoptype+{- typedef friso_task_entry * friso_task_t; -}+#synonym_t friso_task_t , <friso_task_entry>+#ccall friso_new , IO (Ptr <friso_entry>)+#ccall friso_init_from_ifile , Ptr <friso_entry> -> Ptr <friso_config_entry> -> CString -> IO CInt+#ccall friso_free , Ptr <friso_entry> -> IO ()+#ccall friso_new_config , IO (Ptr <friso_config_entry>)+#ccall friso_init_config , Ptr <friso_config_entry> -> IO ()+#ccall friso_new_task , IO (Ptr <friso_task_entry>)+#ccall friso_free_task , Ptr <friso_task_entry> -> IO ()+#ccall friso_new_hits , IO (Ptr <friso_hits_entry>)+#ccall friso_set_text , Ptr <friso_task_entry> -> CString -> IO ()+#ccall friso_next , Ptr <friso_entry> -> Ptr <friso_config_entry> -> Ptr <friso_task_entry> -> IO (Ptr <friso_hits_entry>)+#ccall friso_dic_new , IO (Ptr <friso_hash_cdt>)+-- #ccall file_get_line , CString -> Ptr <struct _IO_FILE> -> IO CString+#ccall friso_dic_free , Ptr <friso_hash_cdt> -> IO ()+#ccall new_lex_entry , CString -> Ptr <friso_array_entry> -> CUInt -> CUInt -> CUInt -> IO (Ptr <lex_entry_cdt>)+#ccall free_lex_entry , Ptr <lex_entry_cdt> -> IO ()+#ccall friso_dic_load , Ptr <friso_entry> -> Ptr <friso_config_entry> -> Ptr <friso_lex_t> -> CString -> CUInt -> IO ()+#ccall friso_dic_load_from_ifile , Ptr <friso_entry> -> Ptr <friso_config_entry> -> CString -> CUInt -> IO ()+#ccall friso_dic_add , Ptr <friso_hash_cdt> -> Ptr <friso_lex_t> -> CString -> Ptr <friso_array_entry> -> IO ()+#ccall friso_dic_add_with_fre , Ptr <friso_hash_cdt> -> Ptr <friso_lex_t> -> CString -> Ptr <friso_array_entry> -> CUInt -> IO ()+#ccall friso_dic_match , Ptr <friso_hash_cdt> -> Ptr <friso_lex_t> -> CString -> IO CInt+#ccall friso_dic_get , Ptr <friso_hash_cdt> -> Ptr <friso_lex_t> -> CString -> IO (Ptr <lex_entry_cdt>)+#ccall friso_spec_dic_size , Ptr <friso_hash_cdt> -> Ptr <friso_lex_t> -> IO CUInt+#ccall friso_all_dic_size , Ptr <friso_hash_cdt> -> IO CUInt
+ Bindings/Friso/Raw/FrisoAPI.hsc view
@@ -0,0 +1,148 @@+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+#include <bindings.dsl.h>+#include <friso/friso_API.h>+module Bindings.Friso.Raw.FrisoAPI where+import Foreign.Ptr+#strict_import++{- typedef unsigned short ushort_t; -}+#synonym_t ushort_t , CUShort+{- typedef unsigned char uchar_t; -}+#synonym_t uchar_t , CUChar+{- typedef unsigned int uint_t; -}+#synonym_t uint_t , CUInt+{- typedef char * fstring; -}+#synonym_t fstring , CString+{- typedef struct {+ fstring buffer; uint_t length; uint_t allocs;+ } string_buffer_entry; -}+#starttype string_buffer_entry+#field buffer , CString+#field length , CUInt+#field allocs , CUInt+#stoptype+{- typedef string_buffer_entry * string_buffer_t; -}+#synonym_t string_buffer_t , <string_buffer_entry>+#ccall new_string_buffer_with_opacity , CUInt -> IO (Ptr <string_buffer_entry>)+#ccall new_string_buffer_with_string , CString -> IO (Ptr <string_buffer_entry>)+#ccall string_buffer_append , Ptr <string_buffer_entry> -> CString -> IO ()+#ccall string_buffer_append_char , Ptr <string_buffer_entry> -> CString -> IO ()+#ccall string_buffer_insert , (Ptr <string_buffer_entry>) -> CUInt -> CString -> IO ()+#ccall string_buffer_remove , Ptr <string_buffer_entry> -> CUInt -> CUInt -> IO CString+#ccall string_buffer_trim , Ptr <string_buffer_entry> -> IO (Ptr <string_buffer_entry>)+#ccall string_buffer_devote , Ptr <string_buffer_entry> -> IO CString+#ccall string_buffer_clear , Ptr <string_buffer_entry> -> IO ()+#ccall free_string_buffer , Ptr <string_buffer_entry> -> IO ()+{- typedef struct {+ fstring source;+ uint_t srcLen;+ fstring delimiter;+ uint_t delLen;+ uint_t idx;+ } string_split_entry; -}+#starttype string_split_entry+#field source , CString+#field srcLen , CUInt+#field delimiter , CString+#field delLen , CUInt+#field idx , CUInt+#stoptype+{- typedef string_split_entry * string_split_t; -}+#synonym_t string_split_t , <string_split_entry>+#ccall new_string_split , CString -> CString -> IO (Ptr <string_split_entry>)+#ccall string_split_reset , Ptr <string_split_entry> -> CString -> CString -> IO ()+#ccall string_split_set_source , Ptr <string_split_entry> -> CString -> IO ()+#ccall string_split_set_delimiter , Ptr <string_split_entry> -> CString -> IO ()+#ccall free_string_split , Ptr <string_split_entry> -> IO ()+#ccall string_split_next , Ptr <string_split_entry> -> CString -> IO CString+{- typedef struct {+ void * * items; uint_t allocs; uint_t length;+ } friso_array_entry; -}+#starttype friso_array_entry+#field items , Ptr (Ptr ())+#field allocs , CUInt+#field length , CUInt+#stoptype+{- typedef friso_array_entry * friso_array_t; -}+#synonym_t friso_array_t , <friso_array_entry>+#ccall new_array_list_with_opacity , CUInt -> IO (Ptr <friso_array_entry>)+#ccall free_array_list , Ptr <friso_array_entry> -> IO ()+#ccall array_list_add , Ptr <friso_array_entry> -> Ptr () -> IO ()+#ccall array_list_insert , Ptr <friso_array_entry> -> CUInt -> Ptr () -> IO ()+#ccall array_list_get , Ptr <friso_array_entry> -> CUInt -> IO (Ptr ())+#ccall array_list_set , Ptr <friso_array_entry> -> CUInt -> Ptr () -> IO (Ptr ())+#ccall array_list_remove , Ptr <friso_array_entry> -> CUInt -> IO (Ptr ())+#ccall array_list_trim , Ptr <friso_array_entry> -> IO (Ptr <friso_array_entry>)+#ccall array_list_clear , Ptr <friso_array_entry> -> IO (Ptr <friso_array_entry>)+{- struct friso_link_node {+ void * value;+ struct friso_link_node * prev;+ struct friso_link_node * next;+}; -}+#starttype struct friso_link_node+#field value , Ptr ()+#field prev , Ptr <struct friso_link_node>+#field next , Ptr <struct friso_link_node>+#stoptype+{- typedef struct friso_link_node link_node_entry; -}+#synonym_t link_node_entry , <struct friso_link_node>+{- typedef link_node_entry * link_node_t; -}+#synonym_t link_node_t , <struct friso_link_node>+{- typedef struct {+ link_node_t head; link_node_t tail; uint_t size;+ } friso_link_entry; -}+#starttype friso_link_entry+#field head , <struct friso_link_node>+#field tail , <struct friso_link_node>+#field size , CUInt+#stoptype+{- typedef friso_link_entry * friso_link_t; -}+#synonym_t friso_link_t , <friso_link_entry>+#ccall new_link_list , IO (Ptr <friso_link_entry>)+#ccall free_link_list , Ptr <friso_link_entry> -> IO ()+#ccall link_list_clear , Ptr <friso_link_entry> -> IO (Ptr <friso_link_entry>)+#ccall link_list_add , Ptr <friso_link_entry> -> Ptr () -> IO ()+#ccall link_list_insert_before , Ptr <friso_link_entry> -> CUInt -> Ptr () -> IO ()+#ccall link_list_get , Ptr <friso_link_entry> -> CUInt -> IO (Ptr ())+#ccall link_list_set , Ptr <friso_link_entry> -> CUInt -> Ptr () -> IO (Ptr ())+#ccall link_list_remove , Ptr <friso_link_entry> -> CUInt -> IO (Ptr ())+#ccall link_list_remove_node , Ptr <friso_link_entry> -> (Ptr <struct friso_link_node>) -> IO (Ptr ())+#ccall link_list_remove_first , Ptr <friso_link_entry> -> IO (Ptr ())+#ccall link_list_remove_last , Ptr <friso_link_entry> -> IO (Ptr ())+#ccall link_list_add_last , Ptr <friso_link_entry> -> Ptr () -> IO ()+#ccall link_list_add_first , Ptr <friso_link_entry> -> Ptr () -> IO ()+{- struct hash_entry {+ fstring _key; void * _val; struct hash_entry * _next;+}; -}+#starttype struct hash_entry+#field _key , CString+#field _val , Ptr ()+#field _next , Ptr <struct hash_entry>+#stoptype+{- typedef struct hash_entry friso_hash_entry; -}+#synonym_t friso_hash_entry , <struct hash_entry>+{- typedef friso_hash_entry * hash_entry_t; -}+#synonym_t hash_entry_t , <struct hash_entry>+#callback fhash_callback_fn_t , Ptr <struct hash_entry> -> IO ()+{- typedef struct {+ uint_t length;+ uint_t size;+ float factor;+ uint_t threshold;+ hash_entry_t * table;+ } friso_hash_cdt; -}+#starttype friso_hash_cdt+#field length , CUInt+#field size , CUInt+#field factor , CFloat+#field threshold , CUInt+#field table , Ptr <struct hash_entry>+#stoptype+{- typedef friso_hash_cdt * friso_hash_t; -}+#synonym_t friso_hash_t , <friso_hash_cdt>+#ccall new_hash_table , IO (Ptr <friso_hash_cdt>)+#ccall free_hash_table , Ptr <friso_hash_cdt> -> <fhash_callback_fn_t> -> IO ()+#ccall hash_put_mapping , Ptr <friso_hash_cdt> -> CString -> Ptr () -> IO ()+#ccall hash_exist_mapping , Ptr <friso_hash_cdt> -> CString -> IO CInt+#ccall hash_get_value , Ptr <friso_hash_cdt> -> CString -> IO (Ptr ())+#ccall hash_remove_mapping , Ptr <friso_hash_cdt> -> CString -> IO (Ptr <struct hash_entry>)
+ LICENSE view
@@ -0,0 +1,13 @@+Copyright 2014 cosmo0920++Licensed under the Apache License, Version 2.0 (the "License");+you may not use this file except in compliance with the License.+You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing, software+distributed under the License is distributed on an "AS IS" BASIS,+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+See the License for the specific language governing permissions and+limitations under the License.
+ README.md view
@@ -0,0 +1,28 @@+Binding-friso+===++[](https://travis-ci.org/cosmo0920/bindings-friso)++Low level Haskell binding for friso.++## dependencies++* friso+* hsc2hs++## export module(s)++* Bindings.Friso.Raw+* Bindings.Friso.Raw.FrisoAPI++## cbits++No longer provided, but example implementation exists under example. Perhaps you should implement yourself using this binding.++## dependent libraries++### friso++* [Friso](https://code.google.com/p/friso/)++friso中文分词器
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ bindings-friso.cabal view
@@ -0,0 +1,32 @@+-- Initial hs-Groonga.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: bindings-friso+version: 0.1.0.0+synopsis: Low level bindings for friso+description: Bindings to Friso <https://code.google.com/p/friso/>.+license: Apache-2.0+license-file: LICENSE+author: cosmo0920+maintainer: cosmo0920.wp@gmail.com+category: FFI+build-type: Simple+stability: Experimental+extra-source-files: README.md+cabal-version: >=1.10++library+ exposed-modules: Bindings.Friso.Raw+ Bindings.Friso.Raw.FrisoAPI+ build-depends: base >= 4.5 && < 5+ , bindings-DSL >= 1.0 && < 1.2+ hs-source-dirs: .+ build-tools: hsc2hs+ default-language: Haskell2010+ default-extensions: GeneralizedNewtypeDeriving+ ForeignFunctionInterface+ CPP+ extra-libraries: friso+source-repository head+ type: git+ location: git://github.com/cosmo0920/bindings-friso.git