diff --git a/resources/languages/nl/corpus/measure.clj b/resources/languages/nl/corpus/measure.clj new file mode 100644 index 00000000..b1103093 --- /dev/null +++ b/resources/languages/nl/corpus/measure.clj @@ -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") +) diff --git a/resources/languages/nl/rules/measure.clj b/resources/languages/nl/rules/measure.clj new file mode 100644 index 00000000..b59b5a90 --- /dev/null +++ b/resources/languages/nl/rules/measure.clj @@ -0,0 +1,142 @@ +( + ;; Distance + + ; latent distance + "number as distance" + (dim :number) + {:dim :distance + :latent true + :value (:value %1)} + + " km" + [(dim :distance) #"(?i)k(ilo)?m?(eter)?s?"] + (-> %1 + (dissoc :latent) + (merge {:unit "kilometre" + :normalized {:value (* 1000 (-> %1 :value)) + :unit "metre"}})) + + " meters" + [(dim :distance) #"(?i)m(eter)?"] + (-> %1 + (dissoc :latent) + (merge {:unit "metre"})) + + " centimeters" + [(dim :distance) #"(?i)(c(enti)?m(eter)?s?)"] + (-> %1 + (dissoc :latent) + (merge {:unit "centimetre" + :normalized {:value (* 0.01 (-> %1 :value)) + :unit "metre"}})) + + " 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)} + + " ml" + [(dim :volume) #"(?i)m(ili)?l(iter)?"] + (-> %1 + (dissoc :latent) + (merge {:unit "millilitre" + :normalized {:value (* 0.001 (-> %1 :value)) + :unit "litre"}})) + + " hectoliters" + [(dim :volume) #"(?i)hectoliter?"] + (-> %1 + (dissoc :latent) + (merge {:unit "hectolitre" + :normalized {:value (* 100 (-> %1 :value)) + :unit "litre"}})) + + " 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})) + + " gallon" + [(dim :volume) #"(?i)gallon?"] + (-> %1 + (dissoc :latent) + (merge {:unit "gallon" + :normalized {:value (* 3.785 (-> %1 :value)) + :unit "litre"}})) + ;; Quantity + + ; three teaspoons + " " + [(dim :number) (dim :leven-unit)] + {:dim :quantity + :value (:value %1) + :unit (:value %2) + :form :no-product} + + ; a pound + "a " + [#"(?i)an?" (dim :leven-unit)] + {:dim :quantity + :value 1 + :unit (:value %2) + :form :no-product} + + ; 3 pounds of flour + " of product" + [(dim :quantity #(= :no-product (:form %))) #"(?i)de" (dim :leven-product)] + (-> %1 + (assoc :product (:value %3)) + (dissoc :form)) + + ; 2 apples + " product" + [(dim :number) (dim :leven-product)] + {:dim :quantity + :value (:value %1) + :product (:value %2)} + + ; an apple + "a " + [#"(?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"} + +)