布尔和通配符文本匹配
Boolean & wildcard text matching
是否有人知道任何支持在某些 Web 界面中实现的复杂布尔值 + 通配符文本匹配的 R 包 - 即使用 AND
OR
*
?
()
/{}
运算符?例如,可以处理以下格式查询的函数(所有示例 return TRUE):
s = "The quick brown fox jumps over the lazy dog"
boolean_match(s, "fox AND dog")
boolean_match(s, "fox OR bird")
boolean_match(s, "f?x")
boolean_match(s, "The quick * dog")
boolean_match(s, "lazy AND (fox OR bird)") # i.e. nested logic
boolean_match(s, "(pretty AND bird) OR (quick AND (fox OR squirrel))") # recursive
This question 提出了同样的问题,但没有引起太大兴趣。我知道 stringi
包 - 例如stri_detect_regex(s, c("fox","dog"))
,可能与 all()
/any()
结合使用 - 但它似乎无法处理嵌套逻辑。尝试将这种复杂的查询结构转换为 REGEX 似乎是自取灭亡。
非常感谢任何建议。
我自己写了一些东西 - 请参阅 https://github.com/geotheory/booleanR
是否有人知道任何支持在某些 Web 界面中实现的复杂布尔值 + 通配符文本匹配的 R 包 - 即使用 AND
OR
*
?
()
/{}
运算符?例如,可以处理以下格式查询的函数(所有示例 return TRUE):
s = "The quick brown fox jumps over the lazy dog"
boolean_match(s, "fox AND dog")
boolean_match(s, "fox OR bird")
boolean_match(s, "f?x")
boolean_match(s, "The quick * dog")
boolean_match(s, "lazy AND (fox OR bird)") # i.e. nested logic
boolean_match(s, "(pretty AND bird) OR (quick AND (fox OR squirrel))") # recursive
This question 提出了同样的问题,但没有引起太大兴趣。我知道 stringi
包 - 例如stri_detect_regex(s, c("fox","dog"))
,可能与 all()
/any()
结合使用 - 但它似乎无法处理嵌套逻辑。尝试将这种复杂的查询结构转换为 REGEX 似乎是自取灭亡。
非常感谢任何建议。
我自己写了一些东西 - 请参阅 https://github.com/geotheory/booleanR