Code Monkey home page Code Monkey logo

dustinstoltz / cmdist Goto Github PK

View Code? Open in Web Editor NEW
27.0 2.0 5.0 1.4 MB

DEPRECATED - The Concept Mover's Distance Method is now available in the text2map package. Concept Mover's Distance is a way to measure a document's conceptual engagement using word embeddings.

Home Page: https://culturalcartography.gitlab.io/text2map/

License: GNU General Public License v3.0

R 100.00%
concept-mover-distance word-embeddings natural-language-processing computational-social-science computational-sociology text-analysis conceptual-engagement cultural-sociology embeddings nlp

cmdist's People

Contributors

adamstorer avatar brandonsepulvado avatar dustinstoltz avatar marshall-soc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cmdist's Issues

Manually load the dependency stringr

Thanks for the great package. I notice a little problem while running it for the first time.

I installed the package through devtools and loaded it in a clean environment. However, the function cmdist could not finish to run since .prepINPUT would get stuck at line 24, where it calls str_trim() from stringr, which is not loaded. Once I load stringr, everything runs smoothly. Likely, this is not what should happen.

Issue in get_centroids()

Hi,

I found that the get_centroids() function always returns the same values no matter which terms are used.
I looked at your code and I believe the issue might be here:

get vectors for words in column 1

        v <- wv[ terms[, 1, drop=TRUE]  , , drop = FALSE]

It subsets the first x terms of the word embedding matrix instead of the terms passed to the function.
Similarly, the get_directions() function only works if I pass a matrix of terms. A data frame returns 0 for all dimensions.

An example:

library(CMDist)
library(word2vec)

#---Load embedding vectors
w2v <- read.wordvectors("/GoogleNews-vectors-negative300.bin",type = "bin",n = 20)


#---get_centroids()
terms_1 <- c("in","with","from")
terms_2 <- c("said","was","are")


centroid_t1 <- get_centroid(terms = terms_1,wv = w2v)
centroid_t2 <- get_centroid(terms = terms_2,wv = w2v)

centroid_t1 == centroid_t2

#---get_directions()
pairs_1 <-   data.frame(additions  = terms_1,
                        substracts = terms_2)

pairs_2 <-   as.matrix(data.frame(additions  = terms_1,
                        substracts = terms_2))

directions_1 <- get_direction(pairs = pairs_1,w2v)
directions_2 <- get_direction(pairs = pairs_2,w2v)

Parallelization error

I get an error with parallelization on Mac OS High Sierra using R version 4.0.2. When I set parallel to true and threads to four, I get the following output.

Error in makePSOCKcluster(names = spec, ...) : 
  Cluster setup failed. 4 of 4 workers failed to connect.

It appears this is a known issue with {parallel}.

text2vec errors

Hi there. I enjoyed your article and was looking forward to using the technique. However, I'm encountering some persistent errors with what I'm guessing is the text2vec implementation. Mainly, I can't get CMDist to run anymore -- whereas in the past, I got the replication materials up and running.

There's a particularly annoying issue with this following error:
Error in .subset2(public_bind_env, "initialize")(...) : is.matrix(wv) is not TRUE

Which shouldn't be true given that my wv variable is is.matrix(word_vectors) [1] TRUE . I'd appreciate your thoughts on troubleshooting this issue.

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.