Giter VIP home page Giter VIP logo

ve-rs's Issues

Condition in `sanitize_asterisk` is incorrect resulting in lemma being discarded

Hi, firstly thank you for this crate, it has been useful for something I'm working on :)

I just wanted to point out that I believe the condition in the sanitize_asterisk function is the wrong way around.

The current code is as follows:

fn sanitize_asterisk(value: &str) -> Option<String> {
    if value.is_empty() || value == "*" {
        Some(value.into())
    } else {
        None
    }
}

To my understanding, an '*' indicates a lack of a relevant value in the MeCab format, which we would presumably want to represent as None. If not an empty string or '*', then presumably we want to keep the lemma. Instead, this code does the opposite.

I changed it to this (the same but shorter and with the condition is inverted):

fn sanitize_asterisk(value: &str) -> Option<String> {
    (!value.is_empty() && value != "*").then(|| value.to_string())
}

Now for example entering the input ’難しかった' results in a Word instance where lemma is Some("難しい".to_string()) whereas before my change it was just None.

Please let me know if I'm missing something, I'm not super familiar with MeCab and such.

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.