String R能否检测word文件中的重复句子?

String R能否检测word文件中的重复句子?,string,r,duplicate-detection,String,R,Duplicate Detection,我有一个word文档包含100页,希望检测重复的句子。 有没有办法在R中自动执行此操作 1-转换为txt文件 2读: 这里是我之前使用的一个小代码块,它松散地基于Matloff的《R编程的艺术》,他在其中使用了类似的东西作为示例: sent <- "This is a sentence. Here comes another sentence. This is a sentence. This is a sentence. Sentence after sentence. This is

我有一个word文档包含100页,希望检测重复的句子。 有没有办法在R中自动执行此操作

1-转换为txt文件 2读:


这里是我之前使用的一个小代码块,它松散地基于Matloff的《R编程的艺术》,他在其中使用了类似的东西作为示例:

 sent <- "This is a sentence. Here comes another sentence. This is a sentence. This is a sentence. Sentence after sentence. This is two sentences."
现在,这可能看起来很笨拙,但请容忍我:

 outlist <- list()
 for(i in 1:length(unlist(out))){
   outlist[[out[[1]][i]]] <- c(outlist[[out[[1]][i] ]],i)
 }

这里是我之前使用的一个小代码块,它松散地基于Matloff的《R编程的艺术》,他在其中使用了类似的东西作为示例:

 sent <- "This is a sentence. Here comes another sentence. This is a sentence. This is a sentence. Sentence after sentence. This is two sentences."
现在,这可能看起来很笨拙,但请容忍我:

 outlist <- list()
 for(i in 1:length(unlist(out))){
   outlist[[out[[1]][i]]] <- c(outlist[[out[[1]][i] ]],i)
 }

您可能应该首先将其转换为文本文件,以避免特殊字符和格式。据我所知,这不是完全自动化的,但您可以:1)将文档转换为txt,2)使用
读线导入R,3)在句点上使用
strsplit
拆分为句子,4)使用
gsub
删除额外的空白,5)使用
复制的
@BrodieG比我快:-)我会等你的答案。大小写差异算吗?正如布罗迪格所建议的,您可能需要进行几次“清理”操作。@sacvf,如果您能提供一个可复制的示例,我很乐意这样做,但实际上,你应该试着用你的数据采取我首先概述的步骤,看看你是否能在我提到的函数的R文档的帮助下自己解决它。你可能应该首先将其转换为文本文件,以避免特殊字符和格式。据我所知,这不是完全自动化的,但是你可以:1)将doc转换为txt,2)使用
读线
导入R,3)在句点上使用
strsplit
拆分成句子,4)使用
gsub
删除额外的空格,5)使用
复制的
@BrodieG击败我:-)我会等待你的答案。大小写差异是否算数?正如BrodieG所建议的,您可能需要进行几次“清理”操作。@sacvf,如果您提供了一个可复制的示例,我很乐意这样做,但实际上您应该尝试使用数据执行我首先概述的步骤,看看您是否可以在我提到的函数的R文档的帮助下自己解决这个问题。
 > outlist
 $`This is a sentence`
 [1] 1 3 4
 $`Here comes another sentence`
 [1] 2
 $`Sentence after sentence`
 [1] 5
 $`This is two sentences`
 [1] 6