Skip to content

Add support for fractional doses (beyond half measures) #1

@Selbosh

Description

@Selbosh

The package currently supports expressions with half measures in them, including mixed fractions:

doseminer::replace_numbers(c('half a spoonful', 'three and a half tablets'))
## [1] "0.5 a spoonful" "3.5 tablets" 

But more unusual fractions like thirds, fifths and quarters don't really work because it just kind of adds the denominator:

doseminer::replace_numbers(c('thirty three and a third', 'four fifths'))
## [1] "37" "9" 

The problem is with fixing this (assuming such cases appear often enough in prescriptions to be worth worrying about) without unintentionally breaking the parsing of ordinal words, which look a lot like fractions:

doseminer::replace_numbers(c('every third day', 'every fifth hour'))
## [1] "every 3 day"  "every 5 hour"

However with enough ambition, 'every 1/3 day' could be interpreted as '(every day) / 3' and end up giving the right result, with an appropriate redesign of how intervals are calculated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions