This does what I expect:

Quantity["Kilograms"*"Meters"] // InputForm

Quantity[1, "Kilograms"*"Meters"]

This, on the other hand, bungles the units:

Quantity[1, "Kilograms*Meters"] // InputForm

Quantity[1, "KilogramsForce"*"Meters"]

Note that KilogramsForce is a unit of force, not mass, and strictly different from Kilograms. This is not a case of a subtle and understandable misinterpretation as in the case of Kelvins vs KelvinsDifference, but a parsing error.

  • What do we need to be careful about when writing down units for parsing? How can we prevent parsing errors, other than splitting the units as in the first input line above?
  • Are there other cases like this one?
  • Is this a residue of Imperial Units parsing, where pounds and pounds-force are sometimes used interchangeably?
  • Is this the result of an overly greedy way of interpreting a torque? This parsing error seems specific to the $\text{kg}\cdot\text{m}$ unit and does not occur, e.g., with $\text{kg}\cdot\text{s}$.
  • 3
    $\begingroup$ And Quantity[1, "Kilograms*Meters^2"] // InputForm is interpreted correctly $\endgroup$ – Gustavo Delfino Feb 19 at 14:16
  • 2
    $\begingroup$ KilogramForce are the devil's work. Like HectareVolume or WattTime. :) $\endgroup$ – MikeY Feb 19 at 20:45
  • 1
    $\begingroup$ Maybe it's time to retire the kilogram-force? According to the English Wikipedia, "Kilogram-force is a non-standard unit and is classified in SI Metric System as a unit that is unacceptable for use with SI." According to the German Wikipedia, "Das Kilopond ist per Gesetz seit 1. Januar 1978 in Deutschland für die Angabe der Kraft unzulässig und wurde durch das Newton ersetzt." ("The kilogram-force is disallowed by law in Germany since January 1st, 1978, and has been replaced by the Newton.") $\endgroup$ – Roman Feb 20 at 1:21

Under the hood, units not recognized by Quantity use Wolfram|Alpha's NLP to parse the unit.

In this case we see there are 2 possibilities:

enter image description here

It's probably worth leaving feedback at the bottom of the Alpha page making your case that 'kilogram meters' should be the default for this query.

I don't think there's a way to access all possibilities in Quantity and I think the best way to avoid this is to use the canonical form of the units from the beginning.

If that's not feasible, as a workaround you can stringify your entire input and use Interpreter:

Interpreter["Quantity", AmbiguityFunction -> All]["1 Kilograms*Meters"]
 {Quantity[1, "KilogramsForce" "Meters"], Quantity[1, "Kilograms" "Meters"]}, 
 {<|"Description" -> "kilogram-force meters"|>, <|"Description" -> "kilogram meters"|>}]
  • 1
    $\begingroup$ Ha that's full-on en.wikipedia.org/wiki/Robopsychology ! Thanks @ChipHurst, this is at least a partial answer. $\endgroup$ – Roman Feb 19 at 14:38
  • 1
    $\begingroup$ Considering how wide the Interpreter casts its net, its full reply is of limited use for an automated procedure and I cannot do better than pick its most likely answer (other than checking the ambiguity list manually). Surprisingly, Interpreter["Quantity", AmbiguityFunction -> All]["1 Second"] gives four possible interpretations, and even Interpreter["Quantity", AmbiguityFunction -> All]["1 Meter"] finds two ways of interpreting, even though these units are about as basic as it gets. NLP is not the right tool here, as it fails in unexpected ways (hence my reference to robopsychology). $\endgroup$ – Roman Feb 19 at 15:00

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.