Examples of InvalidFormatException


Examples of opennlp.tools.util.InvalidFormatException

      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

Examples of opennlp.tools.util.InvalidFormatException

    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

Examples of opennlp.tools.util.InvalidFormatException

          break;
        }
      }

      if (nestedGeneratorElement == null) {
        throw new InvalidFormatException("window feature generator must contain" +
            "a agregator element");
      }
     
      AdaptiveFeatureGenerator nestedGenerator = GeneratorFactory.createGenerator(nestedGeneratorElement, resourceManager);
     
      String prevLengthString = generatorElement.getAttribute("prevLength");

      int prevLength;

      try {
        prevLength = Integer.parseInt(prevLengthString);
      } catch (NumberFormatException e) {
        throw new InvalidFormatException("prevLength attribute is not a number!");
      }
     
      String nextLengthString = generatorElement.getAttribute("nextLength");

      int nextLength;

      try {
        nextLength = Integer.parseInt(nextLengthString);
      } catch (NumberFormatException e) {
        throw new InvalidFormatException("nextLength attribute is not a number!");
     
     
      return new WindowFeatureGenerator(nestedGenerator, prevLength, nextLength);
    }
View Full Code Here

Examples of opennlp.tools.util.InvalidFormatException

     
      AdaptiveFeatureGenerator generator = null;
      try {
        generator = (AdaptiveFeatureGenerator) featureGenClass.newInstance();
      } catch (InstantiationException e) {
        throw new InvalidFormatException("Failed to instantiate custom class!", e);
      } catch (IllegalAccessException e) {
        throw new InvalidFormatException("Failed to instantiate custom class!", e);
      }
     
      return generator;
    }
View Full Code Here

Examples of opennlp.tools.util.InvalidFormatException

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

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

    // Ensure that the tag dictionary is compatible with the model
    Object tagdictEntry = artifactMap.get(TAG_DICTIONARY_ENTRY_NAME);

    if (tagdictEntry != null) {
      if (tagdictEntry instanceof POSDictionary) {
        POSDictionary posDict = (POSDictionary) tagdictEntry;
       
        Set<String> dictTags = new HashSet<String>();
       
        for (String word : posDict) {
          Collections.addAll(dictTags, posDict.getTags(word));
        }
       
        Set<String> modelTags = new HashSet<String>();
       
        AbstractModel posModel = getPosModel();
       
        for  (int i = 0; i < posModel.getNumOutcomes(); i++) {
          modelTags.add(posModel.getOutcome(i));
        }
       
        if (!modelTags.containsAll(dictTags)) {
          throw new InvalidFormatException("Tag dictioinary contains tags " +
              "which are unkown by the model!");
        }
      }
      else {
        throw new InvalidFormatException("Abbreviations dictionary has wrong type!");
      }
    }

    Object ngramDictEntry = artifactMap.get(NGRAM_DICTIONARY_ENTRY_NAME);

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

Examples of opennlp.tools.util.InvalidFormatException

    };

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

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

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

Examples of org.apache.harmony.auth.login.DefaultConfigurationParser.InvalidFormatException

      }
    }
  }
 
  public void testException() {
    InvalidFormatException ife = new InvalidFormatException("message");
    assertEquals("message", ife.getMessage());
    try {
            throw ife;
        }catch (Exception e){
            assertTrue(ife.equals(e));
        }
        DefaultConfigurationParser.InvalidFormatException ife1 = new DefaultConfigurationParser.InvalidFormatException("message");
    assertEquals("message", ife1.getMessage());
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.exceptions.InvalidFormatException

      PackagePart[] parts = this.getPartsImpl();
      this.partList = new PackagePartCollection();
      for (PackagePart part : parts) {
        if (partList.containsKey(part._partName))
          throw new InvalidFormatException(
              "A part with the name '"
                  + part._partName
                  + "' already exist : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]");

        // Check OPC compliance rule M4.1
        if (part.getContentType().equals(
            ContentTypes.CORE_PROPERTIES_PART)) {
          if (!hasCorePropertiesPart)
            hasCorePropertiesPart = true;
          else
            throw new InvalidFormatException(
                "OPC Compliance error [M4.1]: there is more than one core properties relationship in the package !");
        }

        PartUnmarshaller partUnmarshaller = partUnmarshallers
            .get(part._contentType);

        if (partUnmarshaller != null) {
          UnmarshallContext context = new UnmarshallContext(this,
              part._partName);
          try {
            PackagePart unmarshallPart = partUnmarshaller
                .unmarshall(context, part.getInputStream());
            partList.put(unmarshallPart._partName, unmarshallPart);

            // Core properties case
            if (unmarshallPart instanceof PackagePropertiesPart)
              this.packageProperties = (PackagePropertiesPart) unmarshallPart;
          } catch (IOException ioe) {
            logger.log(POILogger.WARN, "Unmarshall operation : IOException for "
                + part._partName);
            continue;
          } catch (InvalidOperationException invoe) {
            throw new InvalidFormatException(invoe.getMessage());
          }
        } else {
          try {
            partList.put(part._partName, part);
          } catch (InvalidOperationException e) {
            throw new InvalidFormatException(e.getMessage());
          }
        }
      }
    }
    return new ArrayList<PackagePart>(partList.values());
View Full Code Here

Examples of org.apache.poi.openxml4j.exceptions.InvalidFormatException

      throw new IllegalArgumentException("partURI");

    String uriPath = partURI.getPath();
    if (uriPath.length() == 0
        || ((uriPath.length() == 1) && (uriPath.charAt(0) == PackagingURIHelper.FORWARD_SLASH_CHAR)))
      throw new InvalidFormatException(
          "A part name shall not be empty [M1.1]: "
              + partURI.getPath());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.