public double computeTreeWeight(DependencyTree root, ArrayList<Word> originalWords) {
double totalWeight = 0;
int signMultiplier;
Stack<DependencyTree> s = new Stack<DependencyTree>();
DependencyTree iterator;
for (int i = 0; i < root.getChilds().size(); i++) {
s.push(root.getChild(i));
}
while (!s.empty()) {
iterator = s.pop();
signMultiplier = iterator.isNegated() ? -1 : 1;
totalWeight += (signMultiplier * aggregator.getWordScore(iterator.getWord(), originalWords));
for (int i = 0; i < iterator.getChilds().size(); i++) {
s.push(iterator.getChild(i));
}
}
return totalWeight;
}