@Test public void testLoadException() throws Exception { SharedOpenNLPModel m = new SharedOpenNLPModel(); try { m.loadModel(SentenceModel.class, OpenNLP.class.getResourceAsStream("en_token.bin")); fail("Should have thrown an exception on loading invalid class"); } catch (BaleenException be) { } try { m.loadModel(TokenizerModel.class, OpenNLP.class.getResourceAsStream("missing.bin")); fail("Should have thrown an exception on loading invalid file"); } catch (BaleenException be) { } }
public void loadModel(Class<? extends BaseModel> modelClazz, InputStream model) throws BaleenException { if (this.model != null) { return; } try { this.model = modelClazz.getDeclaredConstructor(InputStream.class).newInstance(model); } catch (Exception e) { throw new BaleenException("Unable to construct model", e); } }
SharedOpenNLPModel extends BaleenResource { public void loadModel(Class<? extends BaseModel> modelClazz, InputStream model) throws BaleenException { if (this.model != null) { return; } try { this.model = modelClazz.getDeclaredConstructor(InputStream.class).newInstance(model); } catch (Exception e) { throw new BaleenException("Unable to construct model", e); } } }
SharedOpenNLPModel extends BaleenResource { public void loadModel(Class<? extends BaseModel> modelClazz, InputStream model) throws BaleenException { if (this.model != null) { return; } try { this.model = modelClazz.getDeclaredConstructor(InputStream.class).newInstance(model); } catch (Exception e) { throw new BaleenException("Unable to construct model", e); } }  }
SharedOpenNLPModel extends BaleenResource { public void loadModel(Class<? extends BaseModel> modelClazz, InputStream model) throws BaleenException { if (this.model != null) { return; } try { this.model = modelClazz.getDeclaredConstructor(InputStream.class).newInstance(model); } catch (Exception e) { throw new BaleenException("Unable to construct model", e); } }  void loadModel(Class<? extends BaseModel> modelClazz, InputStream model); BaseModel getModel(); }
SharedOpenNLPModel extends BaleenResource { public void loadModel(Class<? extends BaseModel> modelClazz, InputStream model) throws BaleenException { if (this.model != null) { return; } try { this.model = modelClazz.getDeclaredConstructor(InputStream.class).newInstance(model); } catch (Exception e) { throw new BaleenException("Unable to construct model", e); } }  void loadModel(Class<? extends BaseModel> modelClazz, InputStream model); BaseModel getModel();  }