Package org.maltparserx.core.feature

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


    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

          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

    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

    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

          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);
    }
//    featureValue.setKnown(true);
    featureValue.setValue(1);
  }
View Full Code Here

    return column;
  }

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

    singleFeatureValue = new SingleFeatureValue(this);
  }
 
  public void initialize(Object[] arguments) throws MaltChainedException {
    if (arguments.length != 3) {
      throw new FeatureException("Could not initialize Merge3Feature: number of arguments are not correct. ");
    }
    if (!(arguments[0] instanceof FeatureFunction)) {
      throw new FeatureException("Could not initialize Merge3Feature: the first argument is not a feature. ");
    }
    if (!(arguments[1] instanceof FeatureFunction)) {
      throw new FeatureException("Could not initialize Merge3Feature: the second argument is not a feature. ");
    }
    if (!(arguments[2] instanceof FeatureFunction)) {
      throw new FeatureException("Could not initialize Merge3Feature: the third argument is not a feature. ");
    }
    setFirstFeature((FeatureFunction)arguments[0]);
    setSecondFeature((FeatureFunction)arguments[1]);
    setThirdFeature((FeatureFunction)arguments[2]);
    ColumnDescription firstColumn = (firstFeature.getSymbolTable() != null)?dataFormatInstance.getColumnDescriptionByName(firstFeature.getSymbolTable().getName()):null;
    ColumnDescription secondColumn = (secondFeature.getSymbolTable() != null)?dataFormatInstance.getColumnDescriptionByName(secondFeature.getSymbolTable().getName()):null;
    ColumnDescription thirdColumn =  (thirdFeature.getSymbolTable() != null)?dataFormatInstance.getColumnDescriptionByName(thirdFeature.getSymbolTable().getName()):null;
    if (firstFeature.getType() != secondFeature.getType() || firstFeature.getType() != thirdFeature.getType()) {
      throw new FeatureException("Could not initialize MergeFeature: the arguments are not of the same type.");
    }
    if (firstColumn != null || secondColumn != null || thirdColumn != null) {
      setColumn(dataFormatInstance.addInternalColumnDescription("MERGE3_"+firstFeature.getMapIdentifier()+"_"+secondFeature.getMapIdentifier()+"_"+thirdFeature.getMapIdentifier(),
          (firstColumn!=null)?firstColumn:((secondColumn!=null)?secondColumn:thirdColumn)));
    } else {
View Full Code Here

                  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();
              try {
                int dotIndex = secondSymbol.indexOf('.');
                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);
              }
              String thirdSymbol = ((SingleFeatureValue)thirdValue).getSymbol();
              try {
                int dotIndex = thirdSymbol.indexOf('.');
                if (dotIndex == -1) {
                  secondInt = Integer.parseInt(thirdSymbol);
                } else {
                  secondInt = Integer.parseInt(thirdSymbol.substring(0,dotIndex));
                }
              } catch (NumberFormatException e) {
                throw new FeatureException("Could not cast the feature value '"+thirdSymbol+"' to integer value.", e);
              }
              Integer result = firstInt*secondInt*thirdInt;
              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;
              Double thirdReal = 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);
              }
              String thirdSymbol = ((SingleFeatureValue)thirdValue).getSymbol();
              try {
                thirdReal = Double.parseDouble(thirdSymbol);
              } catch (NumberFormatException e) {
                throw new FeatureException("Could not cast the feature value '"+thirdSymbol+"' to real value.", e);
              }
              Double result = firstReal*secondReal*thirdReal;
              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

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

TOP

Related Classes of org.maltparserx.core.feature.FeatureException

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.