quanteda / quanteda.textplots

Plotting and visualisation for quanteda
GNU General Public License v3.0
6 stars 1 forks source link

Bring textmodel methods and textplot_scale1d to quanteda? #13

Open koheiw opened 4 years ago

koheiw commented 4 years ago

My LSS and newsmap package uses textmodel methods such as as.coefficients_textmodel() and textplot_scale1d(), but I do not want to add quanteda.textmodels to their dependency. How about bringing back these functions to quanteda? This helps other people to write their own textmodel's based on our package.

kbenoit commented 4 years ago

That’s a fine idea, and whatever we can do to make it extensible or more general-purpose is something I’d like to develop. One though is to provide a way for all textmodel_*() functions to work on any sparse matrix, either from Matrix or slam, of course in addition to a dfm. Another is via integrating the predictive models with caret (or tidymodels/hardhat) as in quanteda/quanteda.textmodels#8.

Point me to the code in LSS and newsmap and we can start with yours.

koheiw commented 4 years ago

LSS

It extends textplot_scale1d: https://github.com/koheiw/LSS/blob/e8fad83759ad3d9647f19be7edc6715c95fc00cb/R/textplot.R#L74-L95

Also, as.coefficients_textmodel(): https://github.com/koheiw/LSS/blob/e8fad83759ad3d9647f19be7edc6715c95fc00cb/R/textmodel.R#L242

The package no longer builds with quaneda v2.0. I am planing to submit this to CRAN sometime this year.

newsmap

It is already on CRAN. Not affected much because it does a lot of DYI, but it should use more functions made available in quaneda. https://github.com/koheiw/newsmap/blob/master/R/textmodel_newsmap.R