!pip install pynlpl
from pynlpl.lm.lm import SimpleLanguageModel
WARNING: The FoLiA library pynlpl.formats.folia is being used but this version is now deprecated and is replaced by FoLiAPy (pip install folia), see https://github.com/proycon/foliapy. Please update your software if you are a developer, if you are an end-user you can safely ignore this message.
lm = SimpleLanguageModel(3)
lm.append("test sentence one")
lm.append("also a test sentence")
lm.save("simple.lm")
!cat simple.lm
[simplelanguagemodel]
n=3
sentences=2
beginmarker=<begin>
endmarker=<end>
casesensitive=1

[freqlistN]
<begin> <begin> test	1
<begin> test sentence	1
test sentence one	1
sentence one <end>	1
one <end> <end>	1
<begin> <begin> also	1
<begin> also a	1
also a test	1
a test sentence	1
test sentence <end>	1
sentence <end> <end>	1
[freqlistNm1]
test sentence	2
<begin> test	1
sentence one	1
one <end>	1
<begin> also	1
also a	1
a test	1
sentence <end>	1