Watts-College / cpp-527-spr-2022

https://watts-college.github.io/cpp-527-spr-2022/
0 stars 1 forks source link

Lab 4 Part 2 #25

Closed mmonakho closed 2 years ago

mmonakho commented 2 years ago

When running this chunk of code...

tokens <- tokens( corp, what="word", remove_punct=TRUE )

...getting this error:

Error: tokens() only works on character, corpus, list, tokens objects.

mmonakho commented 2 years ago

Which doesn't make sense because I checked the type of corp variable...

typeof(corp) [1] "character"

Dselby86 commented 2 years ago

Can you post the code that declares the Corp object

On Tue, Feb 8, 2022, 7:15 PM mmonakho @.***> wrote:

Which doesn't make sense because I checked the type of corp variable...

typeof(corp) [1] "character"

— Reply to this email directly, view it on GitHub https://github.com/Watts-College/cpp-527-spr-2022/issues/25#issuecomment-1033267443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4EHB5AOKG5ZWXOSDC3PILU2HE5HANCNFSM5N4FIKVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

mmonakho commented 2 years ago

I copy-pasted it at from the lab instructions: dat$mission <- tolower( dat$mission ) set.seed(1986) dat.sample <- dat[ sample( 1:50000, size=1000 ) , ] corp <- corpus( dat.sample, text_field="mission" ) corp <- ?corpus_trim(corp, what="sentences", min_token=3)

Actually, this part doesn't work either: corp <- corpus_trim(corp, what="sentences", min_token=3)

Gives this error: Error in corpus_trim(corp, what = "sentences", min_token = 3) : could not find function "corpus_trim"

Dselby86 commented 2 years ago

make sure you have all of the packages loaded.

library( dplyr ) library( pander ) library( quanteda ) library( quanteda.textmodels ) library( quanteda.textstats ) library( quanteda.textplots )

Also the line you just linked should be:

corpustrim( corp, what="sentences", minntoken=3 )

For your first question carefully follow your corp object through the code until it gets to the tokens line. The command you posted is correct, and it should work. It looks like somewhere you either overwrote your corp object, or something went wrong with loading your packages

On Tue, Feb 8, 2022 at 9:19 PM mmonakho @.***> wrote:

I copy-pasted it at from the lab instructions: dat$mission <- tolower( dat$mission ) set.seed(1986) dat.sample <- dat[ sample( 1:50000, size=1000 ) , ] corp <- corpus( dat.sample, text_field="mission" ) corp <- ?corpus_trim(corp, what="sentences", min_token=3)

Actually, this part doesn't work either: corp <- corpus_trim(corp, what="sentences", min_token=3)

Gives this error: Error in corpus_trim(corp, what = "sentences", min_token = 3) : could not find function "corpus_trim"

— Reply to this email directly, view it on GitHub https://github.com/Watts-College/cpp-527-spr-2022/issues/25#issuecomment-1033330658, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4EHB5RUW54XO5DWR5DIM3U2HTMLANCNFSM5N4FIKVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

mmonakho commented 2 years ago

That missing n was the problem... thank you very much for your help!