From 6ed520ffa42a372edad53afb4e903e44832c0351 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Fri, 23 Jan 2009 15:22:26 +0100 Subject: [PATCH] Implement math.text.french --- extra/math/text/french/authors.txt | 1 + extra/math/text/french/french-docs.factor | 6 ++ extra/math/text/french/french-tests.factor | 22 +++++++ extra/math/text/french/french.factor | 97 ++++++++++++++++++++++++++++++ extra/math/text/french/summary.txt | 1 + 5 files changed, 127 insertions(+) create mode 100644 extra/math/text/french/authors.txt create mode 100644 extra/math/text/french/french-docs.factor create mode 100644 extra/math/text/french/french-tests.factor create mode 100644 extra/math/text/french/french.factor create mode 100644 extra/math/text/french/summary.txt diff --git a/extra/math/text/french/authors.txt b/extra/math/text/french/authors.txt new file mode 100644 index 0000000000..f3b0233f74 --- /dev/null +++ b/extra/math/text/french/authors.txt @@ -0,0 +1 @@ +Samuel Tardieu diff --git a/extra/math/text/french/french-docs.factor b/extra/math/text/french/french-docs.factor new file mode 100644 index 0000000000..702a963e05 --- /dev/null +++ b/extra/math/text/french/french-docs.factor @@ -0,0 +1,6 @@ +USING: help.markup help.syntax ; +IN: math.text.french + +HELP: number>text +{ $values { "n" "an integer" } { "str" "a string" } } +{ $description "Return the a string describing " { $snippet "n" } " in French. Numbers with absolute value equal to or greater than 10^12 will be returned using their numeric representation." } ; diff --git a/extra/math/text/french/french-tests.factor b/extra/math/text/french/french-tests.factor new file mode 100644 index 0000000000..fd8438718d --- /dev/null +++ b/extra/math/text/french/french-tests.factor @@ -0,0 +1,22 @@ +USING: math math.functions math.parser math.text.french sequences tools.test ; + +[ "zéro" ] [ 0 number>text ] unit-test +[ "vingt et un" ] [ 21 number>text ] unit-test +[ "vingt-deux" ] [ 22 number>text ] unit-test +[ "deux mille" ] [ 2000 number>text ] unit-test +[ "soixante et un" ] [ 61 number>text ] unit-test +[ "soixante-deux" ] [ 62 number>text ] unit-test +[ "quatre-vingts" ] [ 80 number>text ] unit-test +[ "quatre-vingt-un" ] [ 81 number>text ] unit-test +[ "quatre-vingt-onze" ] [ 91 number>text ] unit-test +[ "deux cents" ] [ 200 number>text ] unit-test +[ "mille deux cents" ] [ 1200 number>text ] unit-test +[ "mille deux cent quatre-vingts" ] [ 1280 number>text ] unit-test +[ "mille deux cent quatre-vingt-un" ] [ 1281 number>text ] unit-test +[ "un billion deux cent vingt milliards quatre-vingts millions trois cent quatre-vingt mille deux cents" ] [ 1220080380200 number>text ] unit-test +[ "un million" ] [ 1000000 number>text ] unit-test +[ "un million un" ] [ 1000001 number>text ] unit-test +[ "moins vingt" ] [ -20 number>text ] unit-test +[ 104 ] [ -1 10 102 ^ - number>text length ] unit-test +! Check that we do not exhaust stack +[ 1484 ] [ 10 100 ^ 1 - number>text length ] unit-test diff --git a/extra/math/text/french/french.factor b/extra/math/text/french/french.factor new file mode 100644 index 0000000000..f8b97103eb --- /dev/null +++ b/extra/math/text/french/french.factor @@ -0,0 +1,97 @@ +! Copyright (c) 2009 Samuel Tardieu. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays assocs combinators kernel math math.functions +math.parser math.text.utils memoize sequences ; +IN: math.text.french + + + +: number>text ( n -- str ) + dup abs 10 102 ^ >= [ number>string ] [ basic ] if ; diff --git a/extra/math/text/french/summary.txt b/extra/math/text/french/summary.txt new file mode 100644 index 0000000000..c4c89dcdc4 --- /dev/null +++ b/extra/math/text/french/summary.txt @@ -0,0 +1 @@ +Convert integers to French text -- 2.11.4.GIT