String pageName = elements[0];
String[] elementsReplacement = elements[3].split(",");
Page page = pages.get(pageName);
if ((page != null) && (page.getContents() != null)) {
String contents = page.getContents();
PageAnalysis analysis = page.getAnalysis(contents, true);
Collection<PageElementTemplate> templates = analysis.getTemplates(elements[1]);
for (PageElementTemplate template : templates) {
String chapterId = PageAnalysisUtils.getCurrentChapterId(analysis, template.getBeginIndex());
if ((suggestionIgnore == null) || (!suggestionIgnore.contains(chapterId))) {
String patternText = template.getParameterValue(elements[2]);
Suggestion suggestion = tmpMap.get(patternText);
if (suggestion == null) {
String chapter = PageAnalysisUtils.getCurrentChapterId(analysis, template.getBeginIndex());
suggestion = Suggestion.createSuggestion(patternText, false, chapter);
if (suggestion != null) {
tmpMap.put(patternText, suggestion);
}
}
if (suggestion != null) {
boolean automatic = false;
if (elements.length > 4) {
suggestion.setComment(template.getParameterValue(elements[4]));
if (elements.length > 6) {
if (elements[6].equalsIgnoreCase(template.getParameterValue(elements[5]))) {
automatic = true;
}
}
}
for (String elementReplacement : elementsReplacement) {
String replacementText = template.getParameterValue(elementReplacement);
if ((replacementText != null) &&
(replacementText.length() > 0)) {
suggestion.addReplacement(replacementText, automatic);
}
}
}
}
}
}
}
}
}
// Construct suggestions from AWB format
if (suggestionTypoPages != null) {
List<String> suggestionIgnore = getStringList(WPCConfigurationStringList.SUGGESTION_IGNORE);
for (String suggestionPage : suggestionTypoPages) {
Page page = pages.get(suggestionPage);
if ((page != null) && (page.getContents() != null)) {
String contents = page.getContents();
PageAnalysis analysis = page.getAnalysis(contents, true);
Collection<PageElementTag> tags = analysis.getTags(PageElementTag.TAG_OTHER_TYPO);
for (PageElementTag tag : tags) {
String chapterId = PageAnalysisUtils.getCurrentChapterId(analysis, tag.getBeginIndex());
if ((suggestionIgnore == null) || (!suggestionIgnore.contains(chapterId))) {
Parameter word = tag.getParameter("word");
Parameter find = tag.getParameter("find");