Git Product home page Git Product logo

Comments (4)

kbenoit avatar kbenoit commented on May 23, 2024

Try the dev branch rather than the cran version. And why start with tm at all? Will look at this in more detail next week.

Ken

Sent from my iPhone

On 1 May 2015, at 13:38, adamramey <[email protected]mailto:[email protected]> wrote:

I've tried to get a directory of texts in to a quanteda corpus with some issues. First, I make a VCorpus using the DirSource function in tm. Second, I try to make the object a quanteda corpus. However, I get the error "no applicable method for 'corpus' applied to an object of class "list."" But it's not a list; I've checked the files and everything seems sound.

library(quanteda)
library(tm)
Loading required package: NLP

Attaching package: 'tm'

The following objects are masked from 'package:quanteda':

as.DocumentTermMatrix, stopwords

ds <- VCorpus(DirSource("~/Desktop/Speeches/House/2000/"))
##make it a quanteda object
txts <- corpus(ds)
Error in UseMethod("corpus") :
no applicable method for 'corpus' applied to an object of class "list"
class(ds)
[1] "VCorpus" "Corpus"

Reply to this email directly or view it on GitHubhttps://github.com//issues/37.

from quanteda.

adamramey avatar adamramey commented on May 23, 2024

Was using the dev branch...there used to be a directory function in
quanteda to get a directory of text in, but it seems to be gone. Is there a
new way to do that?

On Fri, May 1, 2015 at 4:46 PM, Kenneth Benoit [email protected]
wrote:

Try the dev branch rather than the cran version. And why start with tm at
all? Will look at this in more detail next week.

Ken

Sent from my iPhone

On 1 May 2015, at 13:38, adamramey <[email protected]<mailto:
[email protected]>> wrote:

I've tried to get a directory of texts in to a quanteda corpus with some
issues. First, I make a VCorpus using the DirSource function in tm. Second,
I try to make the object a quanteda corpus. However, I get the error "no
applicable method for 'corpus' applied to an object of class "list."" But
it's not a list; I've checked the files and everything seems sound.

library(quanteda)
library(tm)
Loading required package: NLP

Attaching package: 'tm'

The following objects are masked from 'package:quanteda':

as.DocumentTermMatrix, stopwords

ds <- VCorpus(DirSource("~/Desktop/Speeches/House/2000/"))
##make it a quanteda object
txts <- corpus(ds)
Error in UseMethod("corpus") :
no applicable method for 'corpus' applied to an object of class "list"
class(ds)
[1] "VCorpus" "Corpus"

Reply to this email directly or view it on GitHub<
https://github.com/kbenoit/quanteda/issues/37>.

Reply to this email directly or view it on GitHub
#37 (comment).

Adam Ramey, Ph.D.
Assistant Professor of Politics
New York University Abu Dhabi

Saadiyat Island
Social Sciences Building (A5) - Room 141
PO Box 129188
Abu Dhabi, United Arab Emirates

Office: +971 2 628 5036
Cell: +971 56 194 5001
E-mail: [email protected]
Website: http://www.adamramey.com

N.B. Abu Dhabi is EST+8 from April-October and EST+9 from November-March.

from quanteda.

kbenoit avatar kbenoit commented on May 23, 2024

Yes ?textfile much better than the old method.

Sent from my iPhone

On 1 May 2015, at 14:49, adamramey <[email protected]mailto:[email protected]> wrote:

Was using the dev branch...there used to be a directory function in
quanteda to get a directory of text in, but it seems to be gone. Is there a
new way to do that?

On Fri, May 1, 2015 at 4:46 PM, Kenneth Benoit <[email protected]mailto:[email protected]>
wrote:

Try the dev branch rather than the cran version. And why start with tm at
all? Will look at this in more detail next week.

Ken

Sent from my iPhone

On 1 May 2015, at 13:38, adamramey <[email protected]mailto:[email protected]<mailto:
[email protected]mailto:[email protected]>> wrote:

I've tried to get a directory of texts in to a quanteda corpus with some
issues. First, I make a VCorpus using the DirSource function in tm. Second,
I try to make the object a quanteda corpus. However, I get the error "no
applicable method for 'corpus' applied to an object of class "list."" But
it's not a list; I've checked the files and everything seems sound.

library(quanteda)
library(tm)
Loading required package: NLP

Attaching package: 'tm'

The following objects are masked from 'package:quanteda':

as.DocumentTermMatrix, stopwords

ds <- VCorpus(DirSource("~/Desktop/Speeches/House/2000/"))
##make it a quanteda object
txts <- corpus(ds)
Error in UseMethod("corpus") :
no applicable method for 'corpus' applied to an object of class "list"
class(ds)
[1] "VCorpus" "Corpus"

Reply to this email directly or view it on GitHub<
https://github.com/kbenoit/quanteda/issues/37>.

Reply to this email directly or view it on GitHub
#37 (comment).

Adam Ramey, Ph.D.
Assistant Professor of Politics
New York University Abu Dhabi

Saadiyat Island
Social Sciences Building (A5) - Room 141
PO Box 129188
Abu Dhabi, United Arab Emirates

Office: +971 2 628 5036
Cell: +971 56 194 5001
E-mail: [email protected]:[email protected]
Website: http://www.adamramey.com

N.B. Abu Dhabi is EST+8 from April-October and EST+9 from November-March.

Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-98126349.

from quanteda.

pnulty avatar pnulty commented on May 23, 2024

Hi Adam, thanks for this feedback. We re-wrote this section substantially a couple of months ago and the directory import is not properly documented. The best way to do it currently is to use a filepath with a wildcard expression (a glob),for example this works:

library(quanteda)
myCorp <- corpus(textfile(file='~/Dropbox/QUANTESS/corpora/amicus/balanced/*'))
summary(myCorp)

You should also be able to use the wildcard to select only certain filetypes, e.g. /*.txt

I was also able to reproduce the first problem you mention, which seems to be a bug in our VCorpus import method - the extracted texts weren't typed as a character vector. I've made a change and pushed it, this now works on my system.

ds <- VCorpus(DirSource('~/Dropbox/QUANTESS/corpora/amicus/balanced/'))
corpus(ds)

Let me know if it works for you if you re-install the dev branch from github now.

from quanteda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.