使用 Solr 3.5.0 和在我的模式中.xml我使用以下方法来标记句子的结尾,并将结束标点符号替换为符号标记:
<charFilter class="solr.PatternReplaceCharFilterFactory"
pattern="(?<=[^.!?\s][^.!?]*(?:[.!?](?![']?s|$)[^.!?]*)*)[.!?]+(?=\s|$)"
replacement=" monkeysentence"/>
我不确定这是否适用于我想要的,但首先我需要解决在第一个"?<="外观中转义"<"字符的问题。
我收到以下错误:
org.xml.sax.SAXParseException: The value of attribute "pattern"
associated with an element type "null" must not contain the '<' character.
我尝试使用"\",如下所示:
pattern="(?<=[^.!?\s][^.!?]*(?:[.!?](?![']?s|$)[^.!?]*)*)[.!?]+(?=\s|$)"
但是我得到了同样的错误。
由于这是在XML文件中,因此需要使用XML转义来编码<
,即<
(您可能还需要将>
编码为>
,"
编码为"
,&
编码为&
)