0

我有一个从文本产生的单词形式列表。此列表包括专有名称(例如 John、Mary、Edinburgh)。在另一个字段中,我有一个专有名称列表。我想得到一个没有正确名称的所有单词形式的列表。

我实际上需要 allWordForms MINUS properNames

数组可以像集合一样使用。但是我们只有集合操作UnionIntersect

剧本到此为止

on mouseUp
   put field "allWordForms" into tWordForms
   split tWordForms by return
   -- tWordForms is now an array

   put field "properNames" into tProperNames
   split tProperNames by return
   -- tProperNames is now an array

   -- .....
   repeat  
   -- .....
   -- .....
   end repeat

   combine tWordForms using return

   put tWordForms into field "wordFormsWithoutProperNames"

end mouseUp

重复循环是什么样子的?

这是一个例子。

“allWordForms”字段包含

Mary
and
John
came
yesterday
They
want
to
move
from
Maryland
to
Petersbourough

`

“properNames”字段包含

John
Mary
Maryland
Peter
Petersbourough

期望的结果是allWordForms删除正确名称的列表副本。

and
came
yesterday
They
want
to
move
from
to
4

2 回答 2

1

这是一个可能的解决方案;

on mouseUp
   put field "allWordForms" into tWordForms
   put field "properNames" into tProperNames

   # replace proper names
   repeat for each line tProperName in tProperNames
      replace tProperName with empty in tWordForms
   end repeat

   # remove blank lines
   replace LF & LF with LF in tWordForms   

   put tWordForms into field "wordFormsWithoutProperNames"
end mouseUp

另一种考虑您的额外信息的解决方案;

on mouseUp
   put field "allWordForms" & LF into tWordForms
   put field "properNames" into tProperNames

   repeat for each line tProperName in tProperNames
      replace tProperName & LF with empty in tWordForms
   end repeat

   put tWordForms into field "wordFormsWithoutProperNames"
end mouseUp
于 2013-05-05T07:19:35.317 回答
0

您可以使用没有模式功能的过滤器容器:

put field "allWordsForms" into tResult
repeat for each line aLine in field "ProperNames"
   filter tResult without aLine
end repeat
put tResult into field "wordFormsWithoutProperNames"
于 2013-05-08T08:39:30.813 回答