Views
No views yet
nl_core_news_sm:.arpa files as well as more efficient KenLM binary files (.arpa.bin) are provided. You probably want to use the binary versions.1pip install huggingface_hub
2pip install https://github.com/kpu/kenlm/archive/master.zip
3
4# If you want to use spaCy preprocessing
5pip install spacy
6python -m spacy download nl_core_news_sm1import kenlm
2from huggingface_hub import hf_hub_download
3
4model_file = hf_hub_download(repo_id="BramVanroy/kenlm_sonar", filename="kenlm_sonar_token.arpa.bin")
5model = kenlm.Model(model_file)
6
7text = "Ik eet graag koekjes !" # pre-tokenized
8model.perplexity(text)
9# 148.219963736891341import kenlm
2import spacy
3from huggingface_hub import hf_hub_download
4
5model_file = hf_hub_download(repo_id="BramVanroy/kenlm_sonar", filename="kenlm_sonar_pos.arpa.bin") # pos file
6model = kenlm.Model(model_file)
7
8nlp = spacy.load("nl_core_news_sm")
9
10text = "Ik eet graag koekjes!"
11pos_sequence = " ".join([token.pos_ for token in nlp(text)])
12# 'PRON VERB ADV NOUN PUNCT'
13model.perplexity(pos_sequence)
14# 6.916279238079976bin/lmplz -o 5 -S 75% -T ../data/tmp/ < ../data/processed_sonar_token_dedup.txt > ../data/kenlm_sonar_token.arpa--discount_fallback was used and the parsed data was not deduplicated (but it was deduplicated on the sentence-level for token and lemma models).