Examples of FeatureException


Examples of org.maltparserx.core.feature.FeatureException

    multipleFeatureValue = new MultipleFeatureValue(this);
  }
 
  public void initialize(Object[] arguments) throws MaltChainedException {
    if (arguments.length != 2) {
      throw new FeatureException("Could not initialize SplitFeature: number of arguments are not correct. ");
    }
    if (!(arguments[0] instanceof FeatureFunction)) {
      throw new FeatureException("Could not initialize SplitFeature: the first argument is not a feature. ");
    }
    if (!(arguments[1] instanceof String)) {
      throw new FeatureException("Could not initialize SplitFeature: the second argument is not a string. ");
    }
    setParentFeature((FeatureFunction)arguments[0]);
    setSeparators((String)arguments[1]);
    ColumnDescription parentColumn = dataFormatInstance.getColumnDescriptionByName(parentFeature.getSymbolTable().getName());
    if (parentColumn.getType() != ColumnDescription.STRING) {
      throw new FeatureException("Could not initialize SplitFeature: the first argument must be a string. ");
    }
    setColumn(dataFormatInstance.addInternalColumnDescription("SPLIT_"+parentFeature.getSymbolTable().getName(), parentColumn));
    setSymbolTable(column.getSymbolTable());
//    setSymbolTable(tableHandler.addSymbolTable("SPLIT_"+parentFeature.getSymbolTable().getName(), parentFeature.getSymbolTable()));
  }
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

      } else {
        String items[];
        try {
          items = separatorsPattern.split(symbol);
        } catch (PatternSyntaxException e) {
          throw new FeatureException("The split feature '"+this.toString()+"' could not split the value using the following separators '"+separators+"'",e);
        }
        for (int i = 0; i < items.length; i++) {
          if (items[i].length() > 0) {
            multipleFeatureValue.addFeatureValue(table.addSymbol(items[i]), items[i]);
          }
        }
        multipleFeatureValue.setNullValue(false);
      }
    } else if (value instanceof MultipleFeatureValue) {
      if (((MultipleFeatureValue)value).isNullValue()) {
        multipleFeatureValue.addFeatureValue(parentFeature.getSymbolTable().getSymbolStringToCode(((MultipleFeatureValue)value).getFirstSymbol()), ((MultipleFeatureValue)value).getFirstSymbol());
        multipleFeatureValue.setNullValue(true);
      } else {
        for (String symbol : ((MultipleFeatureValue)value).getSymbols()) {
          String items[];
          try {
            items = separatorsPattern.split(symbol);
          } catch (PatternSyntaxException e) {
            throw new FeatureException("The split feature '"+this.toString()+"' could not split the value using the following separators '"+separators+"'", e);
          }
          for (int i = 0; i < items.length; i++) {
            multipleFeatureValue.addFeatureValue(table.addSymbol(items[i]), items[i]);
          }
          multipleFeatureValue.setNullValue(false);
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

    multipleFeatureValue = new MultipleFeatureValue(this);
  }
 
  public void initialize(Object[] arguments) throws MaltChainedException {
    if (arguments.length != 2) {
      throw new FeatureException("Could not initialize SuffixFeature: number of arguments are not correct. ");
    }
    if (!(arguments[0] instanceof FeatureFunction)) {
      throw new FeatureException("Could not initialize SuffixFeature: the first argument is not a feature. ");
    }
    if (!(arguments[1] instanceof Integer)) {
      throw new FeatureException("Could not initialize SuffixFeature: the second argument is not a string. ");
    }
    setParentFeature((FeatureFunction)arguments[0]);
    setSuffixLength(((Integer)arguments[1]).intValue());
    ColumnDescription parentColumn = dataFormatInstance.getColumnDescriptionByName(parentFeature.getSymbolTable().getName());
    if (parentColumn.getType() != ColumnDescription.STRING) {
      throw new FeatureException("Could not initialize SuffixFeature: the first argument must be a string. ");
    }
    setColumn(dataFormatInstance.addInternalColumnDescription("SUFFIX_"+suffixLength+"_"+parentFeature.getSymbolTable().getName(), parentColumn));
    setSymbolTable(column.getSymbolTable());
//    setSymbolTable(tableHandler.addSymbolTable("SUFFIX_"+suffixLength+"_"+parentFeature.getSymbolTable().getName(), parentFeature.getSymbolTable()));
  }
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

    singleFeatureValue = new SingleFeatureValue(this);
  }
 
  public void initialize(Object[] arguments) throws MaltChainedException {
    if (arguments.length != 2) {
      throw new FeatureException("Could not initialize MergeFeature: number of arguments are not correct. ");
    }
    if (!(arguments[0] instanceof FeatureFunction)) {
      throw new FeatureException("Could not initialize MergeFeature: the first argument is not a feature. ");
    }
    if (!(arguments[1] instanceof FeatureFunction)) {
      throw new FeatureException("Could not initialize MergeFeature: the second argument is not a feature. ");
    }
    setFirstFeature((FeatureFunction)arguments[0]);
    setSecondFeature((FeatureFunction)arguments[1]);
    ColumnDescription firstColumn = (firstFeature.getSymbolTable() != null)?dataFormatInstance.getColumnDescriptionByName(firstFeature.getSymbolTable().getName()):null;
    ColumnDescription secondColumn = (secondFeature.getSymbolTable() != null)?dataFormatInstance.getColumnDescriptionByName(secondFeature.getSymbolTable().getName()):null;
//    if (firstColumn.getType() != secondColumn.getType()) {
//      throw new FeatureException("Could not initialize MergeFeature: the first and the second arguments are not of the same type.");
//    }
//    setColumn(dataFormatInstance.addInternalColumnDescription("MERGE2_"+firstFeature.getSymbolTable().getName()+"_"+secondFeature.getSymbolTable().getName(), firstColumn));

    if (firstFeature.getType() != secondFeature.getType()) {
      throw new FeatureException("Could not initialize MergeFeature: the first and the second arguments are not of the same type.");
    }
    if (firstColumn != null || secondColumn != null) {
      setColumn(dataFormatInstance.addInternalColumnDescription("MERGE2_"+firstFeature.getMapIdentifier()+"_"+secondFeature.getMapIdentifier(), (firstColumn != null)?firstColumn:secondColumn));
    } else {
      setColumn(dataFormatInstance.addInternalColumnDescription("MERGE2_"+firstFeature.getMapIdentifier()+"_"+secondFeature.getMapIdentifier(), ColumnDescription.INPUT, firstFeature.getType(), "", "One"));
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

                  firstInt = Integer.parseInt(firstSymbol);
                } else {
                  firstInt = Integer.parseInt(firstSymbol.substring(0,dotIndex));
                }
              } catch (NumberFormatException e) {
                throw new FeatureException("Could not cast the feature value '"+firstSymbol+"' to integer value.", e);
              }
              String secondSymbol = ((SingleFeatureValue)secondValue).getSymbol();
              dotIndex = secondSymbol.indexOf('.');
              try {
                if (dotIndex == -1) {
                  secondInt = Integer.parseInt(secondSymbol);
                } else {
                  secondInt = Integer.parseInt(secondSymbol.substring(0,dotIndex));
                }
              } catch (NumberFormatException e) {
                throw new FeatureException("Could not cast the feature value '"+secondSymbol+"' to integer value.", e);
              }
              Integer result = firstInt*secondInt;
              singleFeatureValue.setValue(result);
              table.addSymbol(result.toString());
              singleFeatureValue.setSymbol(result.toString());
            } else if (column.getType() == ColumnDescription.REAL) {
              Double firstReal = 0.0;
              Double secondReal = 0.0;
              try {
                firstReal = Double.parseDouble(firstSymbol);
              } catch (NumberFormatException e) {
                throw new FeatureException("Could not cast the feature value '"+firstSymbol+"' to real value.", e);
              }
              String secondSymbol = ((SingleFeatureValue)secondValue).getSymbol();
              try {
                secondReal = Double.parseDouble(secondSymbol);
              } catch (NumberFormatException e) {
                throw new FeatureException("Could not cast the feature value '"+secondSymbol+"' to real value.", e);
              }
              Double result = firstReal*secondReal;
              singleFeatureValue.setValue(result);
              table.addSymbol(result.toString());
              singleFeatureValue.setSymbol(result.toString());
            }
            singleFeatureValue.setNullValue(false);
            singleFeatureValue.setIndexCode(1);
          }
        }
      }
    } else {
      throw new FeatureException("It is not possible to merge Split-features. ");
    }
  }
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

        } else {
          featureValue.setValue(Integer.parseInt(symbol.substring(0,dotIndex)));
          featureValue.setSymbol(symbol.substring(0,dotIndex));
        }
      } catch (NumberFormatException e) {
        throw new FeatureException("Could not cast the feature value '"+symbol+"' to integer value.", e);
      }
    } else if (column.getType() == ColumnDescription.BOOLEAN) {
      final int dotIndex = symbol.indexOf('.');
      if (symbol.equals("1") || symbol.equals("true") ||  symbol.equals("#true#") || (dotIndex != -1 && symbol.substring(0,dotIndex).equals("1"))) {
        featureValue.setValue(1);
        featureValue.setSymbol("true");
      } else if (symbol.equals("false") || symbol.equals("0") || (dotIndex != -1 && symbol.substring(0,dotIndex).equals("0"))) {
        featureValue.setValue(0);
        featureValue.setSymbol("false");
      } else {
        throw new FeatureException("Could not cast the feature value '"+symbol+"' to boolean value.");
      }
    } else if (column.getType() == ColumnDescription.REAL) {
      try {
        featureValue.setValue(Double.parseDouble(symbol));
        featureValue.setSymbol(symbol);
      } catch (NumberFormatException e) {
        throw new FeatureException("Could not cast the feature value '"+symbol+"' to real value.", e);
      }
    }
    if (column.getType() == ColumnDescription.INTEGER || column.getType() == ColumnDescription.BOOLEAN || column.getType() == ColumnDescription.REAL) {
      featureValue.setNullValue(false);
      featureValue.setIndexCode(1);
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

    setFeatureValue(new SingleFeatureValue(this));
  }
 
  public void initialize(Object[] arguments) throws MaltChainedException {
    if (arguments.length != 3) {
      throw new FeatureException("Could not initialize InputArcFeature: number of arguments are not correct. ");
    }
    // Checks that the two arguments are address functions

    if (!(arguments[0] instanceof String)) {
      throw new FeatureException("Could not initialize InputArcFeature: the first argument is not a string. ");
    }
    if (!(arguments[1] instanceof AddressFunction)) {
      throw new SyntaxGraphException("Could not initialize InputArcFeature: the second argument is not an address function. ");
    }
    if (!(arguments[2] instanceof AddressFunction)) {
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

          featureValue.setIndexCode(table.getNullValueCode(NullValueId.NO_NODE));
          featureValue.setSymbol(table.getNullValueSymbol(NullValueId.NO_NODE));
          featureValue.setNullValue(true);
      }
        } catch (NumberFormatException e) {
          throw new FeatureException("The index of the feature must be an integer value. ", e);
        }
    } else {
        featureValue.setIndexCode(table.getNullValueCode(NullValueId.NO_NODE));
        featureValue.setSymbol(table.getNullValueSymbol(NullValueId.NO_NODE));
        featureValue.setNullValue(true);
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

    return column;
  }

  public void setColumn(ColumnDescription column) throws MaltChainedException {
    if (column.getType() != ColumnDescription.INTEGER) {
      throw new FeatureException("InputArc feature column must be of type integer. ");
    }
    this.column = column;
  }
View Full Code Here

Examples of org.maltparserx.core.feature.FeatureException

    setFeatureValue(new SingleFeatureValue(this));
  }
 
  public void initialize(Object[] arguments) throws MaltChainedException {
    if (arguments.length != 3) {
      throw new FeatureException("Could not initialize OutputArcFeature: number of arguments are not correct. ");
    }
    // Checks that the two arguments are address functions

    if (!(arguments[0] instanceof String)) {
      throw new FeatureException("Could not initialize OutputArcFeature: the first argument is not a string. ");
    }
    if (!(arguments[1] instanceof AddressFunction)) {
      throw new SyntaxGraphException("Could not initialize OutputArcFeature: the second argument is not an address function. ");
    }
    if (!(arguments[2] instanceof AddressFunction)) {
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.