代码之家  ›  专栏  ›  技术社区  ›  Sab Garduño

w2v_列中出现错误(trainFile=file_列,modelFile=model,stopWordsFile=file_stopwords)(下面是完整的错误文本)

  •  0
  • Sab Garduño  · 技术社区  · 2 年前

    错误全文: w2v_train(trainFile=file_train,modelFile=model,stopWordsFile=file_stopwords)中出错:需要一个字符串值:[type=closure;extent=1]。

    我正在尝试使用这些数据进行单词嵌入分析 https://www.kaggle.com/datasets/therohk/million-headlines?resource=download 获得:

    1. 与焦点词最接近的25个词
    2. 画出这25个单词
    3. 将相同的分析与不同的数据进行比较(JSTOR关于“民粹主义”文章的数据) https://constellate.org/dataset/f53e497b-844e-2b60-ec2f-b9c54d2e334e?unigrams=political,%20social )

    我加载了所有数据和必要的软件包,并对ABCNews的数据进行了预处理,以便进行分析。(参见代码)

    #Loading necessary packages
    install.packages(c("tidyverse", "tidytext", "word2vec", "Rtsne", "future", "jstor", "magritrr", "ggplot2", "dplyr"))
    library("tidyverse")
    library("tidytext")
    library("word2vec")
    library("Rtsne")
    library("future")
    library("jstor")
    library(magrittr)
    library("ggplot2")
    library("dplyr")
    
    #Preprocessing abcnews data
    ##Select text data from csv file ABC NEWS FILE
    head(abcnews_pop)
    abc_pop_text <- abcnews_pop %>%
      select("headline_text")
    head(abc_pop_text)
    

    然后,我使用以下代码来处理嵌入:

    #ABCNews data
    text_news<-abc_pop_text%>%
      txt_clean_word2vec(.,ascii = TRUE, alpha = TRUE, tolower = TRUE, trim = TRUE)
    
    set.seed(123456789)
    news_model<-word2vec(x=text, type = "cbow", dim = 500, iter = 50)
    embedding_news<-as.matrix(news_model)
    

    第一个功能(text\u news<-abc\u pop…)运行平稳。然而,第二个(set.seed(123456789)news_model…)指出了这个错误:

    w2v_train(trainFile=file_train,modelFile=model,stopWordsFile=file_stopwords)中出错:需要一个字符串值:[type=closure;extent=1]。

    有人知道如何解决这个问题吗?

    0 回复  |  直到 2 年前
        1
  •  0
  •   Sab Garduño    2 年前

    我在命名对象/变量时出错。这已经解决了,谢谢。