import { isStartOrEndInArray , rule , visit } from "./utils" ; import { isWhiteSpace } from "nlcst-types" ; import { isSlash , Punctuation } from "nlcst-parser-chinese" ; import * as ZHError from "./error" ; export const ZH414 = rule ( ":ZH414" , ( tree , file ) => { visit ( tree , "SentenceNode" , ( _sen ) => { visit ( _sen , Punctuation , ( node , i , parent ) => { if ( isSlash ( node ) && ! isStartOrEndInArray ( i , parent . children ) ) { if ( isWhiteSpace ( parent . children [ i - 1 ] ) ) { file . message ( ZHError . ZH414L , node ?. position ?. start ) ; } if ( isWhiteSpace ( parent . children [ i + 1 ] ) ) { file . message ( ZHError . ZH414R , node ?. position ?. end ) ; } } } ) ; } ) ; } ) ;