GithubHelp home page GithubHelp logo

Comments (4)

phlptp avatar phlptp commented on July 25, 2024

Yeah, it is a balancing job between a number of different unit conventions. There are a few programs which specify that . is a multiplier, other programs or conventions where a space is a multiplier. And in a linguistic sense - is a connector that bridges two parts of a word or a prefix or modifier. So I am sure there are a few cases where the complex conglomeration of those conventions make the interpretation a bit odd. I suppose some additional consideration of situations that end in a . might be warranted as that would indicate the . being used as an abbreviation rather than as a multiplier. If there are specific unit strings that get interpreted incorrectly there are a couple different ways I put in to interpret them and bypass most of the other logic that tries to figure out some sort of meaning from strings and break it into individual components.

from units.

phlptp avatar phlptp commented on July 25, 2024

Playing around with this and how to interpret '.' This is what I have currently

// interpret . as multiply
    EXPECT_EQ(precise::m * precise::s, unit_from_string("m.s"));
    // interpret m as abbreviation so milli
    EXPECT_EQ(precise::milli * precise::s, unit_from_string("m. s"));
    // interpret as abbreviation so millisecond
    EXPECT_EQ(precise::milli * precise::s, unit_from_string("m. s."));
    // connector so space = multiply 
    EXPECT_EQ(precise::m * precise::s, unit_from_string("m- s"));
    // connector so space = multiply 
    EXPECT_EQ(precise::milli * precise::s, unit_from_string("m-s"));
    // s is abbreviation so first . is also abbreviation so millisecond
    EXPECT_EQ(precise::milli * precise::s, unit_from_string("m.s."));

a.u. in this context would be interpreted as astronomical unit instead of a*u

basic rule would be any non numerically sensible . would be interpreted as an abbreviation if at the end or followed by a space, otherwise it could be considered a multiplier. And it must be consistent for the whole unit string. I.e if one . shows as abbreviation all will.

If any show as an abbreviation they essentially get removed
[change from previous] "m.s." is equivalent to "m. s."

from units.

SimonHeybrock avatar SimonHeybrock commented on July 25, 2024

And it must be consistent for the whole unit string. I.e if one . shows as abbreviation all will.

👍 nice approach, that makes sense!

What about the recommended (by a number of Journals) abbreviation for "arbitrary units": arb. unit? Does this parse correctly with the suggested change?

from units.

phlptp avatar phlptp commented on July 25, 2024

I went through and looked at a few other units that end in "unit" and added some additional string associated with them and a few modifiers as well so "arb. unit" as a well as a few other descriptions of that will get interpreted as arbitrary unit

from units.

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.