Are you happy or sad?

UPDATED: This is the first time I tried to include a dataset in a package and it didn’t go well 🙂

If you have problems then that is probably why. Sorry for the inconvenience. Will update everything as soon as possible.

—–
Well, if you wrote about it we might be able to figure it out with my new package: happyorsad

Happyorsad is a sentiment scorer. It uses the approach of Finn Årup Nielsen from Informatics and Mathematical Modelling at the Technical University of Denmark and this AFINN lists hosted in his Github repo.

Finn Årup Nielsen has constructed three lists that makes it possible to sentiment score in english, danish and using emoticons. There are already a few sentiment packages for english, but this is the first one for danish and as far as I now also the first one to sentiment score emoticons.

A big shout out to Finn for the lists.

If you want to try it out then just run the code below. Looking forward to your feedback!

if(!require("devtools")) install.packages("devtools")
devtools::install_github("56north/happyorsad")

# Examples of sentiment scoring

library(happyorsad)

# Score danish words
string_da <- ‘Hvis ikke det er det mest afskyelige elendige flueknepperi…’
happyorsad(string_da, “da”)

# Score english words
string_en <- ‘This is utterly excellent!’
happyorsad(string_en, “en”)

# Score emoticons
string_emoticon <- ‘I saw that yesterday :)’
happyorsad(string_emoticon, “emoticon”)

Showing 4 comments

  1. Stockman
    Svar

    I get the following error message when running your code. Any ideas how I might resolve this? thanks

    > devtools::install_github(“56north/happyorsad”)
    Downloading github repo 56north/happyorsad@master
    Installing happyorsad
    “d:/apps/RRO/R-32~1.2/bin/x64/R” –no-site-file –no-environ –no-save –no-restore CMD INSTALL “C:/Users/gcronin/AppData/Local/Temp/RtmpSCAVxX/devtools11b4263443/56north-happyorsad-f3cdbb2″ \
    –library=”d:/apps/RRO/R-3.2.2/library” –install-tests

    Multithreaded BLAS/LAPACK libraries detected. Using 2 cores for math algorithms.
    * installing *source* package ‘happyorsad’ …
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    Multithreaded BLAS/LAPACK libraries detected. Using 2 cores for math algorithms.
    Error in namespaceExport(ns, exports) : undefined exports: updata_emojis
    Error: loading failed
    Execution halted
    ERROR: loading failed
    * removing ‘d:/apps/RRO/R-3.2.2/library/happyorsad’
    Error: Command failed (1)

    • Mikkel
      Svar

      Reinstall package and run this code:

      It is a problem in the package. This hack should work for now:

      library(happyorsad)
      dir.create(“data/”)
      update_wordlists()

      there is a bug in my package and I will fix it later. Above code is a hack that should work until bug is fixed.

  2. Edward
    Svar

    Any solution for the following error?

    Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
    In addition: Warning message:
    In readChar(con, 5L, useBytes = TRUE) :
    cannot open compressed file ‘data/AFINN_da_32.Rdata’, probable reason ‘No such file or directory’

    • Mikkel
      Svar

      It is a problem in the package. This hack should work for now:

      library(happyorsad)
      dir.create(“data/”)
      update_wordlists()

Leave a Comment

Din e-mailadresse vil ikke blive offentliggjort. Krævede felter er markeret med *

*