Git Product home page Git Product logo

Comments (6)

frederatic avatar frederatic commented on May 29, 2024

Fixed using lapply

from pattern.nlp.

jwijffels avatar jwijffels commented on May 29, 2024

Use lapply and next data.table::rbindlist

from pattern.nlp.

Missfortunate avatar Missfortunate commented on May 29, 2024

Hey, I'm trying to apply this solution to my own data set, but it doesn't seem to work.

I have a list that looks like this:
list("deze man in haalt alvast de eu vlag weg en zet de russische in de plaats <U+30FC> ",
"solidariteit cubaitalië on point nu nog europa onderling be ",
"bezoekersrichtlijn ggz geen algehele bezoekersstop ggz samen met hebben we een aangepaste richtlijn op",
"bij het om gebuiken ze het blijkbaar om op hun luie gat te liggen of achterstallig onderhoud van het",
"app die in vele talen kan vertellen of je echt tekenen van hebt test ")

And tried to use lapply and the function created by frederatic:
sentiments <- lapply(try, sentiment_function)

However this gives me 5 dataframes with the correct columns, but it contains gibberish. For example the polarity column = ÿþ0�ÿþ

When I use the function on just 1 string:
pattern_sentiment(try[[5]], language = "dutch")
it does seem to work.

I'm not very familiar with lapply, so not quite sure what I'm doing wrong.

from pattern.nlp.

frederatic avatar frederatic commented on May 29, 2024

It's been a while, but I think this was my code.
Did you assign the function to a variable like below?

sentiment_function <- function(x) {
  pattern_sentiment(x, language="dutch")
}

sentiments <- lapply(LISTNAME, sentiment_function)

U should get a list called sentiments that has the scores for every sentence. I used a dataframe instead, so got a dataframe as output. And then just bind the original tweets dataframe with the sentiment dataframe. Hope it works.

from pattern.nlp.

Missfortunate avatar Missfortunate commented on May 29, 2024

Hey,

That does indeed work, however for some reason it wraps the numbers in unexpected symbols like this:

image

I guess I can extract the contents with something like stringr, but it just seems odd to me that it behaves this way.

from pattern.nlp.

frederatic avatar frederatic commented on May 29, 2024

Quick google showed it might be a bug. Maybe these links help:

How to remove display of strange characters in R-Markdown chunk output?
Github Issue

from pattern.nlp.

Related Issues (13)

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.