in ,

tokenmill / numberwords, Hacker News

           

        

Clojars Project

Number Words will build numeric expressions for natural numbers, percentages and fractions. For example:

  • .
  • will be converted to
  • . less than a quarter ,
  • to over one hundred .

Supports multiple languages.

The implementation is based on ideas expressed in Generating Numerical Approximations .

  • Numerical Approximations

    Numerical approximations are all over texts based on the data:

    – Water temperature is below (C) input data would be 9. 64 C) – A third of students failed the exam (42. 3%) – Q2 sales were around 1M $ (1, , ($)

  • Numeric data providing information about some metrics of interest is often a number with the precision we do not need. If we see 9. %, it is likely that the information we need is – (almost) (%) – instead of the precise number. Furthermore, different approximation strategies are often used in the report involving the same metrics. At the beginning of the report we might say

     almost  (%) or "below 14% "while later in the text, we might choose a more precise expression -  9.4%  . 

    Number Words will help you build such numerical approximations. Making them available for the text generation systems.

    Features

    Number Words uses the following abstractions:

    A full approximation result returns three such approximation data structures for a given value which is :

    • (smaller) than the (actual value) on the scaled number range.
  • greater of the (actual value) (on the scaled number range.)
  • (the

    actual value on the scaled number range. For this a is chosen from the above two which is closer to the actual value

  • Languages ​​
     

    Numeric approximation has two functionality points which are language dependent

    • Hedges which will differ from language to language. See Configuration section to see how this can be controlled.
    • Text number to text translation for a given value . For this translation Number Words relies on ICU4J .

    Currently supported languages:

    • German
    • Usage
    • Number Words exposes approximation functionality through approximations function which takes on the following parameters:

      • – : (
      • or : en
      • actual-value
      • – the number to approximate
    • scale
    • – at which the approximation is to be performed. (require ‘[numberwords.core :as nw]) (nw / approximations: en 0.) 1/4=> #: numwords {: around            #: numwords {: hedges # {“approximately” “about” “around”},                       : text “zero point two five”,                       given-value 1/4,                       : favorite-number # {“a quarter”}},            : more-than            #: numwords {: hedges # {“over” “more than”},                       : text “zero point two five”,                       given-value 1/4,                       : favorite-number # {“a quarter”}},            less-than            #: numwords {: hedges # {“nearly” “under” “less than”},                       : text “zero point five”,                       given-value 1/2,                       : favorite-number # {“a half”}}}

    Configuration

    Hedges, favorite numbers can be modified and new languages ​​added via changes to a configuration file – / resources / numwords.edn

  • {;; Configuration is strucutured by the language  : {       ;; Hedges section specifies which words are associated with given actual to given value relations       : hedges {: equal # {“exactly”}                : around # {“around” “approximately” “about”}                : more # {“more than” “over”}                : less # {“less than” “under” “nearly”}}              ;; Favorite numbers map a special number with its textual expressions       : favorite-numbers {1/4 # {“a quarter” “a fourth”}                          1/2 # {“a half”}}}}
  • License

    Copyright © TokenMill UAB .

    Distributed under the The Apache License, Version 2.0.

       (Read More)

  • What do you think?

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    GIPHY App Key not set. Please check settings

    Is Meghan Markle Deluded to Think She Will Succeed in Hollywood ?, Crypto Coins News

    The psychology behind that tempting quarantine makeover, Ars Technica