SORRY - Lepl은 더 이상 개발되지 않습니다.
도 LEPL있다 - 여기
http://www.acooke.org/lepl 내가 아침 식사를하는 동안 쓴 빠른 해결책 :
pl6 src: python3
Python 3.1 (r31:73572, Oct 24 2009, 05:39:09)
[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from lepl import *
>>>
>>> class Alternatives(Node):
... pass
...
>>> class Query(Node):
... pass
...
>>> class Text(Node):
... pass
...
>>> def compile():
... qualifier = Word() & Drop(':') > 'qualifier'
... word = ~Lookahead('OR') & Word()
... phrase = String()
... text = phrase | word
... word_or_phrase = (Optional(qualifier) & text) > Text
... space = Drop(Space()[1:])
... query = word_or_phrase[1:, space] > Query
... separator = Drop(space & 'OR' & space)
... alternatives = query[:, separator] > Alternatives
... return alternatives.string_parser()
...
>>> parser = compile()
>>>
>>> alternatives = parser('all of these words "with this phrase" '
... 'OR that OR this site:within.site '
... 'filetype:ps from:lastweek')[0]
>>>
>>> print(str(alternatives))
Alternatives
+- Query
| +- Text
| | `- 'all'
| +- Text
| | `- 'of'
| +- Text
| | `- 'these'
| +- Text
| | `- 'words'
| `- Text
| `- 'with this phrase'
+- Query
| `- Text
| `- 'that'
`- Query
+- Text
| `- 'this'
+- Text
| +- qualifier 'site'
| `- 'within.site'
+- Text
| +- qualifier 'filetype'
| `- 'ps'
`- Text
+- qualifier 'from'
`- 'lastweek'
>>>
내가 LEPL는 "장난감"아니라고 주장
- 그것은 재귀 하강은 비록, 그것은 포함 memoisation 및 trampolining, 그 접근 방식의 한계를 피하는 데 도움이됩니다.
그러나 순수 Python이기 때문에 초고속이 아니며 적극적으로 개발되고 있습니다 (새 릴리스, 4.0, 몇 가지 수정 및 개선이 비교적 빨리 예정되어 있습니다).
당신은 아파치 루씬을 살펴 할 수 있습니다 . 필자가 이해할 수 있듯이 파이썬이 아니라 자바와 유사하지만 (자바 스크립트를 사용하여 인터페이스 할 수는 있지만) 비슷한 기능을 수행합니다. –