# Debian GNU/Linux irstlm completion
# Copyright 2013 Giulio Paci <giuliopaci@gmail.com>
# License LGPL-2.1+

_irstlm_get_cmds()
{
    echo "help ngram-split rm-start-end mdtsel build-lm sort-lm plsa.sh cswa goograms2ngrams lm-stat merge-sublm interpolate-lm tlm dict plsa score-lm dtsel build-sublm quantize-lm verify-caching build-lm-qsub ngt prune-lm split-dict add-start-end split-ngt compile-lm ";
}

_irstlm()
{
	local cur cmds

	COMPREPLY=()
	cur=${COMP_WORDS[$COMP_CWORD]}

	if [ $COMP_CWORD -eq 1 ]; then
	    cmds="$(_irstlm_get_cmds)"
	    COMPREPLY=( $(compgen -o filenames -W "$cmds" -- $cur) )
	elif [ $COMP_CWORD -eq 2 ] && [[ ${COMP_WORDS[1]}  = "help" ]]; then
	    cmds="$(_irstlm_get_cmds)"
	    COMPREPLY=( $(compgen -o filenames -W "$cmds" -- $cur) )
	elif [ $COMP_CWORD -ge 2 ] ; then
	    case ${COMP_WORDS[1]} in
	     	"mdtsel")
			    COMPREPLY=( $(compgen -o filenames -W "-v -i -o -s -x -w -j -m -f -n -d -c " -- $cur) )
			    ;;
	     	"build-lm")
			    COMPREPLY=( $(compgen -o filenames -W "-i --InputFile -o --OutputFile -k --Parts -n --NgramSize -d --Dictionary -s --LanguageModelType -p --PruneSingletons -f --PruneFrequencyThreshold -t --TmpDir -l --LogFile -u --uniform -b --boundaries -v --verbose -h -? --help " -- $cur) )
			    ;;
	     	"sort-lm")
			    COMPREPLY=( $(compgen -o filenames -W "-ilm -olm -tmpdir -inv " -- $cur) )
			    ;;
	     	"plsa.sh")
			    COMPREPLY=( $(compgen -o filenames -W "-c -d -f -m -n -i -t -p -k -r -s -l -v -c -d -m -n -u -o -i -t -l -k -v " -- $cur) )
			    ;;
	     	"cswa")
			    COMPREPLY=( $(compgen -o filenames -W "--Alignments= --DistBeta= --DistMean= --DistVar= --DistWin= --FixNullProb= --ForceModel= --Iterations= --M1iter= --MinVariance= --Model= --NormalizeVectors= --SrcData= --Threads= --TrainVariances= --TrgData= --TxtModel= --UseNullWord= --Verbosity= --Word2Vec= --al= --db= --dm= --dv= --dw= --fm= --fnp= --it= -m= --m1= --mv= --nv= --sd= --td= --th= --tv= --txt= --unw= -v= --w2v=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"goograms2ngrams")
			    COMPREPLY=( $(compgen -o filenames -W "--maxsize --startfrom --googledir --ngramdir --verbose " -- $cur) )
			    ;;
	     	"lm-stat")
			    COMPREPLY=( $(compgen -o filenames -W "--lm --txt " -- $cur) )
			    ;;
	     	"merge-sublm")
			    COMPREPLY=( $(compgen -o filenames -W "--size --sublm --lm --backoff " -- $cur) )
			    ;;
	     	"interpolate-lm")
			    COMPREPLY=( $(compgen -o filenames -W "--DictionaryUpperBound= -d= --debug= --dict_load_factor= --dub= -e= --eval= -l= --learn= --lev= --level= --memmap= --mm= --ngram_load_factor= -o= --order= -s= --score= --sentence=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"tlm")
			    COMPREPLY=( $(compgen -o filenames -W "-Help -h --AdaptLevel= --AdaptOOV= --AdaptOn= --AdaptRate= --Back-off= --Beta= --CheckProb= --ComputeLMSize= --Dictionary= --DictionaryUpperBound= --Interactive= --LanguageModelType= --LoadMixParam= --MaximumCachingLevel= --MemoryMap= --Ngram= --NgramSize= --OutProb= --PruneFrequencyThreshold= --PruneSingletons= --PruneThresh= --PruneTopSingletons= --SaveMixParam= --SavePerLevel= --SaveScaleFactor= --SetOovRate= --Statistics= --SubLMInfo= --TestOn= --TrainOn= --ad= --al= --ao= --ar= --beta= --bo= --cp= -d= --dub= -i= --lm= --lmp= --mcl= --memmap= --mm= -n= -o= --oARPA= --oASR= --oBIN= --oarpa= --oasr= --obin= --op= --or= -p= --pft= --ps= --pts= -s= --slmi= --smp= --spl= --ssf= --sz= --te= --tr=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"dict")
			    COMPREPLY=( $(compgen -o filenames -W "--Curve= --CurveSize= --Freq= --InputFile= --IntSymb= --ListOOV= --LoadFactor= --OutputFile= --PruneFreq= --PruneRank= --Size= --TestFile= -c= --cs= -f= -i= --is= --lf= -o= --oov= --pf= --pr= -s= --sort= -t=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"plsa")
			    COMPREPLY=( $(compgen -o filenames -W "--Dictionary= --ForceModel= --Iterations= --MemoryMap= --Model= --PruneFreq= --SpecialTopic= --Test= --Threads= --TmpDir= --TopWordsFile= --TopWordsNum= --TopicFeatures= --Topics= --Train= --WordFeatures= -d= --fm= --it= -m= --mm= --pf= --st= -t= --te= --tf= --th= --tmp= --tr= --twf= --twn= --wf=   --EXAMPLES= --(1) --Train --Example 3 --<d> --<d> --<d> --(2) --Infer --(3) --Infer  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"score-lm")
			    COMPREPLY=( $(compgen -o filenames -W "-lm -dub -level -mm --DictionaryUpperBound= --dub= --lev= --level= --lm= --memmap= --mm=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"dtsel")
			    COMPREPLY=( $(compgen -o filenames -W "--block-size= --bs= -c= --convergence-threshold= --cross-validation= --cv= --dictionary-upper-bound= --dub= -f= -i= --in-domain-file= --index= -m= --min-word-freq= --model= -n= --ngram-order= -o= --out-domain-file= -s= --score-file= -t= --test= -v= --verbose= -x=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"build-sublm")
			    COMPREPLY=( $(compgen -o filenames -W "--size --ngrams --sublm --freq-shift --witten-bell --shift-beta --improved-shift-beta --good-turing --stupid-backoff --prune-singletons -pft, --cross-sentence --verbose " -- $cur) )
			    ;;
	     	"quantize-lm")
			    COMPREPLY=( $(compgen -o filenames -W " --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"verify-caching")
			    COMPREPLY=( $(compgen -o filenames -W " --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"build-lm-qsub")
			    COMPREPLY=( $(compgen -o filenames -W "-i -o -k -n -t -p -u -q -s -b -d -v " -- $cur) )
			    ;;
	     	"ngt")
			    COMPREPLY=( $(compgen -o filenames -W "--AugmentFile= --ConvDict= --Dictionary= --DistCo= --FilterDict= --FilterTable= --FilterTableRate= --HistoMask= --InpLen= --InputFile= --InputGoogleFormat= --LmTable= --NgramSize= --OutputFile= --OutputGoogleFormat= --OutputRedisFormat= --SaveBinaryTable= --SaveEach= --SaveSingle= --SubDict= --aug= -b= --cd= -d= --dc= --fd= --ft= --ftlm= --ftr= --gooinp= --gooout= --hm= -i= --iknstat= --il= --lm= --memuse= -n= -o= --redisout= --saveeach= --sd= --ss= --tlm=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"prune-lm")
			    COMPREPLY=( $(compgen -o filenames -W "--abs= -t= --threshold=  --DEBUG_LEVEL= " -- $cur) )
			    ;;
	     	"split-dict")
			    COMPREPLY=( $(compgen -o filenames -W "--input --output --parts " -- $cur) )
			    ;;
	     	"add-start-end")
			    COMPREPLY=( $(compgen -o filenames -W "-r -t -s " -- $cur) )
			    ;;
	     	"compile-lm")
			    COMPREPLY=( $(compgen -o filenames -W "-d= --debug= --dict_load_factor= --dub= -e= --eval= -f= --filter= -i= --invert= --keepunigrams= --ku= -l= --level= --memmap= --mm= --ngram_load_factor= --ngramscore= --ns= -r= --randcalls= -s= --score= --sentence= -t= --text= --tmpdir=  --DEBUG_LEVEL= " -- $cur) )
			    ;;

		*)
		    ;;
	    esac
	fi

	return 0
}

complete -o bashdefault -o default -o nospace -F _irstlm irstlm


# vim:ft=sh:
