http://en.wikipedia.org/wiki/Markov_AlgorithmA - > apple
B - >包
S - >店
T - >
商店 - >我的兄弟
一个从未使用过的 - >。终止规则
</pre><p>示例文本: </p><p><code>I bought a B of As from T S.</code></p><p>应该生成输出: </p><p><code>I bought a bag of apples from my brother.</code></p>规则集2:<p>终止规则的测试</p><pre>从维基百科的规则略有修改 - >苹果
B - >包
S - > .shop
T - >
商店 - >我的兄弟
一个从未使用过的 - >。终止规则</pre><p>示例文本: </p><p><code>I bought a B of As from T S.</code></p><p>应该生成: </p><p><code>I bought a bag of apples from T shop.</code></p>规则集3:<p>如果没有转义特殊的正则表达式字符,这将测试正确的替换顺序并可能捕获简单的基于正则表达式的替换例程。 </p><pre> BNF语法测试规则A - > apple
</pre><p>示例文本: </p><p><code>I bought a B of As W my Bgage from T S.</code></p><p>应该生成: </p><p><code>I bought a bag of apples with my money from T shop.</code></p>规则集4:<p>这将测试规则扫描的正确顺序,并可能捕获以错误顺序扫描的替换例程。它实现了一般的一元乘法引擎。 (请注意,在此实现中,输入表达式必须放在下划线中。) </p><pre> ##一元乘法引擎,用于测试马尔可夫算法实现
- text: <code>markov(["A -> apple","B -> bag","S -> shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.")</code>应该回复“我从我兄弟那里买了一袋苹果”。
- text: <code>markov(["A -> apple","B -> bag","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As from T S.")</code>应该回来“我从T商店买了一袋苹果。”
- text: <code>markov(["A -> apple","WWWW -> with","Bgage -> ->.*","B -> bag","->.* -> money","W -> WW","S -> .shop","T -> the","the shop -> my brother","a never used -> .terminating rule"],"I bought a B of As W my Bgage from T S.")</code>应该返回”我从T商店用我的钱买了一袋苹果。“