Package org.maltparserx.core.io.dataformat

Examples of org.maltparserx.core.io.dataformat.DataFormatException


    this.optionString = optionString;
    String[] argv;
    try {
      argv = optionString.split("[_\\p{Blank}]");
    } catch (PatternSyntaxException e) {
      throw new DataFormatException("Could not split the TigerXML reader option '"+optionString+"'. ", e);
    }
    for (int i=0; i < argv.length-1; i++) {
      if(argv[i].charAt(0) != '-') {
        throw new DataFormatException("The argument flag should start with the following character '-', not with "+argv[i].charAt(0));
      }
      if(++i>=argv.length) {
        throw new DataFormatException("The last argument does not have any value. ");
      }
      switch(argv[i-1].charAt(1)) {
      case 's':
        try {
          START_ID_OF_NONTERMINALS = Integer.parseInt(argv[i]);
        } catch (NumberFormatException e){
          throw new MaltChainedException("The TigerXML Reader option -s must be an integer value. ");
        }
        break;
      default:
        throw new DataFormatException("Unknown TigerXMLReader parameter: '"+argv[i-1]+"' with value '"+argv[i]+"'. ");   
      }
    }
  }
View Full Code Here


    if (fileName != null) {
      open(fileName, charsetName);
    } else if (url != null) {
      open(url, charsetName);
    } else {
      throw new DataFormatException("The input stream cannot be reopen. ");
    }
  }
View Full Code Here

      // sista: detect .gz files on the fly
      InputStream is = new FileInputStream(fileName);
      if(fileName.endsWith(".gz")) is = new GZIPInputStream(is);
      open(is, charsetName);
    } catch (FileNotFoundException e) {
      throw new DataFormatException("The input file '"+fileName+"' cannot be found. ", e);
    } catch(IOException e) {
      throw new DataFormatException("The input file '"+fileName+"' cannot be gunzipped. ", e);
    }
  }
View Full Code Here

 
  public void open(URL url, String charsetName) throws MaltChainedException {
    setUrl(url);
    setCharsetName(charsetName);
    if (url == null) {
      throw new DataFormatException("The input file cannot be found. ");
    }
    try {
      open(url.openStream(), charsetName);
    } catch (IOException e) {
      throw new DataFormatException("The URL '"+url.toString()+"' cannot be opened. ", e);
    }
  }
View Full Code Here

      if (is == System.in) {
        closeStream = false;
      }
      open(new InputStreamReader(is, charsetName));
    } catch (UnsupportedEncodingException e) {
      throw new DataFormatException("The character encoding set '"+charsetName+"' isn't supported. ", e);
    }
  }
View Full Code Here

      try {
        c = reader.read();
      } catch (IOException e) {
        close();
        throw new DataFormatException("Error when reading from the input file. ", e);
      }
      if (c == TAB || c == NEWLINE || c == CARRIAGE_RETURN || c == -1) {
        if (input.length() != 0) {         
          if (i == 0) {
            terminalCounter++;
            node = syntaxGraph.addTokenNode(terminalCounter);
          }
          if (columns.hasNext()) {
            ColumnDescription column = columns.next();
            if (column.getCategory() == ColumnDescription.INPUT && node != null) {
              syntaxGraph.addLabel(node, column.getName(), input.toString());
            } else if (column.getCategory() == ColumnDescription.HEAD) {
              if (syntaxGraph instanceof DependencyStructure) {
                if (column.getCategory() != ColumnDescription.IGNORE && !input.toString().equals(IGNORE_COLUMN_SIGN)) {
//                if (column.getType() != ColumnDescription.IGNORE && !input.toString().equals(IGNORE_COLUMN_SIGN)) { // bugfix
                //if (!input.toString().equals(IGNORE_COLUMN_SIGN)) {
                  edge = ((DependencyStructure)syntaxGraph).addDependencyEdge(Integer.parseInt(input.toString()), terminalCounter);
                }
              }
              else {
                close();
                throw new DataFormatException("The input graph is not a dependency graph and therefore it is not possible to add dependncy edges. ");
              }
            } else if (column.getCategory() == ColumnDescription.DEPENDENCY_EDGE_LABEL && edge != null) {
              //if (column.getType() != ColumnDescription.IGNORE && !input.toString().equals(IGNORE_COLUMN_SIGN)) { // bugfix not working for everybody
                syntaxGraph.addLabel(edge, column.getName(), input.toString());
              //} // bugfix
View Full Code Here

          reader.close();
        }
        reader = null;
      }
    } catch (IOException e) {
      throw new DataFormatException("Error when closing the input file. ", e);
    }
  }
View Full Code Here

    if (fileName != null) {
      open(fileName, charsetName);
    } else if (url != null) {
      open(url, charsetName);
    } else {
      throw new DataFormatException("The input stream cannot be reopen. ");
    }
  }
View Full Code Here

    setFileName(fileName);
    setCharsetName(charsetName);
    try {
      open(new FileInputStream(fileName), charsetName);
    }catch (FileNotFoundException e) {
      throw new DataFormatException("The input file '"+fileName+"' cannot be found. ", e);
    }
  }
View Full Code Here

    setUrl(url);
    setCharsetName(charsetName);
    try {
      open(url.openStream(), charsetName);
    } catch (IOException e) {
      throw new DataFormatException("The URL '"+url.toString()+"' cannot be opened. ", e);
    }
  }
View Full Code Here

TOP

Related Classes of org.maltparserx.core.io.dataformat.DataFormatException

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.