Git Product home page Git Product logo

Comments (1)

trinker avatar trinker commented on August 15, 2024
if (!require("pacman")) install.packages("pacman")
pacman::p_load(lexicon)


test_valence_shifter <- function(
        valence_shifter_table = lexicon::hash_valence_shifters,
        sentiment_tables = lexicon::available_data('hash_sentiment')[['Data']]
    ){

    valence_words <- valence_shifter_table[['x']]

    overlaps <- lapply(sentiment_tables, function(x){

        sent_hash <- eval(parse(text = paste0('lexicon::', x)))
        intersect(sent_hash[['x']], valence_words)
        
    })

    names(overlaps) <- sentiment_tables

    class(overlaps) <- 'test_valence_shifter'
    overlaps

}

print.test_valence_shifter <- function(x, ...){

    class(x) <- 'list'
    bads <- x[lengths(x) > 0]

    if (length(bads) == 0) {
        textclean:::all_good()
    }

    intersecting <- Map(function(x, y){
        
        paste0(x,':\n\n    - ', y, '\n')

    }, names(bads), lapply(bads, function(x) paste(shQuote(x), collapse = ', ')))

    cat(paste0(
        "The following tables contained these words\n", 
        "overlapping with the supplied valence shifter table:\n\n"
    ))
    cat(paste(unlist(intersecting), collapse = '\n\n\n'))
}




test_valence_shifter(lexicon::hash_valence_shifters)

This reveals a problem:

The following tables contained these words
overlapping with the supplied valence shifter table:

hash_sentiment_senticnet:

    - "sparsely"

from lexicon.

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.