Logo GenPRES

UnitsParse Module

Parses text to a Unit and appends the group of a unit to the text of the unit. The parse gives None for blank text, for a blank part and for more than three parts separated by a slash, and raises a FormatException for a unit with a factor of 0 or for text that does not parse and names a group other than General. Other text that does not parse becomes a General unit.

Functions and values

Function or value Description

fromString s

Full Usage: fromString s

Parameters:
    s : string

Returns: Unit option

Creates a Unit from a string s, if possible, otherwise returns None. Note will take care of the n value of a unit! So, for example, the unit 36 hours can be parsed correctly. A unit with a factor of 0 cannot convert a value, so it raises a FormatException.

s : string
Returns: Unit option
Example

fromString "36 hours" = Some (Time (Hour 36N))

groupIsGeneralOrNone s

Full Usage: groupIsGeneralOrNone s

Parameters:
    s : string

Returns: bool
s : string
Returns: bool

hasZeroFactor u

Full Usage: hasZeroFactor u

Parameters:
Returns: bool

Whether a unit, or a part of a combined unit, has a factor of 0, as in 0 IU/ml.

u : Unit
Returns: bool

stringWithGroup u

Full Usage: stringWithGroup u

Parameters:
    u : string

Returns: string

Append a group to a string that represents a unit Example: stringWithGroup "mg" = "mg[Mass]"

u : string
Returns: string

Type something to start searching.