Code Monkey home page Code Monkey logo

Comments (3)

kn1cht avatar kn1cht commented on July 25, 2024

@misogihagi Thank you for reporting this issue!
I ran your tests and took a measure to prevent false-positives.

我ら5人合わせて四天王!

This test passes because this rule does not detect Japanese characters as possible units.
For example, this rule does not raise any error to '100垓' or '秒速5㌢㍍'.

The 5 of us together are the Four Heavenly Kings!

This test has failed with a message: 「of」には、SI単位系で使用できない文字が含まれています。SI単位系を使用してください。
This is a false positive and "of" should not be warned.

When I wrote this rule, my idea was to detect all possible "number + unit" and exclude words which are not units using a white list.

const allowWordManyChar = P.regexp(/and|or|nor|but|by|for|from|on|out|per|to/);

Since it turned out that this list was inadequate, I added more words which may be placed after numbers (thanks to ChatGPT).

const allowWordManyChar = P.regexp(/and|or|nor|but|by|for|from|on|out|per|to|of|at|over|under|between|among|into|upon|within|around|plus|minus|times|divided/);

It is open to debate whether the whitelist approach is a good idea or not.
It is difficult to prevent false positives completely (e.g., "2 in" should be warned as an expression using an inch that is not an SI unit, but "2 in 1" is not).
If you have any good ideas, further pull requests are welcome.

from textlint-rule-use-si-units.

kn1cht avatar kn1cht commented on July 25, 2024

If you have to prevent such unwanted errors before this rule is improved, you can use allowedUnits option.

{
    "rules": {
        "use-si-units": {
            "allowedUnits": ["of", "in", ...],
        }
    }
}

from textlint-rule-use-si-units.

kn1cht avatar kn1cht commented on July 25, 2024

I published v2.0.0!

https://www.npmjs.com/package/textlint-rule-use-si-units

from textlint-rule-use-si-units.

Related Issues (2)

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.