Back to LanguageTool Homepage - Privacy - Imprint

Chinese part development daily record

(Ze Dang) #82

Add link above. You should download and copy it to the path which is the same as word_trigram.binary.

(Daniel Naber) #83

Okay, it’s working now I think. It’s slow only because of the one-time setup, isn’t it? Have you checked the performance per sentence (e.g in “sentences per second”), not considering the setup time?

(Ze Dang) #84

Set up: about 7s.
Check: about 120 sentences per second.

(Ze Dang) #85

GSoC Phase 3


  • Make ChineseNgramProbabilityRule available for zh-TW.
  • Optimaze the checking speed of the rule and lower memory usage.
  • Fix bugs.

(Daniel Naber) #86

What about memory usage, are you working on lowering that?

(Ze Dang) #87


(Daniel Naber) #88

Great - please also remember to post short but daily reports here.

(Ze Dang) #89

Hi, dnaber

I have make a comparison for my new rule with Lucene Based solution and BerkeleyLM Based solustion.

Name Rule Setup Time Sec per sentence Memory Usage Ngram Data Size
Lucene 8s 4s 2G 3.65G(Lucene index)
BerkerleyLM 3s 0.1s 4G 1.7G(hash based LM binary)

(Daniel Naber) #90

What kind of hard disk did you use for this test? An SSD?

(Ze Dang) #91

SSD. I trained language model again to improve accuracy and find a bug in my test code. The bug is that I actived ChineseNgramProbabilityRule in SimplifiedChinese then I created an instance of ChineseNgramProbabilityRule again. So the memory loads ngram data twice that it takes 8G to run.
After I fixed the bug, I can run java -jar languagetool-commandline -l zh-CN <text> without -Xmx8000m.

(Daniel Naber) #92

How often are you running a lookup per sentence? I just wonder that Lucene is that much slower than BerkeleyLM.

(Ze Dang) #93

In order to find each right character in the sentence, the rule will replace every char with chars in a confusion dictionary and calculate the prob of that sentence.(The right sentence is regarded as the max prob one.) So the longer the sentence is, the more query runs.

(Ze Dang) #94

July 28th

  • Ngram Rule supports zh-TW now.

As I have said above, in order to find the replacement of error characters in my ngram rule, we can’t avoid quering. Unlike Enligh language which has only 26 characters, Chinese language has more than 7000 characters. So the size of query table is totally different.

I tried to make Lucene based way to run faster. But it turns that the fastest speed is 1800ms per sentence while Berkeley one is 80ms per sentence. Also I tried to train a smaller language model to make Berkeley one use fewer memory. However, results showed that though a smaller LM can reduce the memory usage, it greatly decreased checking accurancy.

What’s your idea?

(Daniel Naber) #95

I see. BerkeleyLM’s memory use might make it difficult to get this into production. Could you have both versions in the code, so one can switch between them (doesn’t need to be at runtime, a small code switch would be enough)?

(Daniel Naber) #96

Ping… did you see my reply? I’d prefer if you could send a short daily report…

(Ze Dang) #97

Sorry. I have added swich feature. I am writing tests to evaluate the whole system now. Find resources, preprocess the data set and then writing codes.

(Daniel Naber) #98

When running with -adl (language auto detection), I get this error:

Exception in thread "main" java.lang.IllegalStateException: A language profile for language zh-CN was added already!
	at com.optimaize.langdetect.LanguageDetectorBuilder.withProfile(
	at com.optimaize.langdetect.LanguageDetectorBuilder.withProfiles(
	at org.languagetool.language.LanguageIdentifier.<init>(
	at org.languagetool.commandline.Main.detectLanguageOfString(
	at org.languagetool.commandline.Main.runOnFile(
	at org.languagetool.commandline.Main.main(

Could you see if you can fix this?

(Ze Dang) #99

Fixed now. I have modified some codes(github) in to make it work.

(Daniel Naber) #100

Thanks for the fast fix. still seems to have a hard coded path (C:\Dev\ngramDemo\data\test\index) so the tests fail for me, could you fix that, too?

(Ze Dang) #101

Yes. And I haven’t uploaded Lucene Index data. So you could not run the rule now.