Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Commit

Permalink
translate measure to NL (#213)
Browse files Browse the repository at this point in the history
Thanks a lot!
  • Loading branch information
lenmen authored and Laurent Landowski committed Jan 28, 2017
1 parent 6234212 commit f3c83e9
Show file tree
Hide file tree
Showing 2 changed files with 191 additions and 0 deletions.
49 changes: 49 additions & 0 deletions resources/languages/nl/corpus/measure.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
(
; Context map
{}

; Distance

"3 kilometer"
"3 km"
"3km"
"3k"
(distance 3 "kilometre" {:value 3000 :unit "metre"})

"3,0 km"
"3,0km"
(distance 3.0 "kilometre" {:value 3000.0 :unit "metre"})

"8 mijl"
(distance 8 "mile" {:value 12872 :unit "metre"})

"9m"
"9 m"
"9 meter"
(distance 9 "metre")

"2cm"
"2 cm"
"2 centimeter"
(distance 2 "centimetre" {:value 0.02 :unit "metre"})

; Volume
"250 mililiter"
"250ml"
"250 ml"
(volume 250 "millilitre" {:value 0.25 :unit "litre"})

"2 liter"
"2l"
"2 l"
(volume 2 "litre")

"3 gallon"
(volume 3 "gallon" {:value 11.355 :unit "litre"})

"3 hectoliter"
(volume 300 "litre" {:value 30 :unit "litre"})

"halve liter"
(volume 0.5 "litre")
)
142 changes: 142 additions & 0 deletions resources/languages/nl/rules/measure.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
(
;; Distance

; latent distance
"number as distance"
(dim :number)
{:dim :distance
:latent true
:value (:value %1)}

"<latent dist> km"
[(dim :distance) #"(?i)k(ilo)?m?(eter)?s?"]
(-> %1
(dissoc :latent)
(merge {:unit "kilometre"
:normalized {:value (* 1000 (-> %1 :value))
:unit "metre"}}))

"<dist> meters"
[(dim :distance) #"(?i)m(eter)?"]
(-> %1
(dissoc :latent)
(merge {:unit "metre"}))

"<dist> centimeters"
[(dim :distance) #"(?i)(c(enti)?m(eter)?s?)"]
(-> %1
(dissoc :latent)
(merge {:unit "centimetre"
:normalized {:value (* 0.01 (-> %1 :value))
:unit "metre"}}))

"<dist> miles"
[(dim :distance) #"(?i)mijl?"]
(-> %1
(dissoc :latent)
(merge {:unit "mile"
:normalized {:value (* 1609 (-> %1 :value))
:unit "metre"}}))

;; volume

; latent volume
"number as volume"
(dim :number)
{:dim :volume
:latent true
:value (:value %1)}

"<latent vol> ml"
[(dim :volume) #"(?i)m(ili)?l(iter)?"]
(-> %1
(dissoc :latent)
(merge {:unit "millilitre"
:normalized {:value (* 0.001 (-> %1 :value))
:unit "litre"}}))

"<vol> hectoliters"
[(dim :volume) #"(?i)hectoliter?"]
(-> %1
(dissoc :latent)
(merge {:unit "hectolitre"
:normalized {:value (* 100 (-> %1 :value))
:unit "litre"}}))

"<vol> liters"
[(dim :volume) #"(?i)l(iter)?"]
(-> %1
(dissoc :latent)
(merge {:unit "litre"}))

"half liter"
[#"(?i)halve liter?"]
(-> %1
(dissoc :latent)
(merge {:unit "litre"
:value 0.5}))

"<latent vol> gallon"
[(dim :volume) #"(?i)gallon?"]
(-> %1
(dissoc :latent)
(merge {:unit "gallon"
:normalized {:value (* 3.785 (-> %1 :value))
:unit "litre"}}))
;; Quantity

; three teaspoons
"<number> <units>"
[(dim :number) (dim :leven-unit)]
{:dim :quantity
:value (:value %1)
:unit (:value %2)
:form :no-product}

; a pound
"a <unit>"
[#"(?i)an?" (dim :leven-unit)]
{:dim :quantity
:value 1
:unit (:value %2)
:form :no-product}

; 3 pounds of flour
"<quantity> of product"
[(dim :quantity #(= :no-product (:form %))) #"(?i)de" (dim :leven-product)]
(-> %1
(assoc :product (:value %3))
(dissoc :form))

; 2 apples
"<number> product"
[(dim :number) (dim :leven-product)]
{:dim :quantity
:value (:value %1)
:product (:value %2)}

; an apple
"a <product>"
[#"(?i)une?" (dim :leven-product)]
{:dim :quantity
:value 1
:product (:value %2)}

; Stubs for corpus
"tasse"
#"tasses?"
{:dim :leven-unit :value "tasse"}

"café"
#"caf[eé]"
{:dim :leven-product :value "café"}

"cuillere a soupe"
#"cuill?[eè]res? à soupe?"
{:dim :leven-unit :value "cuillère à soupe"}

"sucre"
#"sucre"
{:dim :leven-product :value "sucre"}

)

0 comments on commit f3c83e9

Please sign in to comment.