Search in sources :

Example 1 with ScopeStrategy

use of org.grupolys.samulan.analyser.operation.ScopeStrategy in project uuusa by aghie.

the class RuleManager method parseWeightOperation.

private Operation parseWeightOperation(String operation, String form) {
    WeightingOperation sucessor = null;
    ScopeStrategy strategy;
    float weightingValue = 0;
    Pattern p = Pattern.compile("(\\(.*\\))");
    Matcher m = p.matcher(operation);
    m.find();
    String[] parameters = m.group(1).replace("(", "").replace(")", "").split(",");
    if (parameters[0].equals(SENTIDATA)) {
        // System.out.println("form: "+form);
        weightingValue = this.d.getValue(Operation.WEIGHT, form, true);
    } else
        weightingValue = Float.parseFloat(parameters[0]);
    for (int i = parameters.length - 1; i >= 1; i--) {
        strategy = getScopeStrategy(parameters[i], parameters);
        sucessor = new WeightingOperation(null, strategy, weightingValue, sucessor);
    }
    return sucessor;
}
Also used : Pattern(java.util.regex.Pattern) WeightingOperation(org.grupolys.samulan.analyser.operation.WeightingOperation) ScopeStrategy(org.grupolys.samulan.analyser.operation.ScopeStrategy) Matcher(java.util.regex.Matcher)

Example 2 with ScopeStrategy

use of org.grupolys.samulan.analyser.operation.ScopeStrategy in project uuusa by aghie.

the class RuleManager method parseShiftOperation.

private Operation parseShiftOperation(String operation, String form) {
    ShiftOperation successor = null;
    ScopeStrategy strategy = null;
    float shiftValue;
    Pattern p = Pattern.compile("(\\(.*\\))");
    Matcher m = p.matcher(operation);
    m.find();
    String[] parameters = m.group(1).replace("(", "").replace(")", "").split(",");
    if (parameters[0].equals(SENTIDATA)) {
        shiftValue = this.d.getValue(Operation.SHIFT, form, true);
    } else
        shiftValue = Float.parseFloat(parameters[0]);
    for (int i = parameters.length - 1; i >= 0; i--) {
        strategy = getScopeStrategy(parameters[i], parameters);
        successor = new ShiftOperation(null, strategy, successor, shiftValue);
        successor.setAlwaysShift(isAlwaysShift());
    }
    return successor;
}
Also used : Pattern(java.util.regex.Pattern) ScopeStrategy(org.grupolys.samulan.analyser.operation.ScopeStrategy) Matcher(java.util.regex.Matcher) ShiftOperation(org.grupolys.samulan.analyser.operation.ShiftOperation)

Aggregations

Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 ScopeStrategy (org.grupolys.samulan.analyser.operation.ScopeStrategy)2 ShiftOperation (org.grupolys.samulan.analyser.operation.ShiftOperation)1 WeightingOperation (org.grupolys.samulan.analyser.operation.WeightingOperation)1