Giter VIP home page Giter VIP logo

Comments (15)

seancarmody avatar seancarmody commented on August 16, 2024 1

It's a bit of a cat and mouse game with ngram - Google doesn't provide an API so it's all about scraping and keeping up with their obfuscation changes. I have to admit it's been a long time since I wrote this package so it might take me a while to get back up to speed and work out what's broken! I'll see what I can do - but no promises...

from ngramr.

tsoukinator avatar tsoukinator commented on August 16, 2024 1

Thanks again Sean! This package truly makes my life easier, and I'm really looking forward to using it!

from ngramr.

jirzii avatar jirzii commented on August 16, 2024

I have the same problem. Would be very grateful for a fix!!

from ngramr.

seancarmody avatar seancarmody commented on August 16, 2024

I have pushed a new version to GitHub (not yet to CRAN). Let me know if the problem has been resolved.

from ngramr.

tsoukinator avatar tsoukinator commented on August 16, 2024

Thanks for getting back to this. It still appears there is another issue now.

Error in pivot_longer(df, -Year, names_to = "Phrase", values_to = "Frequency") : could not find function "pivot_longer"

4. | ngram_single(phrases, corpus = corp, year_start = year_start, year_end = year_end, smoothing = smoothing, tag = tag, case_ins)
3. FUN(X[[i]], ...)
2. | lapply(corpus, function(corp) ngram_single(phrases, corpus = corp, year_start = year_start, year_end = year_end, smoothing = smoothing, tag = tag, case_ins))
1. | ngramr::ngram("dog")

from ngramr.

seancarmody avatar seancarmody commented on August 16, 2024

Hi - the package now requires tidyr, so try installing that package first and see if that helps.
Sean.

from ngramr.

seancarmody avatar seancarmody commented on August 16, 2024

I've also changed the way the tidyr function is called so you may need to reinstall ngramr too.
Sean.

from ngramr.

tsoukinator avatar tsoukinator commented on August 16, 2024

Thanks Sean - when explicitly loading "library(tidyr)" after loading library(ngramr) this was able to work!

library(devtools)
install_github("seancarmody/ngramr")

library(ngramr)
library(tidyr)

dog <- ngramr::ngrami("dog")
dog

There might be some point in your package where you can state tidyr as a dependency, so it loads automatically for your users.
In my package rhymebrainR, I have a devstuffs.R file, which contains the following dependencies of my package. Potentially stating tidyr in this fashion will allow the package to load with your ngramr package.

# Get the dependencies
use_package("httr")
use_package("jsonlite")
use_package("curl")
use_package("attempt")
use_package("purrr")

One last note I'll make, is on your package description page, the command you have to install/load your package from GitHub doesn't seem to work with my version of R (perhaps this was a previous method?).

To install the package from your GitHub account, I had to use the following code:

library(devtools)
install_github("seancarmody/ngramr")

Lastly Sean - thanks for providing this fix - assuming you're in the States, it should technically still be my birthday - and it is a sweet gift at that!
I'm looking forward to using this package in one of my hobby projects! Thanks so much for fixing it!
~ Final edit, noticed you're another Aussie! In that case, cheers!

from ngramr.

seancarmody avatar seancarmody commented on August 16, 2024

Thanks for the feedback! I thought I'd updated the dependency on tidyr but my R package skills are a bit rusty so I did it in the wrong place. I'm hoping it works now without the explicit call to library(tidyr). If there are still problems, do let me know.

On the install_github, you're right, the syntax for the function has changed, so I've updated the README.

Enjoy and a belated Happy Birthday.

from ngramr.

tsoukinator avatar tsoukinator commented on August 16, 2024

from ngramr.

seancarmody avatar seancarmody commented on August 16, 2024

Sorry about that! Result of poorly executed switch from the (old) ddply to dplyr Should be fixed now.

from ngramr.

tsoukinator avatar tsoukinator commented on August 16, 2024

from ngramr.

seancarmody avatar seancarmody commented on August 16, 2024

Note: I've redeveloped a lot of the underlying code which will (hopefully) make it more robust and provide better warnings. If you have a chance, have a look at the development version and let me know if it causes any problems (note if you use the "tag" argument in ngram that won't work anymore - I've removed it). When I'm confident it's stable I plan to replace the master version and republish on CRAN.

from ngramr.

jirzii avatar jirzii commented on August 16, 2024

from ngramr.

seancarmody avatar seancarmody commented on August 16, 2024

I'm glad it's working for you. I've just pushed an update to the development version with a new function chunk that could be helpful to speed up your process a bit. Here's how I'd use it:

tokens <- c("asynchronously","barware","bender", etc... )
ng <- bind_rows(lapply(chunk(tokens, 12), function(c, ...) {Sys.sleep(2); ngram(c, ...)}, year_start = 1960))

Googe's Ngram Viewer will allow up to 12 tokens and this chunks your bigger list into a list of chunks of length 12 to work on.

from ngramr.

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.