METADATA 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. Metadata-Version: 2.1
  2. Name: lunr
  3. Version: 0.5.8
  4. Summary: A Python implementation of Lunr.js
  5. Home-page: https://github.com/yeraydiazdiaz/lunr.py
  6. Author: Yeray Diaz Diaz
  7. Author-email: yeraydiazdiaz@gmail.com
  8. License: MIT
  9. Keywords: lunr full text search
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 3 - Alpha
  12. Classifier: Intended Audience :: Developers
  13. Classifier: License :: OSI Approved :: MIT License
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python
  16. Classifier: Programming Language :: Python :: 2
  17. Classifier: Programming Language :: Python :: 2.7
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3.5
  20. Classifier: Programming Language :: Python :: 3.6
  21. Classifier: Programming Language :: Python :: 3.7
  22. Classifier: Programming Language :: Python :: 3.8
  23. Classifier: Programming Language :: Python :: Implementation :: CPython
  24. Classifier: Programming Language :: Python :: Implementation :: PyPy
  25. Classifier: Topic :: Text Processing
  26. Description-Content-Type: text/markdown
  27. Requires-Dist: future (>=0.16.0)
  28. Requires-Dist: six (>=1.11.0)
  29. Requires-Dist: enum34 ; python_version<'3'
  30. Provides-Extra: languages
  31. Requires-Dist: nltk (<3.5,>=3.2.5) ; (python_version < "3") and extra == 'languages'
  32. Requires-Dist: nltk (>=3.2.5) ; (python_version > "2.7") and extra == 'languages'
  33. [![Build Status](https://travis-ci.org/yeraydiazdiaz/lunr.py.svg?branch=master)](https://travis-ci.org/yeraydiazdiaz/lunr.py)
  34. [![codecov](https://codecov.io/gh/yeraydiazdiaz/lunr.py/branch/master/graph/badge.svg)](https://codecov.io/gh/yeraydiazdiaz/lunr.py)
  35. [![Supported Python Versions](https://img.shields.io/pypi/pyversions/lunr.svg)](https://pypi.org/project/lunr/)
  36. [![PyPI](https://img.shields.io/pypi/v/lunr.svg)](https://pypi.org/project/lunr/)
  37. [![Read the Docs](https://img.shields.io/readthedocs/lunr.svg)](http://lunr.readthedocs.io/en/latest/)
  38. [![Downloads](http://pepy.tech/badge/lunr)](http://pepy.tech/project/lunr)
  39. # Lunr.py
  40. A Python implementation of [Lunr.js](https://lunrjs.com) by [Oliver Nightingale](https://github.com/olivernn).
  41. > A bit like Solr, but much smaller and not as bright.
  42. This Python version of Lunr.js aims to bring the simple and powerful full text search capabilities into Python guaranteeing results as close as the original implementation as possible.
  43. - [Documentation](http://lunr.readthedocs.io/en/latest/)
  44. ## What does this even do?
  45. Lunr is a simple full text search solution for situations where deploying a full scale solution like Elasticsearch isn't possible, viable or you're simply prototyping.
  46. Lunr parses a set of documents and creates an inverted index for quick full text searches.
  47. The typical use case is to integrate Lunr in a web application, an example would be the [MkDocs documentation library](http://www.mkdocs.org/). In order to do this, you'd integrate [Lunr.js](https://lunrjs.com) in the Javascript code of your application, which will need to fetch and parse a JSON of your documents and create the index at startup of your application. Depending on the size of your document set this can take some time and potentially block the browser's main thread.
  48. Lunr.py provides a backend solution, allowing you to parse the documents ahead of time and create a Lunr.js compatible index you can pass have the browser version read, minimizing start up time of your application.
  49. Of course you could also use Lunr.py to power full text search in desktop applications or backend services to search on your documents mimicking Elasticsearch.
  50. ## Installation
  51. Simply `pip install lunr` for the english only, best compatibility with Lunr.js version.
  52. An optional and experimental support for other languages via the [Natural Language Toolkit](http://www.nltk.org/) stemmers is also available via `pip install lunr[languages]`. Please refer to the [documentation page on languages](https://lunr.readthedocs.io/en/latest/languages/) for more information.
  53. ## Current state
  54. Each version of lunr.py [targets a specific version of lunr.js](https://github.com/yeraydiazdiaz/lunr.py/blob/master/lunr/__init__.py#L12) and produces the same results as it both in Python 2.7 and 3 for [non-trivial corpus of documents](https://github.com/yeraydiazdiaz/lunr.py/blob/master/tests/acceptance_tests/fixtures/mkdocs_index.json).
  55. Lunr.py also serializes `Index` instances respecting the [`lunr-schema`](https://github.com/olivernn/lunr-schema) which are consumable by Lunr.js and viceversa.
  56. The API is in alpha stage and likely to change.
  57. ## Usage
  58. You'll need a list of dicts representing the documents you want to search on. These documents must have a unique field which will serve as a reference and a series of fields you'd like to search on.
  59. Lunr provides a convenience `lunr` function to quickly index this set of documents:
  60. ```python
  61. >>> from lunr import lunr
  62. >>>
  63. >>> documents = [{
  64. ... 'id': 'a',
  65. ... 'title': 'Mr. Green kills Colonel Mustard',
  66. ... 'body': 'Mr. Green killed Colonel Mustard in the study with the candlestick.',
  67. ... }, {
  68. ... 'id': 'b',
  69. ... 'title': 'Plumb waters plant',
  70. ... 'body': 'Professor Plumb has a green plant in his study',
  71. ... }]
  72. >>> idx = lunr(
  73. ... ref='id', fields=('title', 'body'), documents=documents
  74. ... )
  75. >>> idx.search('kill')
  76. [{'ref': 'a', 'score': 0.6931722372559913, 'match_data': <MatchData "kill">}]
  77. >>> idx.search('study')
  78. [{'ref': 'b', 'score': 0.23576799568081389, 'match_data': <MatchData "studi">}, {'ref': 'a', 'score': 0.2236629211724517, 'match_data': <MatchData "studi">}]
  79. ```
  80. Please refer to the [documentation](http://lunr.readthedocs.io/en/latest/) for more usage examples.