【问题标题】:Delete hyphen (special chars) while processing text in RapidMiner在 RapidMiner 中处理文本时删除连字符(特殊字符)
【发布时间】:2016-06-08 11:06:31
【问题描述】:

我想删除我在 Rapidminer 中分析的文本文档中的所有连字符。为此,我使用运算符“处理文件中的文档”来分析大型 PDF 文件。每个文件都包含很多连字符,在将文本标记为片段(非字母)之前,我想删除这些连字符。我使用了运算符“替换令牌”。有了它,我可以用其他符号替换连字符,但我不能用空字符串(“”)替换它们。我也尝试使用我自己定制的停用词词典(非字母,-)。这个运算符根本不工作。我已将包含要删除的字符和单词的字典保存为文本文件(每个都在新行中)。有人可以帮助解决这个问题吗?

【问题讨论】:

    标签: replace text-mining rapidminer hyphen


    【解决方案1】:

    您可以将Replace Tokens 与以下参数一起使用。

    replace what()[-]

    replace by$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 &#10;with&#10;some-text-with-hyphens-in&#10;hyphens in&#10;"/>
          </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>
    

    希望能有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2012-02-25
      相关资源
      最近更新 更多