@@ -42,11 +42,12 @@ const defaultOptions = {
42
42
43
43
44
44
/*
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.
49
49
50
+ TODO: need abstraction
50
51
*/
51
52
export default function ( context , options = { } ) {
52
53
const helper = new RuleHelper ( context ) ;
@@ -60,18 +61,20 @@ export default function (context, options = {}) {
60
61
return ;
61
62
}
62
63
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
+ } ;
64
68
let sentences = splitSentences ( text , {
65
69
charRegExp : / [ 。 \? \! ? ! ] /
66
- } ) . filter ( node => {
67
- return node . type === SentenceSyntax . Sentence ;
68
- } ) ;
70
+ } ) . filter ( isSentenceNode ) ;
69
71
return getTokenizer ( ) . then ( tokenizer => {
70
72
const checkSentence = ( sentence ) => {
71
73
let tokens = tokenizer . tokenizeForSentence ( sentence . raw ) ;
72
- let joshiTokens = tokens . filter ( token => {
74
+ const isJoshiToken = token => {
73
75
return token . pos === "助詞" ;
74
- } ) ;
76
+ } ;
77
+ let joshiTokens = tokens . filter ( isJoshiToken ) ;
75
78
let joshiTokenSurfaceKeyMap = createSurfaceKeyMap ( joshiTokens ) ;
76
79
/*
77
80
# Data Structure
0 commit comments