Skip to content

Commit

Permalink
Modify filters structure for Chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnychhsu committed Mar 6, 2019
1 parent 33c7298 commit 65f549b
Showing 1 changed file with 16 additions and 35 deletions.
51 changes: 16 additions & 35 deletions languages/zh-tw/filters.genie
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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.)
Expand All @@ -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 = {
Expand All @@ -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)
]);
};
}

0 comments on commit 65f549b

Please sign in to comment.