shuai-xu commented on a change in pull request #11168: [FLINK-16140] [docs-zh] 
Translate Event Processing (CEP) page into Chinese
URL: https://github.com/apache/flink/pull/11168#discussion_r387438639
 
 

 ##########
 File path: docs/dev/libs/cep.zh.md
 ##########
 @@ -136,140 +132,143 @@ val result: DataStream[Alert] = patternStream.process(
 </div>
 </div>
 
-## The Pattern API
+## 模式API
 
-The pattern API allows you to define complex pattern sequences that you want 
to extract from your input stream.
+模式API可以让你定义想从输入流中抽取的复杂模式序列。
 
-Each complex pattern sequence consists of multiple simple patterns, i.e. 
patterns looking for individual events with the same properties. From now on, 
we will call these simple patterns **patterns**, and the final complex pattern 
sequence we are searching for in the stream, the **pattern sequence**. You can 
see a pattern sequence as a graph of such patterns, where transitions from one 
pattern to the next occur based on user-specified
-*conditions*, e.g. `event.getName().equals("end")`. A **match** is a sequence 
of input events which visits all
-patterns of the complex pattern graph, through a sequence of valid pattern 
transitions.
+每个复杂的模式序列包括多个简单的模式,比如,寻找拥有相同属性事件序列的模式。从现在开始,我们把这些简单的模式称作**模式**,
+把我们在数据流中最终寻找的复杂模式序列称作**模式序列**,你可以把模式序列看作是这样的模式构成的图,
+这些模式基于用户指定的**条件**从一个转换到另外一个,比如 `event.getName().equals("end")`。
+一个**匹配**是输入事件的一个序列,这些事件通过一系列有效的模式转换,能够访问到复杂模式图中的所有模式。
 
-{% warn Attention %} Each pattern must have a unique name, which you use later 
to identify the matched events.
+{% warn 注意 %} 每个模式必须有一个独一无二的名字,你可以在后面使用它来识别匹配到的事件。
 
-{% warn Attention %} Pattern names **CANNOT** contain the character `":"`.
+{% warn 注意 %} 模式的名字不能包含字符`":"`.
 
-In the rest of this section we will first describe how to define [Individual 
Patterns](#individual-patterns), and then how you can combine individual 
patterns into [Complex Patterns](#combining-patterns).
+这一节的剩余部分我们会先讲述如何定义[单个模式](#单个模式),然后讲如何将单个模式组合成[复杂模式](#组合模式)。
 
-### Individual Patterns
+### 单个模式
 
-A **Pattern** can be either a *singleton* or a *looping* pattern. Singleton 
patterns accept a single
-event, while looping patterns can accept more than one. In pattern matching 
symbols, the pattern `"a b+ c? d"` (or `"a"`, followed by *one or more* 
`"b"`'s, optionally followed by a `"c"`, followed by a `"d"`), `a`, `c?`, and 
`d` are
-singleton patterns, while `b+` is a looping one. By default, a pattern is a 
singleton pattern and you can transform
-it to a looping one by using [Quantifiers](#quantifiers). Each pattern can 
have one or more
-[Conditions](#conditions) based on which it accepts events.
+一个**模式**可以是一个**单例**或者**循环**模式。单例模式只接受一个事件,循环模式可以接受多个事件。
+在模式匹配表达式中,模式`"a b+ c? 
d"`(或者`"a"`,后面跟着一个或者多个`"b"`,再往后可选择的跟着一个`"c"`,最后跟着一个`"d"`),
+`a`,`c?`,和 `d`都是单例模式,`b+`是一个循环模式。默认情况下,模式都是单例的,你可以通过使用[量词](#量词)把它们转换成循环模式。
+每个模式可以有一个或者多个[条件](#条件)来决定它接受哪些事件。
 
-#### Quantifiers
+#### 量词
 
-In FlinkCEP, you can specify looping patterns using these methods: 
`pattern.oneOrMore()`, for patterns that expect one or more occurrences of a 
given event (e.g. the `b+` mentioned before); and `pattern.times(#ofTimes)`, 
for patterns that
-expect a specific number of occurrences of a given type of event, e.g. 4 
`a`'s; and `pattern.times(#fromTimes, #toTimes)`, for patterns that expect a 
specific minimum number of occurrences and a maximum number of occurrences of a 
given type of event, e.g. 2-4 `a`s.
+在FlinkCEP中,你可以通过这些方法指定循环模式:`pattern.oneOrMore()`,指定期望一个给定事件出现一次或者多次的模式(例如前面提到的`b+`模式);
+`pattern.times(#ofTimes)`,指定期望一个给定事件出现特定次数的模式,例如出现4次`a`;
+`pattern.times(#fromTimes, 
#toTimes)`,指定期望一个给定事件出现次数在一个最小值和最大值中间的模式,比如出现2-4次`a`。
 
-You can make looping patterns greedy using the `pattern.greedy()` method, but 
you cannot yet make group patterns greedy. You can make all patterns, looping 
or not, optional using the `pattern.optional()` method.
+你可以使用`pattern.greedy()`方法让循环模式变成贪心的,但现在还不能让模式组贪心。
+你可以使用`pattern.optional()`方法让所有的模式变成可选的,不管是否是循环模式。
 
-For a pattern named `start`, the following are valid quantifiers:
+对一个命名为`start`的模式,以下量词是有效的:
 
 <div class="codetabs" markdown="1">
 <div data-lang="java" markdown="1">
 {% highlight java %}
-// expecting 4 occurrences
+// 期望出现4次
 start.times(4);
 
-// expecting 0 or 4 occurrences
+// 期望出现0或者4次
 start.times(4).optional();
 
-// expecting 2, 3 or 4 occurrences
+// 期望出现2、3或者4次
 start.times(2, 4);
 
-// expecting 2, 3 or 4 occurrences and repeating as many as possible
+// 期望出现2、3或者4次,并且尽可能的重复次数多
 start.times(2, 4).greedy();
 
-// expecting 0, 2, 3 or 4 occurrences
+// 期望出现0、2、3或者4次
 start.times(2, 4).optional();
 
-// expecting 0, 2, 3 or 4 occurrences and repeating as many as possible
+// 期望出现0、2、3或者4次,并且尽可能的重复次数多
 start.times(2, 4).optional().greedy();
 
-// expecting 1 or more occurrences
+// 期望出现1到多次
 start.oneOrMore();
 
-// expecting 1 or more occurrences and repeating as many as possible
+// 期望出现1到多次,并且尽可能的重复次数多
 start.oneOrMore().greedy();
 
-// expecting 0 or more occurrences
+// 期望出现0到多次
 start.oneOrMore().optional();
 
-// expecting 0 or more occurrences and repeating as many as possible
+// 期望出现0到多次,并且尽可能的重复次数多
 start.oneOrMore().optional().greedy();
 
-// expecting 2 or more occurrences
+// 期望出现2到多次
 start.timesOrMore(2);
 
-// expecting 2 or more occurrences and repeating as many as possible
+// 期望出现2到多次,并且尽可能的重复次数多
 start.timesOrMore(2).greedy();
 
-// expecting 0, 2 or more occurrences and repeating as many as possible
+// 期望出现0、2或多次
+start.timesOrMore(2).optional();
+
+// 期望出现0、2或多次,并且尽可能的重复次数多
 start.timesOrMore(2).optional().greedy();
 {% endhighlight %}
 </div>
 
 <div data-lang="scala" markdown="1">
 {% highlight scala %}
-// expecting 4 occurrences
+// 期望出现4次
 start.times(4)
 
-// expecting 0 or 4 occurrences
+// 期望出现0或者4次
 start.times(4).optional()
 
-// expecting 2, 3 or 4 occurrences
+// 期望出现2、3或者4次
 start.times(2, 4)
 
-// expecting 2, 3 or 4 occurrences and repeating as many as possible
+// 期望出现2、3或者4次,并且尽可能的重复次数多
 start.times(2, 4).greedy()
 
-// expecting 0, 2, 3 or 4 occurrences
+// 期望出现0、2、3或者4次
 start.times(2, 4).optional()
 
-// expecting 0, 2, 3 or 4 occurrences and repeating as many as possible
+// 期望出现0、2、3或者4次,并且尽可能的重复次数多
 start.times(2, 4).optional().greedy()
 
-// expecting 1 or more occurrences
+// 期望出现1到多次
 start.oneOrMore()
 
-// expecting 1 or more occurrences and repeating as many as possible
+// 期望出现1到多次,并且尽可能的重复次数多
 start.oneOrMore().greedy()
 
-// expecting 0 or more occurrences
+// 期望出现0到多次
 start.oneOrMore().optional()
 
-// expecting 0 or more occurrences and repeating as many as possible
+// 期望出现0到多次,并且尽可能的重复次数多
 start.oneOrMore().optional().greedy()
 
-// expecting 2 or more occurrences
+// 期望出现2到多次
 start.timesOrMore(2)
 
-// expecting 2 or more occurrences and repeating as many as possible
+// 期望出现2到多次,并且尽可能的重复次数多
 start.timesOrMore(2).greedy()
 
-// expecting 0, 2 or more occurrences
+// 期望出现0、2或多次
 start.timesOrMore(2).optional()
 
-// expecting 0, 2 or more occurrences and repeating as many as possible
+// 期望出现0、2或多次,并且尽可能的重复次数多
 start.timesOrMore(2).optional().greedy()
 {% endhighlight %}
 </div>
 </div>
 
-#### Conditions
+#### 条件
 
-For every pattern you can specify a condition that an incoming event has to 
meet in order to be "accepted" into the pattern e.g. its value should be larger 
than 5,
-or larger than the average value of the previously accepted events.
-You can specify conditions on the event properties via the `pattern.where()`, 
`pattern.or()` or `pattern.until()` methods.
-These can be either `IterativeCondition`s or `SimpleCondition`s.
+对每个模式你可以指定一个条件来决定一个进来的事件是否被接受进入这个模式,例如,它的value字段应该大于5,或者大于前面接受的事件的平均值。
+指定判断事件属性的条件可以通过`pattern.where()`、`pattern.or()`或者`pattern.until()`方法。
+这些可以是`IterativeCondition`或者`SimpleCondition`。
 
-**Iterative Conditions:** This is the most general type of condition. This is 
how you can specify a condition that
-accepts subsequent events based on properties of the previously accepted 
events or a statistic over a subset of them.
+**迭代条件:** 这是最普遍的条件类型。使用它可以指定一个基于前面已经被接受的事件的属性或者它们的一个子集的统计数据来决定是否接受时间序列的条件。
 
-Below is the code for an iterative condition that accepts the next event for a 
pattern named "middle" if its name starts
-with "foo", and if the sum of the prices of the previously accepted events for 
that pattern plus the price of the current event do not exceed the value of 
5.0. Iterative conditions can be powerful, especially in combination with 
looping patterns, e.g. `oneOrMore()`.
+下面是一个迭代条件的代码,它接受"middle"模式下一个事件的名称开头是"foo", 并且前面已经匹配到的事件的加个加上这个事件的价格小于5.0。
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to