sentence-splitter
Version:
split {japanese, english} text into sentences.
23 lines (20 loc) • 526 B
text/typescript
import { SourceCode } from "./SourceCode.js";
import { AbstractParser } from "./AbstractParser.js";
/**
* Space parser
*/
export class SpaceParser implements AbstractParser {
test(sourceCode: SourceCode) {
const string = sourceCode.read();
if (!string) {
return false;
}
// space without new line
return /[^\S\n\r]/.test(string);
}
seek(sourceCode: SourceCode): void {
while (this.test(sourceCode)) {
sourceCode.peek();
}
}
}