如何创建搜索查询分析器 [英] how to create a parser for search queries

查看:113
本文介绍了如何创建搜索查询分析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如我需要创造一些像谷歌搜索查询解析器来解析这些非pressions为:

for example i'd need to create something like google search query parser to parse such expressions as:

飞远足性游泳
   - 走在靴子的 作者:哈米什作者:里德

flying hiking or swiming -"walking in boots " author:hamish author:reid

房子的纽约售价超过
  $ 500000的游泳池

如何将我连去开始建立类似的东西呢?任何好的资源?

how would i even go about start building something like it? any good resources?

C#相关,请(如果可能)


  • 编辑:这是一件我应该以某种方式能够转换成SQL查询

推荐答案

多少个关键字你有(像'或','中','价格比','与')?如果你只有一对夫妇的人我建议过于简单的字符串处理(正则表达式)去。

How many keywords do you have (like 'or', 'in', 'priced over', 'with a')? If you only have a couple of them I'd suggest going with simple string processing (regexes) too.

但如果你有比你可能要考虑实施的真正的那些搜索前pressions分析器多。 Irony.net 可以帮你(我发现它非常容易,你可以使用恩preSS在不久的BNF形式直接在code你的语法)。

But if you have more than that you might want to look into implementing a real parser for those search expressions. Irony.net might help you with that (I found it extremely easy to use as you can express your grammar in a near bnf-form directly in code).

这篇关于如何创建搜索查询分析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆