Package opennlp.tools.util

Examples of opennlp.tools.util.InvalidFormatException


    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


       if (parts.length >= minNumberOfFields) {
         tokens.add(parts[1]);
         tags.add(parts[4]);
       }
       else {
         throw new InvalidFormatException("Every non-empty line must have at least " +
             minNumberOfFields + " fields!");
       }
     }
    
     // just skip empty samples and read next sample
View Full Code Here

        try {
          String 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 must be a nubmer!");
        }

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

        String operationString = entry.getAttributes().getValue("operation");

        StringList word = entry.getTokens();

        if (word.size() != 1)
          throw new InvalidFormatException("Each entry must have exactly one token! "+word);
       
        // parse operation
        Operation operation = Operation.parse(operationString);
       
        if (operation == null)
            throw new InvalidFormatException("Unkown operation type: " + operationString);
       
        operationTable.put(word.getToken(0), operation);
      }});
  }
View Full Code Here

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

    if (!(artifactMap.get(TOKENIZER_MODEL_ENTRY) instanceof AbstractModel)) {
      throw new InvalidFormatException("Token model is incomplete!");
    }

    if (!isModelCompatible(getMaxentModel())) {
      throw new InvalidFormatException("The maxent model is not compatible with the tokenizer!");
    }

    if (getManifestProperty(USE_ALPHA_NUMERIC_OPTIMIZATION) == null) {
      throw new InvalidFormatException("The " + USE_ALPHA_NUMERIC_OPTIMIZATION + " parameter " +
          "cannot be found!");
    }
   
    Object abbreviationsEntry = artifactMap.get(ABBREVIATIONS_ENTRY_NAME);

    if (abbreviationsEntry != null && !(abbreviationsEntry instanceof Dictionary)) {
      throw new InvalidFormatException("Abbreviations dictionary has wrong type!");
    }
  }
View Full Code Here

    }
    else if ("ORG".equals(type)) {
      type = "organization";
    }
    else {
      throw new InvalidFormatException("Unkonw type: " + type);
    }
   
    return new Span(begin, end, type);
  }
View Full Code Here

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

    if (!(artifactMap.get(MAXENT_MODEL_ENTRY_NAME) instanceof AbstractModel)) {
      throw new InvalidFormatException("Unable to find " + MAXENT_MODEL_ENTRY_NAME +
          " maxent model!");
    }

    if (!ModelUtil.validateOutcomes(getMaxentModel(), SentenceDetectorME.SPLIT,
        SentenceDetectorME.NO_SPLIT)) {
      throw new InvalidFormatException("The maxent model is not compatible " +
          "with the sentence detector!");
    }
   
    if (getManifestProperty(TOKEN_END_PROPERTY) == null)
      throw new InvalidFormatException(TOKEN_END_PROPERTY + " is a mandatory property!");

    Object abbreviationsEntry = artifactMap.get(ABBREVIATIONS_ENTRY_NAME);

    if (abbreviationsEntry != null && !(abbreviationsEntry instanceof Dictionary)) {
      throw new InvalidFormatException("Abbreviations dictionary has wrong type!");
    }
  }
View Full Code Here

  @Override
  protected void validateArtifactMap() throws InvalidFormatException {
    super.validateArtifactMap();
   
    if (!(artifactMap.get(BUILD_MODEL_ENTRY_NAMEinstanceof AbstractModel)) {
      throw new InvalidFormatException("Missing the build model!");
    }
   
    ParserType modelType = getParserType();
   
    if (modelType != null) {
      if (ParserType.CHUNKING.equals(modelType)) {
        if (artifactMap.get(ATTACH_MODEL_ENTRY_NAME) != null)
            throw new InvalidFormatException("attachModel must be null for chunking parser!");
      }
      else if (ParserType.TREEINSERT.equals(modelType)) {
        if (!(artifactMap.get(ATTACH_MODEL_ENTRY_NAMEinstanceof AbstractModel))
          throw new InvalidFormatException("attachModel must not be null!");
      }
      else {
        throw new InvalidFormatException("Unkown ParserType!");
      }
    }
    else {
      throw new InvalidFormatException("Missing the parser type property!");
    }
   
    if (!(artifactMap.get(CHECK_MODEL_ENTRY_NAMEinstanceof AbstractModel)) {
      throw new InvalidFormatException("Missing the check model!");
    }
   
    if (!(artifactMap.get(PARSER_TAGGER_MODEL_ENTRY_NAMEinstanceof POSModel)) {
      throw new InvalidFormatException("Missing the tagger model!");
    }
   
    if (!(artifactMap.get(CHUNKER_TAGGER_MODEL_ENTRY_NAMEinstanceof ChunkerModel)) {
      throw new InvalidFormatException("Missing the chunker model!");
    }
   
    if (!(artifactMap.get(HEAD_RULES_MODEL_ENTRY_NAMEinstanceof HeadRules)) {
      throw new InvalidFormatException("Missing the head rules!");
    }
  }
View Full Code Here

        String[] tags = tagString.split(" ");

        StringList word = entry.getTokens();

        if (word.size() != 1)
          throw new InvalidFormatException("Each entry must have exactly one token! "+word);

        newPosDict.dictionary.put(word.getToken(0), tags);
      }});

    newPosDict.caseSensitive = isCaseSensitive;
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

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.