return dict;
}
public YKDictionary parse(String s) {
errors = new ArrayList();
YKDictionary dict = new SimpleDictionary();
String newname = "Imported VBPro Dictionary";
dict.getDictionaryRoot().setName(newname);
PatternEngine rengine = dict.getPatternEngine();
dict.setName(newname);
BufferedReader in = new BufferedReader(new StringReader(s));
String line;
int ii=0;
CategoryNode cat = null; // the current category
int lineNumber = 0;
try {
while ((line = in.readLine()) != null) {
lineNumber++;
String trimmed = line.trim().toLowerCase();
if (trimmed.startsWith(">") && trimmed.endsWith("<")) {
// a category
String categoryName = stripArrows(trimmed);
if (categoryName.length() == 0) {
categoryName = "Entry_" + ii;
ii++;
}
cat = new CategoryNodeImpl(categoryName);
try {
dict.addCategory(cat, dict.getDictionaryRoot());
} catch (DuplicateException de){
errors.add(new BadPattern(lineNumber, trimmed, true));
}
} else if (trimmed.length() > 0) {
// no need to fix these for a SubString match-using dictionary
//String fixed = fixVBProWildcards(trimmed);
try {
Pattern regexp = rengine.makeRegexp(trimmed);
PatternNode pattern =
new PatternNodeImpl(trimmed, null, regexp);
dict.addPattern(pattern, cat);
} catch (DuplicateException de){
errors.add(new BadPattern(lineNumber, trimmed, true));
} catch (Exception re) {
errors.add(new BadPattern(lineNumber, trimmed, false));
}