- 
                Notifications
    
You must be signed in to change notification settings  - Fork 18
 
Cache loading
        Pu Chen edited this page Oct 19, 2017 
        ·
        2 revisions
      
    If you have a big volume of message XML files, you can use the cached loading to accelerate the loading process. The very first time when you try to load messages for a certain language, the loaded message set will be stored into file cache. If you try to load the messages for that language again, Grammaticus will simply load from cache if the timestamp is recent.
private static final String SET_NAME = "sample";
private static final String MESSAGES = "labels.xml";
private static final String NAMES = "names.xml";
private static final String BASE_DIR = "src/test/resources/labels";
HumanLanguage ENGLISH_US = LanguageProviderFactory.get().getBaseLanguage();
GrammaticalLabelSetDescriptor gls = new LabelSetDescriptorImpl(dir, ENGLISH_US, SET_NAME, MESSAGES, NAMES);
GrammaticalLabelSetLoader loader = new GrammaticalLabelSetLoader(gls);
private static final String SET_NAME = "sample";
private static final String MESSAGES = "labels.xml";
private static final String NAMES = "names.xml";
private static final String BASE_DIR = "src/test/resources/labels";
HumanLanguage ENGLISH_US = LanguageProviderFactory.get().getBaseLanguage();
GrammaticalLabelSetDescriptor gls = new LabelSetDescriptorImpl(dir, ENGLISH_US, SET_NAME, MESSAGES, NAMES);
GrammaticalLabelSetLoader loader = GrammaticalLocalizerFactory.getLoader(gls, null);
The last parameter for cascade loading when you have more than one set of message files in different locations. It's null in the example code above since we only have one set.