if (rule == null || inside.isEmpty()) {
return null;
}
// create base 1 and base 2:
WhiskRule base1 = rule.copy(); // slot filler rule
TextRulerSlotPattern slotPattern = base1.getPatterns().get(slotIndex);
for (int i = 0; i < inside.size(); i++)
if (i == 0 || (i == inside.size() - 1))
slotPattern.fillerPattern.add(inside.get(i).copy());
else if (inside.size() > 2 && i < 2)
slotPattern.fillerPattern.add(WhiskRuleItem.newWildCardItem(getElementIndex(base1,
inside.get(i))));
List<WhiskRuleItem> beforeList = getTermsBefore(inside.get(0), example);
List<WhiskRuleItem> afterList = getTermsAfter(inside.get(inside.size() - 1), example);
Collection<WhiskRule> tempRules = new HashSet<WhiskRule>();
if (!beforeList.isEmpty()) {
if (!afterList.isEmpty()) {
for (WhiskRuleItem eachBefore : beforeList) {
for (WhiskRuleItem eachAfter : afterList) {
WhiskRule copy = rule.copy();
TextRulerSlotPattern textRulerSlotPattern = copy.getPatterns().get(slotIndex);
textRulerSlotPattern.preFillerPattern.add(eachBefore);
textRulerSlotPattern.fillerPattern.add(WhiskRuleItem.newWildCardItem(getElementIndex(
copy, inside.get(0))));
textRulerSlotPattern.postFillerPattern.add(eachAfter);
tempRules.add(copy);
}
}
} else {
for (WhiskRuleItem eachBefore : beforeList) {
WhiskRule copy = rule.copy();
TextRulerSlotPattern textRulerSlotPattern = copy.getPatterns().get(slotIndex);
textRulerSlotPattern.fillerPattern.add(WhiskRuleItem.newWildCardItem(getElementIndex(
copy, inside.get(0))));
textRulerSlotPattern.preFillerPattern.add(eachBefore);
tempRules.add(copy);
}
}
} else {
for (WhiskRuleItem eachAfter : afterList) {
WhiskRule copy = rule.copy();
TextRulerSlotPattern textRulerSlotPattern = copy.getPatterns().get(slotIndex);
textRulerSlotPattern.fillerPattern.add(WhiskRuleItem.newWildCardItem(getElementIndex(
copy, inside.get(0))));
textRulerSlotPattern.postFillerPattern.add(eachAfter);
tempRules.add(copy);
}