Very minor clean-up.
This commit is contained in:
parent
4cbaa5d45f
commit
21e15172a7
|
@ -35,17 +35,16 @@ public class Composer {
|
||||||
Window preamble = composePreamble(rules);
|
Window preamble = composePreamble(rules);
|
||||||
WordSequence result = new WordSequence();
|
WordSequence result = new WordSequence();
|
||||||
|
|
||||||
// composing the preamble will have ended with *ROOT* on top of the
|
/* composing the preamble will have ended with *ROOT* on top of the
|
||||||
// stack;
|
* stack; get rid of it. */
|
||||||
// get rid of it.
|
|
||||||
preamble.pop();
|
preamble.pop();
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
System.err.println("Preamble: " + preamble);
|
|
||||||
}
|
|
||||||
|
|
||||||
Window copy = preamble.duplicate();
|
Window copy = preamble.duplicate();
|
||||||
Collections.reverse(copy);
|
Collections.reverse(copy);
|
||||||
|
if (debug) {
|
||||||
|
System.err.println("Preamble: " + copy);
|
||||||
|
}
|
||||||
|
|
||||||
result.addAll(copy);
|
result.addAll(copy);
|
||||||
|
|
||||||
result.addAll(this.compose(preamble, rules, length));
|
result.addAll(this.compose(preamble, rules, length));
|
||||||
|
|
|
@ -87,9 +87,7 @@ class Writer extends BufferedWriter {
|
||||||
|
|
||||||
this.maybeParagraph(token);
|
this.maybeParagraph(token);
|
||||||
|
|
||||||
return (token.endsWith(Milkwood.PERIOD) ||
|
return (endOfSentence(token));
|
||||||
token.equals("?") ||
|
|
||||||
token.endsWith("!"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,19 +142,32 @@ class Writer extends BufferedWriter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this token is an end-of-sentence token, then, on one chance in some,
|
* If this token is an end-of-sentence token, then, on one chance in some,
|
||||||
* have the writer write two new lines. NOTE: The tokeniser is treating
|
* have the writer write two new lines.
|
||||||
* PERIOD ('.') as a word character, even though it has not been told to.
|
|
||||||
* Token.endsWith( PERIOD) is a hack to get round this problem. TODO:
|
|
||||||
* investigate and fix.
|
|
||||||
*
|
*
|
||||||
* @param token a token
|
* @param token a token
|
||||||
* @throws IOException if Mr this has run out of ink
|
* @throws IOException if Mr this has run out of ink
|
||||||
*/
|
*/
|
||||||
private void maybeParagraph(String token) throws IOException {
|
private void maybeParagraph(String token) throws IOException {
|
||||||
if (token.endsWith(Milkwood.PERIOD)
|
if (this.endOfSentence(token)
|
||||||
&& RANDOM.nextInt(AVSENTENCESPERPARA) == 0) {
|
&& RANDOM.nextInt(AVSENTENCESPERPARA) == 0) {
|
||||||
this.write(NEWLINE);
|
this.write(NEWLINE);
|
||||||
this.write(NEWLINE);
|
this.write(NEWLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this token mark the end of a sentence? NOTE: The tokeniser is
|
||||||
|
* treating PERIOD ('.') as a word character, even though it has not been
|
||||||
|
* told to. Token.endsWith( PERIOD) is a hack to get round this problem.
|
||||||
|
* TODO: investigate and fix.
|
||||||
|
*
|
||||||
|
* @param token a token.
|
||||||
|
* @return True if in conventional orthography this token should mark the
|
||||||
|
* end of a sentence, else false.
|
||||||
|
*/
|
||||||
|
private boolean endOfSentence(String token) {
|
||||||
|
return token.endsWith(Milkwood.PERIOD)
|
||||||
|
|| token.equals("?")
|
||||||
|
|| token.endsWith("!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue