/** * Initializes the current instance with a language detector model. Default feature * generation is used. * * @param model the language detector model */ public LanguageDetectorME(LanguageDetectorModel model) { this.model = model; this.mContextGenerator = model.getFactory().getContextGenerator(); }
@Test public void testDummyFactoryContextGenerator() throws Exception { LanguageDetectorContextGenerator cg = model.getFactory().getContextGenerator(); String[] context = cg.getContext( "a dummy text phrase to test if the context generator works!!!!!!!!!!!!"); Set<String> set = new HashSet(Arrays.asList(context)); Assert.assertTrue(set.contains("!!!!!")); // default normalizer would remove the repeated ! Assert.assertTrue(set.contains("a dum")); Assert.assertTrue(set.contains("tg=[THE,CONTEXT,GENERATOR]")); }
@Test public void testCorrectFactory() throws IOException { byte[] serialized = LanguageDetectorMETest.serializeModel(model); LanguageDetectorModel myModel = new LanguageDetectorModel(new ByteArrayInputStream(serialized)); Assert.assertTrue(myModel.getFactory() instanceof DummyFactory); }
@Test public void testDummyFactory() throws Exception { byte[] serialized = LanguageDetectorMETest.serializeModel(model); LanguageDetectorModel myModel = new LanguageDetectorModel(new ByteArrayInputStream(serialized)); Assert.assertTrue(myModel.getFactory() instanceof DummyFactory); }
/** * Initializes the current instance with a language detector model. Default feature * generation is used. * * @param model the language detector model */ public LanguageDetectorME(LanguageDetectorModel model) { this.model = model; this.mContextGenerator = model.getFactory().getContextGenerator(); }
/** * Initializes the current instance with a language detector model. Default feature * generation is used. * * @param model the language detector model */ public LanguageDetectorME(LanguageDetectorModel model) { this.model = model; this.mContextGenerator = model.getFactory().getContextGenerator(); }