| 1 | |
|
| 2 | |
package org.galagosearch.core.retrieval.traversal; |
| 3 | |
|
| 4 | |
import java.util.ArrayList; |
| 5 | |
import org.galagosearch.core.retrieval.query.Node; |
| 6 | |
import org.galagosearch.core.retrieval.query.Traversal; |
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | 12 | public class IndriWindowCompatibilityTraversal implements Traversal { |
| 19 | |
public Node afterNode(Node original) { |
| 20 | 12 | String operator = original.getOperator(); |
| 21 | 12 | ArrayList<Node> children = original.getInternalNodes(); |
| 22 | |
|
| 23 | 12 | if (operator.length() == 0) { |
| 24 | 0 | return original; |
| 25 | |
} |
| 26 | |
|
| 27 | 12 | if (Character.isDigit(operator.codePointAt(0))) { |
| 28 | |
|
| 29 | 4 | return new Node("od", operator, children, original.getPosition()); |
| 30 | 8 | } else if (operator.startsWith("od") && |
| 31 | |
operator.length() > 2 && |
| 32 | |
Character.isDigit(operator.codePointAt(2))) { |
| 33 | |
|
| 34 | 4 | return new Node("od", operator.substring(2), |
| 35 | |
children, original.getPosition()); |
| 36 | 4 | } else if (operator.startsWith("uw") && |
| 37 | |
operator.length() > 2 && |
| 38 | |
Character.isDigit(operator.codePointAt(2))) { |
| 39 | |
|
| 40 | 4 | return new Node("uw", operator.substring(2), |
| 41 | |
children, original.getPosition()); |
| 42 | |
} |
| 43 | |
|
| 44 | 0 | return original; |
| 45 | |
} |
| 46 | |
|
| 47 | |
public void beforeNode(Node object) throws Exception { |
| 48 | |
|
| 49 | 12 | } |
| 50 | |
} |