I've done this now for some other rules (English and German and those that extend an abstract rule). I suggest you change your affected rules to work like AvsAnRule: use a class like AvsAnData that keeps a static reference to the data. All rules that load data from disk are affected and should be modified for best performance.
On 2015-03-31 20:33, Daniel Naber wrote: > Hi, > > one of LT's common use cases is being run as a web service. A new > JLanguageTool object needs to be created for every request, as it's not > thread-safe. JLanguageTool then initializes the rules for the current > language. Some rules need to load data from disk (lists of words etc), > so this loading will happen for every HTTP request to the server, even > though the data is always the same. That's a waste of CPU power. > > I've now rewritten the English AvsAnRule like this: a new class > AvsAnData reads the data once and keeps it in static fields. AvsAnRule > accesses the data via static methods that will always return the same > data. I see three advantages of this approach: > > 1) Data that doesn't change is only loaded once -> better performance, > at least for short texts. > 2) There are no static fields in the rule itself. > 3) Loading the data is moved to its own class, which makes the rule > class shorter. > > You can see the simple new class which only loads and provides the data > here: > > https://github.com/languagetool-org/languagetool/blob/master/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/AvsAnData.java ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Languagetool-devel mailing list Languagetool-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/languagetool-devel