diff --git a/contextionary/core/wordlist.go b/contextionary/core/wordlist.go index 1e21e1f..48caa75 100644 --- a/contextionary/core/wordlist.go +++ b/contextionary/core/wordlist.go @@ -101,7 +101,7 @@ func (w *Wordlist) FindIndexByWord(_needle string) ItemIndex { var bytes_needle = []byte(needle) var low ItemIndex = 0 - var high ItemIndex = ItemIndex(w.numberOfWords) + var high ItemIndex = ItemIndex(w.numberOfWords) - 1 for low <= high { var midpoint ItemIndex = (low + high) / 2 diff --git a/tools/native_build_contextionary.sh b/tools/native_build_contextionary.sh new file mode 100755 index 0000000..d637cab --- /dev/null +++ b/tools/native_build_contextionary.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +#Download contextionary +LANGUAGE=en +MODEL_VERSION=0.16.0 +./tools/download_contextionary.sh "$LANGUAGE" "$MODEL_VERSION" + +#Build the server +VERSION=1.2.0 +CGO_ENABLED=1 go build -o ./contextionary-server -a -tags netgo -ldflags "-w -X main.Version=$VERSION" ./server + +#Generate contextionary +tools/dev/gen_simple_contextionary.sh + +#Preprocess splitter dictionary +/bin/bash ./tools/preprocess_splitter_dict.sh "$LANGUAGE" "./data/contextionary.idx" + +#Copy files to Alpine image +cp ./contextionary-server $PWD + +#Set environment variables +export KNN_FILE=./data/contextionary.knn +export IDX_FILE=./data/contextionary.idx +export STOPWORDS_FILE=./data/stopwords.json +export COMPOUND_SPLITTING_DICTIONARY_FILE=./data/splitter_dict.csv + +#Run the server +./contextionary-server