Minor clean up. Question marks and exclamation marks (also closing brackets) now printed without leading white space. Also, question marks and exclamation marks treated as end-of-sentence.

Finally the first tuple-Length words were emitted in reverse order - fixed.
This commit is contained in:
simon 2013-10-31 14:07:34 +00:00
parent d91fdcab16
commit 4cbaa5d45f
2 changed files with 11 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package cc.journeyman.milkwood;
import java.util.Collection;
import java.util.Collections;
/**
* Composes text output based on a rule tree.
@ -43,7 +44,9 @@ public class Composer {
System.err.println("Preamble: " + preamble);
}
result.addAll(preamble);
Window copy = preamble.duplicate();
Collections.reverse(copy);
result.addAll(copy);
result.addAll(this.compose(preamble, rules, length));

View file

@ -87,7 +87,9 @@ class Writer extends BufferedWriter {
this.maybeParagraph(token);
return (token.endsWith(Milkwood.PERIOD));
return (token.endsWith(Milkwood.PERIOD) ||
token.equals("?") ||
token.endsWith("!"));
}
/**
@ -112,6 +114,10 @@ class Writer extends BufferedWriter {
case ',':
case ':':
case ';':
case '!':
case '?':
case ')':
case ']':
case 's':
/*
* an 's' on its own is probably evidence of a possessive with