/** * Loads the model from disk. * * @param path The location of model that was saved to disk * @throws ClassCastException if model is the wrong format * @throws IOException if the model file doesn't exist or is otherwise unavailable/incomplete * @throws ClassNotFoundException this would probably indicate a serious classpath problem */ public static BasicEntityExtractor load( String path, Class<? extends BasicEntityExtractor> entityClassifier, boolean preferDefaultGazetteer) throws ClassCastException, IOException, ClassNotFoundException { // load the additional arguments // try to load the extra file from the CLASSPATH first InputStream is = BasicEntityExtractor.class.getClassLoader().getResourceAsStream(path + ".extra"); // if not found in the CLASSPATH, load from the file system if (is == null) is = new FileInputStream(path + ".extra"); ObjectInputStream in = new ObjectInputStream(is); String gazetteerLocation = ErasureUtils.<String>uncheckedCast(in.readObject()); if (preferDefaultGazetteer) gazetteerLocation = DefaultPaths.DEFAULT_NFL_GAZETTEER; Set<String> annotationsToSkip = ErasureUtils.<Set<String>>uncheckedCast(in.readObject()); Boolean useSubTypes = ErasureUtils.<Boolean>uncheckedCast(in.readObject()); Boolean useBIO = ErasureUtils.<Boolean>uncheckedCast(in.readObject()); in.close(); is.close(); BasicEntityExtractor extractor = (BasicEntityExtractor) MachineReading.makeEntityExtractor(entityClassifier, gazetteerLocation); // load the CRF classifier (this works from any resource, e.g., classpath or file system) extractor.classifier = CRFClassifier.getClassifier(path); // copy the extra arguments extractor.annotationsToSkip = annotationsToSkip; extractor.useSubTypes = useSubTypes; extractor.useBIO = useBIO; return extractor; }
/* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { while (true) { try { MachineReading mr = bridge.take(); if (mr != null) { if (DEBUG) System.out.println(mr); data.addLast(new int[] {mr.getRawSeq(), mr.getReadingValInt()}); } } catch (IndexOutOfBoundsException ioobe) { } // try { // System.out.println("UltrasonicListener:"+MachineBridge.getInstance("ultrasonic").get(0)+" // elems:"+data.size()); // } catch(IndexOutOfBoundsException ioobe) {} } }