From 65f549bbb24c5859b8b237bd19f9a4876e89ef78 Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 6 Mar 2019 15:35:30 +0800 Subject: [PATCH] Modify filters structure for Chinese --- languages/zh-tw/filters.genie | 51 +++++++++++------------------------ 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/languages/zh-tw/filters.genie b/languages/zh-tw/filters.genie index 15bc66a14..f054b75ba 100644 --- a/languages/zh-tw/filters.genie +++ b/languages/zh-tw/filters.genie @@ -24,6 +24,9 @@ atom_filter = { t1:constant_Time '之前' => C.timeGetPredicate($options, null, t1); t2:constant_Time '之後' => C.timeGetPredicate($options, t2, null); t1:constant_Time '和' t2:constant_Time '之間' => C.timeGetPredicate($options, t1, t2); + '從' t1:constant_Time '到' t2:constant_Time => C.timeGetPredicate($options, t1, t2); + '從' t1:constant_Time '到' t2:constant_Time '之間' => C.timeGetPredicate($options, t1, t2); + '從' t1:constant_Time '開始 到' t2:constant_Time '結束' => C.timeGetPredicate($options, t1, t2); '我 在' loc:constant_Location => C.locationGetPredicate($options, loc); '我 不 在' loc:constant_Location => C.locationGetPredicate($options, loc, true); @@ -32,31 +35,33 @@ atom_filter = { // proj:projection_Any ('is' | 'is exactly' | 'is equal to') x:constant_Any => C.makeGetPredicate(proj, '==', x); // proj:projection_Any ('is not' | 'is n\'t' | 'is different than') x:constant_Any => C.makeGetPredicate(proj, '==', x, true); - p:out_param_Any ('等於' | '相等於') x:constant_Any => C.makeFilter($options, p, '==', x); - p:out_param_Any ('和' | '跟') x:constant_Any ('一樣' | '相同') => C.makeFilter($options, p, '==', x); - p:out_param_Any '不等於' x:constant_Any => C.makeFilter($options, p, '==', x, true); - p:out_param_Any ('和' | '跟') x:constant_Any ('不一樣' | '不 相同') => C.makeFilter($options, p, '==', x, true); + p:out_param_Any ('是' | '為') x:constant_Any => C.makeFilter($options, p, '==', x); + p:out_param_Any ('和' | '跟') x:constant_Any ('一樣' | '相同') => C.makeFilter($options, p, '==', x); + p:out_param_Any ('不是' | '不為') x:constant_Any => C.makeFilter($options, p, '==', x, true); + p:out_param_Any ('和' | '跟') x:constant_Any ('不一樣' | '不 相同') => C.makeFilter($options, p, '==', x, true); p:the_out_param_Numeric '比' x:constant_Numeric ('大' | '多') => C.makeFilter($options, p, '>=', x); + p:the_out_param_Numeric '大於' x:constant_Numeric => C.makeFilter($options, p, '>=', x); p:the_out_param_Numeric '比' x:constant_Numeric ('小' | '少') => C.makeFilter($options, p, '<=', x); - - // I need something like timeGetPredicate for constant_Date, should I add in ast_manip? - // For example, d1:constant_Date '和' d2:constant_Date '之間' => C.dateGetPredicate($options, d1, d2); + p:the_out_param_Numeric '小於' x:constant_Numeric => C.makeFilter($options, p, '<=', x); !turking { p:the_out_param_Date '在' x:constant_Date '之後' => C.makeFilter($options, p, '>=', x); p:the_out_param_Date '在' x:constant_Date '之前' => C.makeFilter($options, p, '<=', x); } - p:the_out_param_Array__Any ('有' | '包含' | '擁有' | '含有' | '存在') x:constant_Any => C.makeFilter($options, p, 'contains', x); - p:the_out_param_Array__Any ('沒有' | '不 包含' | '沒 擁有' | '不 含有' | '不 存在') x:constant_Any => C.makeFilter($options, p, 'contains', x, true); + p:the_out_param_Array__Any ('有' | '包含' | '擁有' | '含有') x:constant_Any => C.makeFilter($options, p, 'contains', x); + x:constant_Any ('存在' | '在' | '存在 於') p:the_out_param_Array__Any ('之中' | '裡面') => C.makeFilter($options, p, 'contains', x); + p:the_out_param_Array__Any ('沒有' | '不 包含' | '沒 擁有' | '不 含有') x:constant_Any => C.makeFilter($options, p, 'contains', x, true); + x:constant_Any ('不 存在' | '不在' | '不 存在 於') p:the_out_param_Array__Any ('之中' | '裡面') => C.makeFilter($options, p, 'contains', x, true); !turking range_filter; //!turking f:either_filter => f; } edge_filter = { - !turking '當' p:out_param_Any ('跟' | '和') x:constant_Any ('一樣' | '相同') ('時' | '的 時候') => C.makeFilter($options, p, '==', x); + !turking '當' p:out_param_Any ('跟' | '和') x:constant_Any ('一樣' | '相同') ('時' | '的 時候') => C.makeFilter($options, p, '==', x); + !turking '當' p:out_param_Any ('變得' | '變成') ('和' | '跟') x:constant_Any ('一樣' | '相同') ('時' | '的 時候') => C.makeFilter($options, p, '==', x); '當' p:the_out_param_Numeric ('比' | '變得 比') x:constant_Numeric ('大' | '多') ('時' | '的 時候') => C.makeFilter($options, p, '>=', x); '當' p:the_out_param_Numeric ('比' | '變得 比') x:constant_Numeric ('小' | '少') ('時' | '的 時候') => C.makeFilter($options, p, '<=', x); } @@ -99,7 +104,7 @@ either_filter = { } range = { - v1:constant_Numeric ('和' | '跟') v2:constant_Numeric '之間'=> { + v1:constant_Numeric ('和' | '跟' | '到') v2:constant_Numeric '之間'=> { if (!v1.getType().equals(v2.getType())) return null; if (v1.equals(v2)) // can happen with constants (now, 0, 1, etc.) @@ -109,11 +114,6 @@ range = { return null; return [v1, v2]; }; - v1:constant_Date ('和' | '跟') v2:constant_Date '之間'=> { - if (!v1.getType().equals(v2.getType())) - return null; - return [v1, v2]; - }; } range_filter = { @@ -126,22 +126,3 @@ range_filter = { }; } -with_filter = { - p:out_param_Any ('和' | '跟') x:constant_Any ('一樣' | '相同')=> C.makeFilter($options, p, '==', x); - p:out_param_Numeric '比' x:constant_Numeric ('大' | '多') => C.makeFilter($options, p, '>=', x); - p:out_param_Numeric '比' x:constant_Numeric ('小' | '少') => C.makeFilter($options, p, '<=', x); - - !turking { - f:range_with_filter => f; - ('無' | '沒有' | '零個') param:out_param_Number => new Ast.BooleanExpression.Atom(param.name, '==', Ast.Value.Number(0)); - } -} -range_with_filter = { - param:out_param_Numeric range:range => { - const [v1, v2] = range; - return new Ast.BooleanExpression.And([ - Ast.BooleanExpression.Atom(param.name, '>=', v1), - Ast.BooleanExpression.Atom(param.name, '<=', v2) - ]); - }; -}