Skip to content

Error when using the "phrasetotoken" function with collocations (bi- AND trigrams) #239

Description

@atrolle

Hi,

I'm using tm and quanteda packages conjointly.
But I'm facing an error message when using the "phrasetotoken" function with collocations (bi- and trigrams). Here is my code :

Text <- readLines("Text.txt", encoding = "latin1")

CollocsText <- collocations(Text, size = 2:3, method = "lr")
CollocsText <- removeFeatures(CollocsText, stopwords("french"))


vsText <- VectorSource(Text)
corpusText <- Corpus(vsText)
corpusText <- tm_map(corpusText, content_transformer(tolower))
corpusText <- tm_map(corpusText, removeWords, stopwords("french"))
corpusText <- tm_map(corpusText, removePunctuation)

TokensText <- phrasetotoken(corpus(corpusText),CollocsText)

When executing the last command, the error message is as follows :
Error in stringi::stri_replace_all_regex(object, re.search, re.replace,  : 
  Syntax error in regexp pattern. (U_REGEX_RULE_SYNTAX)

I don't understand the reason why this error message appears. The "phrasetotoken" function works fine with collocations of bi-grams only (i.e. size = 2).

Thank you in advance for your help,
Kind regards,
Arnaud.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions