1
votes

I want to read a single file as a single document in a corpus but didnt find any sloution,i have tried with

>fdat <- readLines(fname)
> reuters=suppressWarnings(Corpus(VectorSource(fdat),readerControl = list(language = "en")))
> reuters
A corpus with 139 text documents

Or Is it possible to choose some selected files form a directory within a corpus

#reading all the files within directory
Corpus(DirSource("C:/test"), readerControl=list(language="eng", reader=readPlain))

as in I want to read "c:/test/abc.txt" and "c:/test/xyz.txt" only from directory and each file as an document.any help,thanks.

1

1 Answers

3
votes

Use pattern to match the file names:

DirSource(directory=path_directory,pattern="abc.txt|xyz.txt")