[codeface] [PATCH 3/4] Use tm_map function

  • From: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Fri, 2 Oct 2015 10:44:44 +0200

- No need to use lapply here

Signed-off-by: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
---
codeface/R/ml/analysis.r | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/codeface/R/ml/analysis.r b/codeface/R/ml/analysis.r
index 2f97cb4..4cc2422 100644
--- a/codeface/R/ml/analysis.r
+++ b/codeface/R/ml/analysis.r
@@ -275,16 +275,13 @@ check.corpus.precon <- function(corp.base) {
fix.corpus <- function(doc) {
meta(doc, tag="header") <- rmv.multi.refs(doc)
meta(doc, tag="author") <- fix.author(doc)
-
return(doc)
}

## Apply checks and fixes for all preconditions to all
## documents in the corpus
- idx <- 1:length(corp.base$corp)
- for (i in idx) {
- corp.base$corp[[i]] <- fix.corpus(corp.base$corp[[i]])
- }
+ corp.base$corp <- tm_map(corp.base$corp, fix.corpus)
+ class(corp.base$corp) <- class(corp.base$corp.orig)

return(corp.base)
}
--
2.1.4


Other related posts:

  • » [codeface] [PATCH 3/4] Use tm_map function - Mitchell Joblin