Search in sources :

Example 1 with NChildrenStrategy

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

the class RuleManager method getOperations.

/**
 * @param dg
 * @param address
 * @return
 */
public List<Operation> getOperations(SentimentDependencyGraph dg, short address) {
    SentimentDependencyNode currentNode = dg.getNode(address);
    List<Operation> operations = new ArrayList<Operation>();
    for (Rule r : rules) {
        if (r.match(dg, currentNode)) {
            Operation o = r.getOperation();
            // System.out.println("currentNode: "+currentNode+" r: "+r+" o: "+o);
            if (dg.getNode(address).getSi() == null)
                dg.getNode(address).setSi(new SentimentInformation());
            if (!o.getOperationName().equals(Operation.DEFAULT)) {
                dg.getNode(address).getSi().setType(o.getOperationName());
                if (o.getStrategy() instanceof NChildrenStrategy) {
                    ((NChildrenStrategy) o.getStrategy()).setReference(address);
                }
                if (o.getStrategy() instanceof FirstSubjectiveChildrenStrategy) {
                    ((FirstSubjectiveChildrenStrategy) o.getStrategy()).setReference(address);
                }
            }
            operations.add(r.getOperation());
        }
    }
    if (operations.contains(getOperation(Operation.DEFAULT)) && operations.size() > 1)
        operations.remove(getOperation(Operation.DEFAULT));
    return operations;
}
Also used : SentimentDependencyNode(org.grupolys.samulan.util.SentimentDependencyNode) NChildrenStrategy(org.grupolys.samulan.analyser.operation.NChildrenStrategy) ArrayList(java.util.ArrayList) SentimentInformation(org.grupolys.samulan.util.SentimentInformation) DefaultOperation(org.grupolys.samulan.analyser.operation.DefaultOperation) ShiftOperation(org.grupolys.samulan.analyser.operation.ShiftOperation) WeightingOperation(org.grupolys.samulan.analyser.operation.WeightingOperation) Operation(org.grupolys.samulan.analyser.operation.Operation) Rule(org.grupolys.samulan.rule.Rule) FirstSubjectiveChildrenStrategy(org.grupolys.samulan.analyser.operation.FirstSubjectiveChildrenStrategy)

Aggregations

ArrayList (java.util.ArrayList)1 DefaultOperation (org.grupolys.samulan.analyser.operation.DefaultOperation)1 FirstSubjectiveChildrenStrategy (org.grupolys.samulan.analyser.operation.FirstSubjectiveChildrenStrategy)1 NChildrenStrategy (org.grupolys.samulan.analyser.operation.NChildrenStrategy)1 Operation (org.grupolys.samulan.analyser.operation.Operation)1 ShiftOperation (org.grupolys.samulan.analyser.operation.ShiftOperation)1 WeightingOperation (org.grupolys.samulan.analyser.operation.WeightingOperation)1 Rule (org.grupolys.samulan.rule.Rule)1 SentimentDependencyNode (org.grupolys.samulan.util.SentimentDependencyNode)1 SentimentInformation (org.grupolys.samulan.util.SentimentInformation)1