读取pdf文件后删除连字符

tobowtobow 成员职位:5新手
你好,

我对RapidMiner很陌生。我正在阅读德文pdf文件和令牌化它们,这是正常工作…然而,pdf文件包含连字符,将相当数量的单词分隔为两部分,如下面的例子:

“die Bedeutung der finan-”

ziellen Interessen der Union"

m trying to dehyphenate the broken text to:

"在金融联盟中死去"

我使用替换令牌操作符来连接行并删除“-”。当我用运算符中的例子尝试它时,它是有效的,但当我玩这个过程时,单词仍然都是坏的,似乎没有任何东西被替换。也许社区里有人能帮上忙?提前谢谢!以下是我的过程:

<?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程version = " 9.10.001”>

> <上下文

<输入/ >

<输出/ >

<宏/ >

> < /上下文

. class="process

<参数键= " logverbosity " value = " init " / >

<参数键= " random_seed " value = " 2001 " / >

<参数键= " send_mail " value = "永远" / >

<参数键= " notification_email“价值= " / >

<参数键= " process_duration_for_mail " value = " 30 " / >

<参数键=“编码”值= "系统" / >

<过程扩展= " true " >

<参数键= " repository_entry " value = " BPW_Dictionary_zusammengefasst " / >

< /操作符>

<参数键= " value_attribute " value = " C " / >

<参数键= " key_attribute " value = " " / >

<参数键= " negation_attribute“价值= " / >

<参数键= " negation_window_size " value = " 1 " / >

<参数键= " negation_strength“价值= " / >

<参数键= " use_symmetric_negation_window " value = " false " / >

<参数键= " use_intensifier " value = " false " / >

<参数键= " intensifier_word“价值= " / >

<参数键= " intensifier_value“价值= " / >

<参数键= " use_symmetric_intensifier_window " value = " false " / >

< /操作符>

.

<参数键= " filter_type " value = "一滴" / >

<参数键=“递归”价值= " true " / >

<参数键= " enable_macros " value = " false " / >

<参数键= " macro_for_file_name " value = " file_name " / >

<参数键= " macro_for_file_type " value = " file_type " / >

<参数键= " macro_for_folder_name " value = " folder_name " / >

<参数键= " reuse_results " value = " false " / >

<参数键= " enable_parallel_execution " value = " true " / >

<过程扩展= " true " >

<参数键= " extract_text_only " value = " true " / >

<参数键= " use_file_extension_as_type " value = " true " / >

<参数键= " content_type " value = " pdf " / >

<参数键=“编码”值= "系统" / >

< /操作符>

<参数键= " repository_entry " value = " Stopwords_zusammengefasst " / >

< /操作符>

.

.

< / >列表

< /操作符>

<列出关键= " replace_dictionary " >

<参数键= " ()" value = " $ 1 " / >

< / >列表

< /操作符>

.

<参数键= "字符" value = ": " / >

<参数键= "语言" value = "德国" / >

<参数键= " max_token_length " value = " 3 " / >

< /操作符>

.

<参数键= " max_chars " value = " 999 " / >

< /操作符>

< /操作符>

<参数键= "属性" value = " " / >

<参数键= " case_sensitive " value = " true " / >

<参数键= " invert_filter " value = " false " / >

< /操作符>

/> .

.

> < /过程

< /操作符>

< /操作符>


最佳答案

  • BalazsBaranyBalazsBarany 管理员,版主,员工,RapidMiner认证分析师,RapidMiner认证专家职位:828独角兽
    解决方案接受
    这就跟你问声好!

    尝试一些或\n\r的组合,而不是只\n。
    \n是“Unix行结束符”,只是一个换行符。
    回车+换行,这是Windows的传统。

    这取决于你的文件和它们的处理方式。

    问候,
    Balazs

答案

  • BalazsBaranyBalazsBarany 管理员,版主,员工,RapidMiner认证分析师,RapidMiner认证专家职位:828独角兽
    你好,

    我建议使用不同的正则表达式更换令牌(2)



    回复:([^])- +(\w)
    替换:$ 1 $ 2

    这应该更健壮一些。It searches for a non-space before the hyphen, one or more spaces and then a word character.

    然而,问题是只有第一个匹配被替换,正如您在示例中看到的那样。因此,您可能需要在循环中重复该操作符,并选中“重用结果”。

    问候,
    Balazs

    tobow
  • tobowtobow 成员职位:5新手
    嗨,Balazs,

    谢谢你的帮助,你推荐的正则表达式工作棒极了!我还在努力解决的唯一问题是,它只在我使用“创建文档”操作符时有效,所以我必须手动从pdf文件中传输文本。当我在pdf或txt文件上尝试“读取文档”操作符时,似乎\n命令不起作用,换行符没有被删除。你或其他关注这篇文章的人知道如何解决这个问题吗?或者是否有一种方法来读取pdf文件并自动在RapidMiner中创建文档?

    谢谢微笑:
  • tobowtobow 成员职位:5新手
    编辑2月8日
    嗨,Balazs,

    再次感谢您的帮助!r\n|\r|\n这个短语对我来说很管用。

    愿一切都好!:)
登录注册置评。