Revision: 12679
http://sourceforge.net/p/foray/code/12679
Author: victormote
Date: 2022-06-21 17:01:55 +0000 (Tue, 21 Jun 2022)
Log Message:
-----------
Improvements to terminal element processing.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java 2022-06-21 16:24:03 UTC (rev 12678)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java 2022-06-21 17:01:55 UTC (rev 12679)
@@ -150,7 +150,8 @@
private List<String> elementIgnoreList = Arrays.asList(new String[] {"Page", "MendOut", "Comment", "ToDo"});
/** The list of elements that should never be straddled by a word. */
- private List<String> elementTerminalList = Arrays.asList(new String[] {"Para", "Sidenote"});
+ private List<String> elementTerminalList = Arrays.asList(new String[] {"Para", "Sidenote", "Signature", "EmDash",
+ "PoetryLine", "Title", "Subtitle", "Dateline", "TitlePara"});
/** Map whose key is elements that are actually tokens for text, and whose value is that text. */
private Map<String, String> textElementMap = new HashMap<String, String>();
@@ -252,7 +253,8 @@
final WritingSystem4a newWritingSystem = parseWritingSystem(attributes);
element.writingSystem = newWritingSystem;
- if (! ObjectUtils.safeEquals(oldWritingSystem, newWritingSystem)) {
+ if (newWritingSystem != null
+ && ! ObjectUtils.safeEquals(oldWritingSystem, newWritingSystem)) {
checkWords(oldWritingSystem);
}
this.elementStack.push(element);
@@ -312,7 +314,7 @@
for (int index = 0; index < words.size(); index ++) {
if (index % 2 == 0) {
final CharSequence word = words.get(index);
- checkWord(orthography, word);
+ checkWord(writingSystem, orthography, word);
}
}
}
@@ -319,10 +321,12 @@
/**
* Spell-check a word.
+ * @param writingSystem The writing system, used for error messages.
* @param orthography The orthography to be used to spell-check {@code word}.
* @param word The word to be checked.
*/
- private void checkWord(final Orthography4a orthography, final CharSequence word) {
+ private void checkWord(final WritingSystem4a writingSystem, final Orthography4a orthography,
+ final CharSequence word) {
/* The word breaker can return empty words when the parsed text begins with non-word content. */
if (word.length() < 1) {
return;
@@ -339,7 +343,7 @@
}
final String message = String.format("Not found: %s %s %s", word, getShortLocationString(getLocator()),
- getCurrentWritingSystem().toString());
+ writingSystem.toString());
this.output.println(message);
this.notFoundCounter ++;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|