Package opennlp.tools.util

Examples of opennlp.tools.util.InvalidFormatException


    for (int i = 0; i < tokenTags.length; i++) {
      int split = tokenTags[i].lastIndexOf("_");

      if (split == -1) {
        throw new InvalidFormatException("Cannot find \"_\" inside token '" + tokenTags[i] + "'!");
      }

      sentence[i] = tokenTags[i].substring(0, split);
      tags[i] = tokenTags[i].substring(split+1);
    }
View Full Code Here


  @Override
  public void validateArtifactMap() throws InvalidFormatException {

    if (this.artifactProvider
        .getManifestProperty(USE_ALPHA_NUMERIC_OPTIMIZATION) == null)
      throw new InvalidFormatException(USE_ALPHA_NUMERIC_OPTIMIZATION
          + " is a mandatory property!");

    Object abbreviationsEntry = this.artifactProvider
        .getArtifact(ABBREVIATIONS_ENTRY_NAME);

    if (abbreviationsEntry != null && !(abbreviationsEntry instanceof Dictionary)) {
      throw new InvalidFormatException("Abbreviations dictionary '" + abbreviationsEntry +
              "' has wrong type, needs to be of type Dictionary!");
    }
  }
View Full Code Here

    } catch (Exception e) {
      String msg = "Could not instantiate the " + subclassName
          + ". The initialization throw an exception.";
      System.err.println(msg);
      e.printStackTrace();
      throw new InvalidFormatException(msg, e);
    }
  }
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

    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

      xmlReader = XMLReaderFactory.createXMLReader();
      xmlReader.setContentHandler(profileContentHandler);
      xmlReader.parse(new InputSource(new UncloseableInputStream(in)));
    }
    catch (SAXException e) {
      throw new InvalidFormatException("The profile data stream has " +
            "an invalid format!", e);
    }
    return profileContentHandler.mIsCaseSensitiveDictionary;
  }
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

  @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!");
    }
  }
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.