Package opennlp.tools.util

Examples of opennlp.tools.util.InvalidFormatException


        try {
          countValueString = entry.getAttributes().getValue(COUNT);

          if (countValueString == null) {
            throw new InvalidFormatException(
                "The count attribute must be set!");
          }

          count = Integer.parseInt(countValueString);
        } catch (NumberFormatException e) {
          throw new InvalidFormatException("The count attribute '" + countValueString
              + "' must be a number!", e);
        }

        add(entry.getTokens());
        setCount(entry.getTokens(), count);
View Full Code Here


  @Override
  protected void validateArtifactMap() throws InvalidFormatException {
    super.validateArtifactMap();

    if (!(artifactMap.get(DOCCAT_MODEL_ENTRY_NAME) instanceof AbstractModel)) {
      throw new InvalidFormatException("Doccat model is incomplete!");
    }
  }
View Full Code Here

    Class<?> generatorFactoryClass = classSerializer.create(in);
   
    try {
      return (FeatureGeneratorFactory) generatorFactoryClass.newInstance();
    } catch (InstantiationException e) {
      throw new InvalidFormatException(e);
    } catch (IllegalAccessException e) {
      throw new InvalidFormatException(e);
    }
  }
View Full Code Here

    if (artifactMap.get(MAXENT_MODEL_ENTRY_NAME) instanceof AbstractModel) {
      AbstractModel model = (AbstractModel) artifactMap.get(MAXENT_MODEL_ENTRY_NAME);
      isModelValid(model);
    }
    else {
      throw new InvalidFormatException("Token Name Finder model is incomplete!");
    }
  }
View Full Code Here

    String elementName = generatorElement.getTagName();
   
    XmlFeatureGeneratorFactory generatorFactory = factories.get(elementName);

    if (generatorFactory == null) {
      throw new InvalidFormatException("Unexpected element: " + elementName);
    }
   
    return generatorFactory.create(generatorElement, resourceManager);
  }
View Full Code Here

    org.w3c.dom.Document xmlDescriptorDOM;

    try {
      xmlDescriptorDOM = documentBuilder.parse(xmlDescriptorIn);
    } catch (SAXException e) {
      throw new InvalidFormatException("Descriptor is not valid XML!", e);
    }

    Element generatorElement = xmlDescriptorDOM.getDocumentElement();

    return createGenerator(generatorElement, resourceManager);
View Full Code Here

          break;
        }
      }

      if (cachedGeneratorElement == null) {
        throw new InvalidFormatException("Could not find containing generator element!");
      }

      AdaptiveFeatureGenerator cachedGenerator =
          GeneratorFactory.createGenerator(cachedGeneratorElement, resourceManager);
View Full Code Here

    };

    try {
      return loader.loadClass(CLASS_SEARCH_NAME);
    } catch (ClassNotFoundException e) {
      throw new InvalidFormatException(e);
    }
  }
View Full Code Here

      int min;

      try {
        min = Integer.parseInt(minString);
      } catch (NumberFormatException e) {
        throw new InvalidFormatException("min attribute '" + minString + "' is not a number!", e);
      }

      String maxString = generatorElement.getAttribute("max");

      int max;

      try {
        max = Integer.parseInt(maxString);
      } catch (NumberFormatException e) {
        throw new InvalidFormatException("max attribute '" + maxString + "' is not a number!", e);
      }

      return new CharacterNgramFeatureGenerator(min, max);
    }
View Full Code Here

      String dictResourceKey = generatorElement.getAttribute("dict");
     
      Object dictResource = resourceManager.getResource(dictResourceKey);
     
      if (!(dictResource instanceof Dictionary)) {
        throw new InvalidFormatException("No dictionary resource for key: " + dictResourceKey);
      }

      String prefix = generatorElement.getAttribute("prefix");
     
      return new DictionaryFeatureGenerator(prefix, (Dictionary) dictResource);
View Full Code Here

TOP

Related Classes of opennlp.tools.util.InvalidFormatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.