Package opennlp.tools.util

Examples of opennlp.tools.util.InvalidFormatException


    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);
    }
    return xmlDescriptorDOM;
  }
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

    }
    else if ("ORG".equals(type)) {
      type = "organization";
    }
    else {
      throw new InvalidFormatException("Unknown type: " + type);
    }

    return new Span(begin, end, type);
  }
View Full Code Here

            if (startDocElement < endDocElement) {
              docs.add(newDocs.substring(startDocElement, endDocElement + DOC_END_ELEMENT.length()));
              docStartOffset = endDocElement + DOC_END_ELEMENT.length();
            }
            else {
              throw new InvalidFormatException("<DOC> element is not closed!");
            }
          }
          else if (startDocElement != endDocElement) {
            throw new InvalidFormatException("Missing <DOC> or </DOC> element!");
          }
          else {
            break;
          }
        }
View Full Code Here

    if (NAME_ELEMENT_NAMES.contains(name)) {

      String nameType = attributes.get("TYPE");

      if (!EXPECTED_TYPES.contains(nameType)) {
        throw new InvalidFormatException("Unknown timex, numex or namex type: "
            + nameType + ", expected one of " + EXPECTED_TYPES);
      }

      incompleteNames.add(new Span(text.size(), text.size(), nameType.toLowerCase(Locale.ENGLISH)));
    }
View Full Code Here

      if (tagChars.charAt(ci) == '>' || StringUtil.isWhitespace(tagChars.charAt(ci))) {
        return tagChars.subSequence(fromOffset, ci).toString();
      }
    }

    throw new InvalidFormatException("Failed to extract tag name!");
  }
View Full Code Here

    int c;
    while ((c = in.read()) != -1) {

      if ('<' == c) {
        if (isInsideTag) {
          throw new InvalidFormatException("Did not expect < char!");
        }

        if (buffer.toString().trim().length() > 0) {
          handler.characters(buffer.toString().trim());
        }

        buffer.setLength(0);

        isInsideTag = true;
        isStartTag = true;
      }

      buffer.appendCodePoint(c);

      if ('/' == c && lastChar == '<') {
        isStartTag = false;
      }

      if ('>' == c) {

        if (!isInsideTag) {
          throw new InvalidFormatException("Did not expect > char!");
        }

        if (isStartTag) {
          handler.startElement(extractTagName(buffer), getAttributes(buffer));
        }
        else {
          handler.endElement(extractTagName(buffer));
        }

        buffer.setLength(0);

        isInsideTag = false;
      }

      lastChar = c;
    }

    if (isInsideTag) {
      throw new InvalidFormatException("Did not find matching > char!");
    }
  }
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("Unknown operation type: " + operationString);

        operationTable.put(word.getToken(0), operation);
      }});
  }
View Full Code Here

    }
    else if ("ORG".equals(type)) {
      type = "organization";
    }
    else {
      throw new InvalidFormatException("Unknown type: " + type);
    }

    return new Span(begin, end, type);
  }
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.