20 package uk.ac.cam.eng.rule.retrieval;
22 import java.util.ArrayList;
23 import java.util.List;
33 private List<String> pattern;
34 private int numberOfNT;
37 this.pattern = pattern;
39 for (String elt : pattern) {
40 if (!elt.equals(
"w")) {
47 return pattern.size();
50 String
get(
int index) {
51 return pattern.get(index);
55 String[] parts = patternString.split(
"_");
56 List<String> elements =
new ArrayList<String>();
57 for (String part : parts) {
58 if (part.equals(
"V")) {
60 }
else if (part.equals(
"V1")) {
62 }
else if (part.equals(
"W")) {
65 throw new RuntimeException(
"Malformed pattern: " + patternString);
73 return (pattern.size() == 1 && pattern.get(0).equals(
"w"));
77 return (numberOfNT > 1);
81 for (String elt : pattern) {
82 if (!elt.equals(
"w")) {
83 return Integer.parseInt(elt);
98 result = prime * result + ((pattern == null) ? 0 : pattern.hashCode());
113 if (getClass() != obj.getClass())
116 if (pattern == null) {
117 if (other.pattern != null)
119 }
else if (!pattern.equals(other.pattern))
131 StringBuilder res =
new StringBuilder();
132 if (!pattern.isEmpty()) {
133 res.append(pattern.get(0));
135 for (
int i = 1; i < pattern.size(); i++) {
136 res.append(
"_").append(pattern.get(i));
138 return res.toString();
boolean equals(Object obj)
SidePattern(List< String > pattern)
static SidePattern parsePattern(String patternString)