public String getStr(String name) throws InvalidFormatException { Object value = args.get(name); if (value == null) { throw new InvalidFormatException("parameter " + name + " must be set!"); } else if (value instanceof String) { return (String)value; } else { throw new InvalidFormatException("parameter " + name + " must be double!"); } }
public InvalidFormatException(String message, Throwable t) { super(message); initCause(t); } }
featureGeneratorBytes, resources, sequenceCodec); } catch (InvalidFormatException e) { throw new TerminateToolException(-1, e.getMessage(), e);
/** * 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; }
featureGeneratorBytes, resources, sequenceCodec); } catch (InvalidFormatException e) { throw new TerminateToolException(-1, e.getMessage(), e);
/** * 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) { } } } }
public boolean getBool(String name) throws InvalidFormatException { Object value = args.get(name); if (value == null) { throw new InvalidFormatException("parameter " + name + " must be set!"); } else if (value instanceof Boolean) { return (Boolean)value; } else { throw new InvalidFormatException("parameter " + name + " must be boolean!"); } }
resources, null); } catch (InvalidFormatException e) { throw new TerminateToolException(-1, e.getMessage(), e);
POSTaggerFactory.class.getName(), ngramDictionary, null); } catch (final InvalidFormatException e) { e.printStackTrace(); BaselineFactory.class.getName(), ngramDictionary, null); } catch (final InvalidFormatException e) { e.printStackTrace();
public InvalidFormatException(Throwable t) { super(); initCause(t); }
public long getLong(String name) throws InvalidFormatException { Object value = args.get(name); if (value == null) { throw new InvalidFormatException("parameter " + name + " must be set!"); } else if (value instanceof Long) { return (Long)value; } else { throw new InvalidFormatException("parameter " + name + " must be long!"); } }
featureGeneratorBytes, resources, sequenceCodec); } catch (InvalidFormatException e) { throw new TerminateToolException(-1, e.getMessage(), e);
e.printStackTrace(); } catch (IOException e) { e.printStackTrace();
public InvalidFormatException(String message, Throwable t) { super(message); initCause(t); } }
public float getFloat(String name) throws InvalidFormatException { Object value = args.get(name); if (value == null) { throw new InvalidFormatException("parameter " + name + " must be set!"); } else if (value instanceof Float) { return (Float)value; } else { throw new InvalidFormatException("parameter " + name + " must be float!"); } }
featureGeneratorBytes, resources, sequenceCodec); } catch (InvalidFormatException e) { throw new TerminateToolException(-1, e.getMessage(), e);
public InvalidFormatException(String message, Throwable t) { super(message); initCause(t); } }
public int getInt(String name) throws InvalidFormatException { Object value = args.get(name); if (value == null) { throw new InvalidFormatException("parameter " + name + " must be set!"); } else if (value instanceof Integer) { return (Integer)value; } else { throw new InvalidFormatException("parameter " + name + " must be integer!"); } }
featureGeneratorBytes, resources, sequenceCodec); } catch (InvalidFormatException e) { throw new TerminateToolException(-1, e.getMessage(), e);
public InvalidFormatException(Throwable t) { super(); initCause(t); }