@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
throws ResourceInitializationException { try { return getStopwords(SharedStopwordResource.StopwordList.valueOf(configuration)); } catch (IllegalArgumentException iae) { getMonitor() .info( "Value of {} does not match pre-defined list, assuming value is a file", configuration); getMonitor().debug("Unable to parse value of {} as StopwordList enum", configuration, iae); return getStopwords(f); } catch (IOException ioe) { throw new ResourceInitializationException( getMonitor().warn("Unable to load Stopword list, resorting to default list", ioe); return getStopwords();
@Override protected boolean doInitialize(ResourceSpecifier specifier, Map<String, Object> additionalParams) throws ResourceInitializationException { try { stopwords = loadStoplist("SmartStoplist.txt"); } catch (IOException ioe) { getMonitor().error("Unable to read default stop words from SmartStoplist.txt", ioe); throw new ResourceInitializationException(ioe); } return true; }
@Before public void beforeTest() throws Exception { ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription( "stopwords", SharedStopwordResource.class); ssr = new SharedStopwordResource(); ssr.initialize(erd.getResourceSpecifier(), Collections.emptyMap()); }
/** * Returns a lower case list of stopwords loaded by this resource, using the specified stopword * list */ public Collection<String> getStopwords(StopwordList list) throws IOException { if (list == StopwordList.FOX) { return loadStoplist("FoxStoplist.txt"); } else if (list == StopwordList.RANKS_NL) { return loadStoplist("RanksNlStoplist.txt"); } else if (list == StopwordList.LONG) { return loadStoplist("LongStoplist.txt"); } else if (list == StopwordList.MYSQL) { return loadStoplist("MySqlStoplist.txt"); } return stopwords; }
@After public void afterTest() throws Exception { ssr.destroy(); ssr = null; }
/** * Returns a lower case list of stopwords loaded by this resource, using the specified stopword * list */ public Collection<String> getStopwords(StopwordList list) throws IOException { if (list == StopwordList.FOX) { return loadStoplist("FoxStoplist.txt"); } else if (list == StopwordList.RANKS_NL) { return loadStoplist("RanksNlStoplist.txt"); } else if (list == StopwordList.LONG) { return loadStoplist("LongStoplist.txt"); } else if (list == StopwordList.MYSQL) { return loadStoplist("MySqlStoplist.txt"); } return stopwords; }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
throws ResourceInitializationException { try { return getStopwords(SharedStopwordResource.StopwordList.valueOf(configuration)); } catch (IllegalArgumentException iae) { getMonitor() .info( "Value of {} does not match pre-defined list, assuming value is a file", configuration); getMonitor().debug("Unable to parse value of {} as StopwordList enum", configuration, iae); return getStopwords(f); } catch (IOException ioe) { throw new ResourceInitializationException( getMonitor().warn("Unable to load Stopword list, resorting to default list", ioe); return getStopwords();
@Override protected boolean doInitialize(ResourceSpecifier specifier, Map<String, Object> additionalParams) throws ResourceInitializationException { try { stopwords = loadStoplist("SmartStoplist.txt"); } catch (IOException ioe) { getMonitor().error("Unable to read default stop words from SmartStoplist.txt", ioe); throw new ResourceInitializationException(ioe); } return true; }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); labelsAndFeatures = readLabelsAndFeaturesFromFile(labelsFile); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); MongoDatabase db = mongo.getDB(); documentsCollection = db.getCollection(documentCollectionName); labelsAndFeatures = readLabelsAndFeaturesFromFile(labelsFile); stopwords = stopwordResource.getStopwords(stoplist); }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); try { model = ParallelTopicModel.read(new File(modelPath)); pipe = new TopicModelPipe(stopwordResource.getStopwords(stoplist), model.getAlphabet()); topicWords = new TopicWords(model); } catch (Exception e) { throw new ResourceInitializationException(); } }
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); try { model = ParallelTopicModel.read(new File(modelPath)); pipe = new TopicModelPipe(stopwordResource.getStopwords(stoplist), model.getAlphabet()); topicWords = new TopicWords(model); } catch (Exception e) { throw new ResourceInitializationException(); } }
@Test public void testDefault() throws IOException { assertTrue(ssr.getStopwords().contains("the")); assertTrue(ssr.getStopwords(StopwordList.DEFAULT).contains("the")); }
@Test public void testBadCustom() throws IOException { try { ssr.getStopwords(new File("missing.txt")); fail("Expected exception not thrown"); } catch (IOException ioe) { // Do nothing, expected exception for missing file } } }
@Test public void testCustom() throws IOException { Collection<String> words = ssr.getStopwords(new File(getClass().getResource("exampleStoplist.txt").getPath())); assertTrue(words.contains("the")); assertFalse(words.contains("comment")); assertTrue(words.contains("test")); }
@Test public void testSmart() throws IOException { assertTrue(ssr.getStopwords(StopwordList.SMART).contains("the")); }