bnosac / pattern.nlp Goto Github PK
View Code? Open in Web Editor NEWR package to perform sentiment analysis and Parts of Speech tagging for Dutch/French/English/German/Spanish/Italian
License: Other
R package to perform sentiment analysis and Parts of Speech tagging for Dutch/French/English/German/Spanish/Italian
License: Other
Hello
i have installed the Python 2.5.4 and i tried to install the pattern package but it doesn't work. Do you have a tutorial or something easier for me please ?
Thank you
Dear Staff,
I'm encountering some issues when I try to install your package. I run Python 2.7.9. I've correctly installed pattern, but when I go to R to run the second part
devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
I get this error:
devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
Downloading GitHub repo bnosac/pattern.nlp@master
from URL https://api.github.com/repos/bnosac/pattern.nlp/zipball/master
Installing pattern.nlp
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save
--no-restore --quiet CMD INSTALL
'/private/var/folders/c_/km_9j5xn7pjc53pchr527g4c0000gn/T/Rtmp2dLsSE/devtools5fd865431c54/bnosac-pattern.nlp-0802212'
--library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library' --install-tests
--no-multiarch
installing source package ‘pattern.nlp’ ...
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Traceback (most recent call last):
File "", line 1, in
ImportError
:
No module named pattern.db
Error : .onAttach failed in attachNamespace() for 'pattern.nlp', details:
call: PythonInR::pyExec("from pattern.db import *")
error: An error has occured while executing Python code. See traceback above.
Errore: loading failed
Esecuzione interrotta
ERROR: loading failed
Thanks in advance for your help
My Python 3.7.2 and R 3.5.2 are both 64-bit and are on Windows.
Pattern is installed in Python. I'd like to troubleshoot this directly, but if there's a workaround where I could specific an alternative 32-bit Python installation then that would be an option (?).
The R installation fails anyway with these errors:
finding HTML links ... done pattern.nlp-package html pattern_pos html pattern_sentiment html penn_treebank_postags html
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'pattern.nlp':
.onAttach failed in attachNamespace() for 'pattern.nlp', details:
call: autodetectPython(pythonExePath)
error: Python 64bit can't be connected with R 32bit!
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
- removing 'pattern.nlp'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘RtmpobB6uh/file2188337f981/pattern.nlp_1.0.tar.gz’ had non-zero exit status
As explained in the title,
pattern_pos(" ", "english")
Error in[<-.data.table
(x, j = name, value = value) :
Cannot use := to add columns to a null data.table (no columns), currently. You can use := to add (empty) columns to a 0-row data.table (1 or more empty columns), though.
In addition: Warning message:
In is.na(tags$word) :
is.na() applied to non-(list or vector) of type 'NULL'
This is due to the fact that there is no token in the string and this corner case is not handled by the wrapper.
Yours,
Erwan
After installing I tried to test the code with the example text:
library(pattern.nlp)
pattern_sentiment("i really really hate iphones", language = "english")
But then I get the following error:
Error in pyExec(sprintf("senti = %s(%s)", FUN, pyobj)) :
Traceback (most recent call last):
File "", line 1, in
NameError: name 'sentiment_en' is not defined
What could be wrong and how could I try to fix it?
I got it working, but when I try your examples for pattern_sentiment, the dutch one outputs 0.00 for both polarity and subjectivity. I tried the same example in python 2.7 with pattern 2.6 and it gives the same results, so I assume the problem lies with pattern. Problem is I can't install the latest pattern version with python 2.7, cuz it says it requires >3.5. And this R package can't use 3.5 as it says in your Read.me. How do I fix this so I can get the same output as yours?
What sets this off?
Some of values in the input character vector may be empty, is that not allowed?
pos_tags.q2 <- mapply(article.id = 1:length(text.q2.clean), content = text.q2.clean, FUN=function(article.id, content){
+ out <- (x = content, language = "english", core = TRUE)
+ out$article.id <- rep(article.id, times = nrow(out))
+ out
+ }, SIMPLIFY = FALSE)
Hide Traceback
Rerun with Debug
Error in `[<-.data.table`(x, j = name, value = value) :
Cannot use := to add columns to a null data.table (no columns), currently. You can use := to add (empty) columns to a 0-row data.table (1 or more empty columns), though.
6.
`[<-.data.table`(x, j = name, value = value)
5.
`$<-.data.table`(`*tmp*`, "word.id", value = integer(0))
4.
`$<-`(`*tmp*`, "word.id", value = integer(0))
3.
pattern_pos(x = content, language = "english", core = TRUE)
2.
(function (article.id, content)
{
out <- pattern_pos(x = content, language = "english", core = TRUE)
out$article.id <- rep(article.id, times = nrow(out)) ...
1.
mapply(article.id = 1:length(text.q2.clean), content = text.q2.clean,
FUN = function(article.id, content) {
out <- pattern_pos(x = content, language = "english",
core = TRUE) ...
Even after reading the other installation issues in regarding this package, I cannot get it to work; unfortunately. After installing the pattern package, I used the following commands:
remove.packages('pattern.nlp')
library(findpython)
can_find_python_cmd(required_modules = "pattern.db")
devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
library(pattern.nlp)
This led to the following chuck of response:
> library(findpython)
> can_find_python_cmd(required_modules = "pattern.db")
[1] TRUE
attr(,"python_cmd")
[1] "C:\\Python27\\python.exe"
> devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
Downloading GitHub repo bnosac/pattern.nlp@master
√ checking for file 'C:\Users\Max\AppData\Local\Temp\Rtmps1aWZc\remotes1e58403b698\bnosac-pattern.nlp-91a459f/DESCRIPTION' ...
- preparing 'pattern.nlp':
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- looking to see if a 'data/datalist' file should be added
- building 'pattern.nlp_1.0.tar.gz'
Installing package into ‘C:/Users/.../Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'pattern.nlp' ...
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'pattern.nlp'
finding HTML links ... done
pattern.nlp-package html
pattern_pos html
pattern_sentiment html
penn_treebank_postags html
** building package indices
** testing if installed package can be loaded
*** arch - i386
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\site-packages\pattern\text\en\__init__.py", line 61, in <module>
from pattern.text.en.inflect import (
File "C:\Python27\lib\site-packages\pattern\text\en\__init__.py", line 80, in <module>
from pattern.text.en import wordnet
File "C:\Python27\lib\site-packages\pattern\text\en\wordnet\__init__.py", line 48, in <module>
import nltk
ImportError
:
No module named nltk
Error: package or namespace load failed for 'pattern.nlp':
.onAttach failed in attachNamespace() for 'pattern.nlp', details:
call: PythonInR::pyExec("from pattern.en import sentiment as sentiment_en")
error: An error has occured while executing Python code. See traceback above.
Error: loading failed
Execution halted
*** arch - x64
Error: package or namespace load failed for 'pattern.nlp':
.onAttach failed in attachNamespace() for 'pattern.nlp', details:
call: autodetectPython(pythonExePath)
error: Python 32bit can't be connected with R 64bit!
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Users/Max/Documents/R/win-library/3.5/pattern.nlp'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘C:/Users/Max/AppData/Local/Temp/Rtmps1aWZc/file1e584b3d676c/pattern.nlp_1.0.tar.gz’ had non-zero exit status
In addition: Warning messages:
1: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
2: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
> library(pattern.nlp)
Error in library(pattern.nlp) : there is no package called ‘pattern.nlp’
As the pattern.db returns "TRUE", I guess that the issue seem to be somewhere related to the Pattern.nlp package. Would it be possible to support me, so I can use this package? It even shows the error explaining how Python 32bit can't be connected with R 64bit, but I am using R 32 bit.
Support would be very welcome!
Thanks for your package and although some issues occurred during installation it now works fine.
PythonInR
is not available on cran anymore and is not compatible with newest version of R. Is it possible to make the package work with reticulate
instead? The package worked before (using steps that you have on your github page), but cannot find PythonInR
anymore. Anyone who has this problem?
Thanks a lot for this package ! I couldn't install it on the latest R version (3.3.2), gives this error:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called 'pack'
However installation on R 3.2.3 succeeded.
as per the steps, I have Install all the packages and python. But while running library(pattern.nlp)
I am getting below error.
Error in find_python_cmd(minimum_version = minimum_version, maximum_version = maximum_version, :
Couldn't find a sufficient Python binary. If you haven't installed the Python dependency yet please do so. If you have but it isn't on the system path (as is default on Windows) please add it to path or set options('python_cmd'='/path/to/binary') or set the PYTHON, PYTHON2, or PYTHON3 environmental variables. Python must have access to the modules: pattern.db
Also, I had tried to code in R instead of R studio still the error is not working out.
Second Issue is sometimes it gives the error of, " could connect to python in R "
so please could you help out for this.
I want to apply the pattern_sentiment function to a dataframe of tweets, specifically to 1 column containing the text. I used a for loop and binds first, but this takes a long time on millions of rows, so then I tried the apply function, but for some reason it does not work, returning 0.0 for every value. I am just a beginner at R, so can anyone help me with a solution?
Here the 2 methods I tried:
library(pattern.nlp)
for (x in 1:4000000) {sentiments <- rbind(sentiments, (pattern_sentiment(tweets$text_clean[x], language="dutch")))}
tweets <- cbind(tweets, sentiments)
library(pattern.nlp)
sentiment_function <- function(x) {
pattern_sentiment(x, language="dutch")
}
sentiments <- apply(tweets['text_clean'], 1, sentiment_function)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.