LanguageDetector { public LanguageModel getLanguageModel() { return this.languageModel; } LanguageDetector();  LanguageDetector(LanguageModel model);   LanguageDetector(boolean fromJSON); WeightedLocale classify(String text); LanguageModel getLanguageModel(); static void main(String[] args); static final String LANGUAGE_MODEL_JSON; static final String LANGUAGE_MODEL_BINARY; }
@Test public void testLanguageModelReadWrite() throws IOException { final LanguageDetector det = new LanguageDetector(); final File out = folder.newFile("languagemodel.binary"); GZIPOutputStream os = new GZIPOutputStream(new FileOutputStream(out)); IOUtils.writeBinary(os, det.getLanguageModel()); os.flush(); os.close(); final InputStream is = new FileInputStream(out); final LanguageModel readModel = IOUtils.read(new GZIPInputStream(is), LanguageModel.class); final LanguageDetector newdet = new LanguageDetector(readModel); assertTrue(readModel.equals(det.getLanguageModel())); final String[] hindiStrings = new String[] { "\u092F\u0939 \u090F\u0915 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917 \u0939\u0948 \u0915\u093F \u092E\u0948\u0902 \u0939\u093F\u0902\u0926\u0940 \u092E\u0947\u0902 \u0932\u093F\u0916\u0928\u093E \u0939\u0948", "\u0924\u0947\u0939\u0930\u093E\u0928. \u0908\u0930\u093E\u0928 \u0915\u0947 \u0930\u093E\u0937\u094D\u091F\u094D\u0930\u092A\u0924\u093F \u092E\u0939\u092E\u0942\u0926 \u0905\u0939\u092E\u0926\u0940\u0928\u0947\u091C\u093E\u0926 \u0928\u0947 \u092C\u0941\u0927\u0935\u093E\u0930 \u0915\u094B \u0930\u093E\u0937\u094D\u091F\u094D\u0930 \u0915\u094B \u0938\u0902\u092C\u094B\u0927\u093F\u0924 \u0915\u0930\u0924\u0947 \u0939\u0941\u090F \u0915\u0939\u093E \u0915\u093F \u0908\u0930\u093E\u0928 \u092C\u092E \u0928\u0939\u0940\u0902 \u092C\u0928\u093E \u0930\u0939\u093E \u0939\u0948\u0964 \u092A\u0930\u092E\u093E\u0923\u0941 \u0915\u093E \u092E\u0924\u0932\u092C \u0938\u093F\u0930\u094D\u092B \u092C\u092E \u0939\u0940 \u0928\u0939\u0940\u0902 \u0939\u094B\u0924\u093E \u0939\u0948\u0964\u0905\u092E\u0947\u0930\u093F\u0915\u093E \u0914\u0930 \u0907\u091C\u0930\u093E\u0907\u0932 \u092A\u0930 \u0924\u0940\u0916\u093E \u092A\u094D\u0930\u0939\u093E\u0930 \u0915\u0930\u0924\u0947 \u0939\u0941\u090F \u0905\u0939\u092E\u0926\u0940\u0928\u0947\u091C\u093E\u0926 \u0928\u0947 \u0915\u0939\u093E \u0915\u093F \u0935\u094B \u0908\u0930\u093E\u0928\u0940 \u0935\u0948\u091C\u094D\u091E\u093E\u0928\u093F\u0915\u094B\u0902 \u0915\u094B \u0907\u0938\u0932\u093F\u090F \u092E\u093E\u0930 \u0930\u0939\u0947 \u0939\u0948\u0902 \u0915\u094D\u092F\u094B\u0902\u0915\u093F \u0935\u094B \u0928\u0939\u0940\u0902 \u091A\u093E\u0939\u0924\u0947 \u0915\u093F \u0915\u094B\u0908 \u0914\u0930 \u092E\u0941\u0932\u094D\u0915 \u0906\u0917\u0947 \u092C\u0922\u093C\u0947\u0964 \u0939\u092E\u093E\u0930\u0947 \u0935\u0948\u091C\u094D\u091E\u093E\u0928\u093F\u0915\u094B\u0902 \u0928\u0947 \u0907\u0938 \u0909\u092A\u0932\u092C\u094D\u0927\u093F \u0915\u094B \u0939\u093E\u0938\u093F\u0932 \u0915\u0930\u0928\u0947 \u092E\u0947\u0902 \u092C\u0939\u0941\u0924 \u092E\u0947\u0939\u0928\u0924 \u0915\u0940 \u0939\u0948\u0964" }; assertLanguage(newdet, hindiStrings, new Locale("hi")); }