Giter Site home page Giter Site logo

Comments (6)

dselivanov avatar dselivanov commented on July 18, 2024 1

Problem is here.
Before @TommyJones will fix it, you can try to construct DTM directly with text2vec::create_dtm function.

from textminer.

dselivanov avatar dselivanov commented on July 18, 2024 1

@TommyJones probably str_replace_all(doc_vec, "[^[:alnum:]]", " ") will work. See ?base::regex.

stringr::str_replace_all("advad ывмывм 134134 ,..?", "[^[:alnum:]]", " ")

"advad ывмывм 134134 "

from textminer.

TommyJones avatar TommyJones commented on July 18, 2024

Thank you for the feedback. As @dselivanov noted, the issue is with the
regular expression underlying the option remove_punctuation. In the short
run, you can set remove_punctuation = FALSE in the call to CreateDtm.
However, I believe Russian still has punctuation marks. So you'd have to
strip them out with a regular expression before a call to CreateDtm. (Note:
you would have to do the same if you call text2vec::create_dtm directly.)

Some example code:

character vector containing a Russian document

my_docs <- scan("https://habrahabr.ru/post/123845/", what="character",
sep="\n")

my_docs <- paste(my_docs, collapse = "\n")

remove punctuation - this regular expression will work with Russian only.

I'll find something more general to patch textmineR
my_docs <- stringr::str_replace_all(my_docs, "[^а-яА-ЯёЁa-zA-Z]", " ")

create DTM

my_dtm <- CreateDtm(my_docs, remove_punctuation = FALSE) # set other
options you may need here

I will keep this issue open until I find a general solution that works for
many languages.

On Wed, Apr 27, 2016 at 6:48 AM Dmitriy Selivanov [email protected]
wrote:

Problem is here
https://github.com/TommyJones/textmineR/blob/master/R/CreateDtm.R#L69-L74
.
Before @TommyJones https://github.com/TommyJones will fix it, you can
try to construct DTM directly with text2vec::create_dtm function.


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#20 (comment)

from textminer.

paskn avatar paskn commented on July 18, 2024

Thanks for suggestions!
remove_punctuation = FALSE fixed the problem.

from textminer.

TommyJones avatar TommyJones commented on July 18, 2024

@dselivanov, I was playing with "_|[^\\w0-9]" but your solution is much more elegant.

from textminer.

TommyJones avatar TommyJones commented on July 18, 2024

I've tested this successfully with Russian, Japanese, Korean, Chinese, and English. I'm going to call that good enough for now and close the issue. Please re-open it if you run into a similar issue.

from textminer.

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.