/** * Instantiate the {@code LemmatizerFactory} according to the features * specified in the parameters properties file. * * @param params * the training parameters * @return the factory */ private final LemmatizerFactory getTrainerFactory( final TrainingParameters params) { LemmatizerFactory lemmatizerFactory = null; final String featureSet = Flags.getFeatureSet(params); if (featureSet.equalsIgnoreCase("chunk")) { try { lemmatizerFactory = LemmatizerFactory.create( LemmatizerFactory.class.getName()); } catch (final InvalidFormatException e) { e.printStackTrace(); } } else { try { lemmatizerFactory = LemmatizerFactory.create( LemmatizerFactory.class.getName()); } catch (final InvalidFormatException e) { e.printStackTrace(); } } return lemmatizerFactory; }
/** * Load a resource by resourceId. * @param serializerId the serializer id * @param artifactSerializers the serializers in which to put the resource * @param resourcePath the canonical path of the resource * @param featureGenDescriptor the feature descriptor * @param resources the map in which to put the resource */ public static void loadResource(String serializerId, @SuppressWarnings("rawtypes") Map<String, ArtifactSerializer> artifactSerializers, String resourcePath, byte[] featureGenDescriptor, Map<String, Object> resources) { File resourceFile = new File(resourcePath); if (resourceFile != null) { String resourceId = InputOutputUtils.normalizeLexiconName(resourceFile.getName()); ArtifactSerializer<?> serializer = artifactSerializers.get(serializerId); InputStream resourceIn = CmdLineUtil.openInFile(resourceFile); try { resources.put(resourceId, serializer.create(resourceIn)); } catch (InvalidFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { resourceIn.close(); } catch (IOException e) { } } } }
POSTaggerFactory.class.getName(), ngramDictionary, null); } catch (final InvalidFormatException e) { e.printStackTrace(); BaselineFactory.class.getName(), ngramDictionary, null); } catch (final InvalidFormatException e) { e.printStackTrace();
e.printStackTrace(); } catch (IOException e) { e.printStackTrace();