Replace 在RapidMiner中处理文本时删除连字符(特殊字符)
我想删除我在Rapidminer中分析的文本文档中的所有连字符。为此,我使用操作符“从文件处理文档”来分析大型PDF文件。每个文件都包含许多连字符,我想在将文本标记为片段(非字母)之前删除这些连字符。我使用了运算符“替换令牌”。有了它,我可以用其他符号替换连字符,但我不能用空字符串(“”)替换它们。我还尝试使用自己定制的stopwords词典(非字母,-)。这个操作员根本不工作。我已将包含我要删除的字符和单词的字典保存为文本文件(每一个都在新行中)。有人能在这个问题上帮忙吗 您可以使用以下参数使用Replace 在RapidMiner中处理文本时删除连字符(特殊字符),replace,text-mining,rapidminer,hyphen,Replace,Text Mining,Rapidminer,Hyphen,我想删除我在Rapidminer中分析的文本文档中的所有连字符。为此,我使用操作符“从文件处理文档”来分析大型PDF文件。每个文件都包含许多连字符,我想在将文本标记为片段(非字母)之前删除这些连字符。我使用了运算符“替换令牌”。有了它,我可以用其他符号替换连字符,但我不能用空字符串(“”)替换它们。我还尝试使用自己定制的stopwords词典(非字母,-)。这个操作员根本不工作。我已将包含我要删除的字符和单词的字典保存为文本文件(每一个都在新行中)。有人能在这个问题上帮忙吗 您可以使用以下参数使
替换令牌
替换什么
()[-]
替换为
$1
这有点像黑客,但它可以工作,因为括号之间的第一个捕获组总是空的,整个正则表达式将匹配一个连字符。$1
是第一个捕获组的结果,它始终为空
下面是一个示例流程,说明了这一点
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="7.0.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="7.0.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="text:create_document" compatibility="7.0.000" expanded="true" height="68" name="Create Document" width="90" x="246" y="187">
<parameter key="text" value="some text with some-text-with-hyphens-in hyphens in "/>
</operator>
<operator activated="true" class="text:replace_tokens" compatibility="7.0.000" expanded="true" height="68" name="Replace Tokens" width="90" x="447" y="187">
<list key="replace_dictionary">
<parameter key="()[-]" value="$1"/>
</list>
</operator>
<operator activated="true" class="text:process_documents" compatibility="7.0.000" expanded="true" height="103" name="Process Documents" width="90" x="648" y="187">
<parameter key="vector_creation" value="Term Occurrences"/>
<process expanded="true">
<operator activated="true" class="text:tokenize" compatibility="7.0.000" expanded="true" height="68" name="Tokenize" width="90" x="179" y="85"/>
<connect from_port="document" to_op="Tokenize" to_port="document"/>
<connect from_op="Tokenize" from_port="document" to_port="document 1"/>
<portSpacing port="source_document" spacing="0"/>
<portSpacing port="sink_document 1" spacing="0"/>
<portSpacing port="sink_document 2" spacing="0"/>
</process>
</operator>
<connect from_op="Create Document" from_port="output" to_op="Replace Tokens" to_port="document"/>
<connect from_op="Replace Tokens" from_port="document" to_op="Process Documents" to_port="documents 1"/>
<connect from_op="Process Documents" from_port="example set" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>
希望以此为基础有所帮助