@@ -42,11 +42,12 @@ const defaultOptions = {
4242
4343
4444/*
45- 1. Paragraph Node -> text
46- 2. text -> sentences
47- 3. tokenize sentence
48- 4. report error if found word that match the rule.
45+ 1. Paragraph Node -> text
46+ 2. text -> sentences
47+ 3. tokenize sentence
48+ 4. report error if found word that match the rule.
4949
50+ TODO: need abstraction
5051 */
5152export default function ( context , options = { } ) {
5253 const helper = new RuleHelper ( context ) ;
@@ -60,18 +61,20 @@ export default function (context, options = {}) {
6061 return ;
6162 }
6263 const source = new StringSource ( node ) ;
63- let text = source . toString ( ) ;
64+ const text = source . toString ( ) ;
65+ const isSentenceNode = node => {
66+ return node . type === SentenceSyntax . Sentence ;
67+ } ;
6468 let sentences = splitSentences ( text , {
6569 charRegExp : / [ 。 \? \! ? ! ] /
66- } ) . filter ( node => {
67- return node . type === SentenceSyntax . Sentence ;
68- } ) ;
70+ } ) . filter ( isSentenceNode ) ;
6971 return getTokenizer ( ) . then ( tokenizer => {
7072 const checkSentence = ( sentence ) => {
7173 let tokens = tokenizer . tokenizeForSentence ( sentence . raw ) ;
72- let joshiTokens = tokens . filter ( token => {
74+ const isJoshiToken = token => {
7375 return token . pos === "助詞" ;
74- } ) ;
76+ } ;
77+ let joshiTokens = tokens . filter ( isJoshiToken ) ;
7578 let joshiTokenSurfaceKeyMap = createSurfaceKeyMap ( joshiTokens ) ;
7679 /*
7780 # Data Structure
0 commit comments