You should be able to do this without modifying the code. There are at least two ways -- Create a file with lines containing </s> and <s> and give this file to ngram-count using -nonevents. Alternately, you can create count files first (-write), remove the uninteresting events and create an lm using the count file (-read). &