0

我有 2 个应该完全并行的例程。我希望 Snowball 执行它们并选择匹配时间最长的那个。

目前,我使用or. 这意味着执行第一个,如果失败则执行第二个。

我想对两个例程进行测试以获取匹配长度,将其存储在变量中,然后比较它们并执行具有最长匹配的例程。

是否有执行此操作的标准说明或更好的解决方案?

伪代码:

 Verb_Suffixes 
 or 
 Noun_Suffixes

真实代码

    //Suffixes for verbs
  ( 
   is_verb
   (
       (
          (atleast 1 Suffix_Verb_Step1) 
          ( Suffix_Verb_Step2a or Suffix_Verb_Step2c  or next)
        )
        or Suffix_Verb_Step2b
        or Suffix_Verb_Step2a
    )
   )
    //Suffixes for nouns 
    or (
       is_noun
        ( 

         try ( 
             Suffix_Noun_Step2c2
             or (not is_defined Suffix_Noun_Step1a ( 
                    Suffix_Noun_Step2a 
                    or Suffix_Noun_Step2b 
                    or Suffix_Noun_Step2c1 
                    or next))
             or (Suffix_Noun_Step1b ( 
                    Suffix_Noun_Step2a 
                    or Suffix_Noun_Step2b 
                    or Suffix_Noun_Step2c1))
             or (not is_defined Suffix_Noun_Step2a)
             or (Suffix_Noun_Step2b)
         )
         Suffix_Noun_Step3
         )
    )
4

1 回答 1

0

它没有标准指令,但可以通过在每个例程之后获取光标值来完成,而不是比较它们并返回它应该在的位置:

$c = 0 
do test (Verb_Suffixes  $c = cursor)
do test (Noun_Suffixes ($c < cursor $c = cursor))
tomark c

($c < cursor $c = cursor)方法if ($c < cursor) $c = cursor

而对于test,来自雪球手册的定义:

测试 C

这确实命令 C 但没有推进 c。它的信号与 C 的信号相同,但在信号 t 之后,c 被设置回原来的值。

于 2016-01-10T07:32:03.400 回答