सोरी - लीप्ल अब विकसित नहीं किया जा रहा है।
वहाँ भी 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 एक "खिलौना" नहीं है - हालांकि यह पुनरावर्ती वंश है, यह भी शामिल है ज्ञापन और trampolining, जो उस दृष्टिकोण की कुछ सीमाओं से बचने में मदद करते हैं।
हालांकि, यह शुद्ध पायथन है, इसलिए यह सुपर-फास्ट नहीं है, और यह सक्रिय विकास में है (एक नई रिलीज, 4.0, कुछ फिक्स और सुधार के साथ, अपेक्षाकृत जल्द ही आ रहा है)।
स्रोत
2010-03-03 12:19:12
आप अपाचे Lucene पर एक नज़र लेने के लिए चाहते हो सकता है । मेरी समझ के लिए, यह कुछ समान है, हालांकि यह जावा में है, पायथन नहीं (हालांकि आप ज्योथन का उपयोग कर इसके साथ इंटरफ़ेस कर सकते हैं)। –