;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "htk/htk-config")



#? *** htk_lm

;; dummy function that adds HTK C header files in C file
(eval `(de dummy_htk_lm () ,htk-cpheader-cmd ()))

#? * (dummy_htk_lm)
#? * (initlm)
#? * (createbongram <lm> <vocsize> <counts>)
#? * (creatematbigram <lm> <nw>)
#? * (getnentry <nglm> <ndx> <create>)
#? * (getlmprob <lm> <prid> <wdid>)
#? * (readlmodel <heap> <fn>)
#? * (writelmodel <lm> <fn> <flags>)
#? * (clearlmodel <lm>)

;; ********************************************************


(de InitLM (  )
    #{ InitLM(  );  #} 
    ()
)




(de CreateBoNGram (  lm  vocsize  counts )
    ((-gptr- "LModel *") lm) 
    ((-int-) vocsize) 
    ((-gptr- "int *") counts)  
    (gptr #{ CreateBoNGram(  $lm   ,$vocsize   ,$counts  )  #} )            ;; NGramLM *   -> gptr
)


(de CreateMatBigram (  lm  nw )
    ((-gptr- "LModel *") lm) 
    ((-int-) nw)  
    (gptr #{ CreateMatBigram(  $lm   ,$nw  )  #} )            ;; MatBiLM *   -> gptr
)


(de GetNEntry (  nglm  ndx  create )
    ((-gptr- "NGramLM *") nglm) 
    ((-gptr- "lmId *") ndx)                            ;; lmId (unsigned short ) -> int
    ((-int-) create)  
    (gptr #{ GetNEntry(  $nglm   ,$ndx   ,$create  )  #} )            ;; NEntry *   -> gptr
)


(de GetLMProb (  lm  prid  wdid )
    ((-gptr- "LModel *") lm) 
    ((-gptr- "NameCell **") prid) 
    ((-gptr- "NameCell *") wdid)  
    (double   #{ GetLMProb(  $lm   ,$prid   ,$wdid  )  #} )        ;; float -> double
)


(de ReadLModel (  heap  fn )
    ((-gptr- "MemHeap *") heap) 
    ((-gptr- "char *") fn)  
    (gptr #{ ReadLModel(  $heap   ,$fn  )  #} )            ;; LModel *   -> gptr
)


(de WriteLModel (  lm  fn  flags )
    ((-gptr- "LModel *") lm) 
    ((-gptr- "char *") fn) 
    ((-int-) flags)  
    #{ WriteLModel(  $lm   ,$fn   ,$flags  );  #} 
    ()
)


(de ClearLModel (  lm )
    ((-gptr- "LModel *") lm)  
    #{ ClearLModel(  $lm  );  #} 
    ()
)

;; ********************************************************

(dhc-make-with-libs () (list htk-libhtk)
  dummy_htk_lm
  initlm
  createbongram
  creatematbigram
  getnentry
  getlmprob
  readlmodel
  writelmodel
  clearlmodel
)
