{ "info": { "author": "Pooya Eghbali", "author_email": "persian.writer@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Human Machine Interfaces", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing", "Topic :: Text Processing :: General", "Topic :: Text Processing :: Linguistic" ], "description": "What is Bridge?\n===============\n\nBridge is a light-weight portable library for natural language processing and because of its tiny size it can be easily ported to any programming languages. As of now Bridge provides a Python Library in 50 SLOC and a JavaScript one in 78 SLOC.\n\nHow Bridge Works?\n=================\n\nUnlike other natural language processing approaches that investigate grammatical features of a language, Bridge aims the structred meaning. Bridge knows the meaningful parts of a text and instead of grammatically examining it to extract meaning, it literally understands the sentence.\n\nA Sample Program with Bridge\n============================\n\nIt's better to show the power of Bridge with an example, thus let's build a simple calculator with Bridge!\n\nFirst we should construct a Bridge Object:\n\n Bridge = bridge();\n\nNow, Let us add our Meaning Models to Bridge. First of all, we'll teach it what is a number. We'll use a grammar object to teach Bridge a new concept. Each grammar has one or more \"type\" or \"role\", for example our number have role \"number\". Also, we need some definitions to create a grammar. Each definition or model, should have a single \"type\" and a regex pattern to test atoms passed to it. Each grammar has a \"value\" that Bridge uses to create the resulting atom. Finally each grammar has a \"weight\" that shows the importance of the grammar.\n\nWhen first Bridge examines a sentence, it breaks the sentence to atoms. Each atom shows a meaningful part of speech in Bridge, At the first examination Bridge gives all of the atoms a \"word\" type.\n\nWe'll teach the number model as follows::\n\n Bridge.add_grammar(\n grammar(\n ['number'], # grammar type\n [definition( # definitions\n 'word', # type of atom to accept\n r'^\\d+$')], # regex to match atoms against\n '{0}', # grammar value\n 0)); # weight\n\nNow let's teach it the basic mathematical operators::\n\n Bridge.add_grammar(grammar(['plus'], [definition('word', r'^\\+$')], '{0}', 0)) # plus\n Bridge.add_grammar(grammar(['minus'], [definition('word', r'^-$')], '{0}', 0)) # minus\n\nNow we'll teach mathematical operations and use the models we've already defined::\n\n Bridge.add_grammar(\n grammar(['plus-command', 'number'],\n [definition('number', r'.*'),\n definition('plus', r'.*'),\n definition('number', r'.*')],\n '(+ {0} {2})', 1));\n\n Bridge.add_grammar(\n grammar(['minus-command', 'number'],\n [definition('number', r'.*'),\n definition('minus', r'.*'),\n definition('number', r'.*')],\n '(- {2} {0})', 1));\n\nNow Bridge can do simple mathematical operations, for now it can take this::\n\n 1 - 2 + 3 - 4 + 5\n\nAnd convert it to the following lisp code::\n\n (+ (- 4 (+ (- 2 1) 3)) 5)\n\n(you may run this lisp using hy) It's time to teach Bridge some natural language::\n\n Bridge.add_grammar(\n grammar\n (['and'],\n [definition('word', r'^and$')],\n '{0}', 0));\n\n Bridge.add_grammar(\n grammar(\n ['numeral-and', 'number'],\n [definition('number', r'.*'),\n definition('and', r'.*'),\n definition('number', r'.*')],\n '{0} {2}', 2));\n\n Bridge.add_grammar(\n grammar\n (['sum-command'],\n [definition('word', r'^sum$')],\n '{0}', 0));\n\n Bridge.add_grammar(\n grammar(\n ['complete-function'],\n [definition('sum-command', r'.*'),\n definition('numeral-and', r'.*')],\n '(+ {1})', 3))\n\nUsing the following code::\n\n sentence = \"sum 3 + 4 and 5 and 6 - 7 and 4\"\n print(Bridge.process(sentence)[0].value))\n\nWe'll get::\n\n (+ (+ 3 4) 5 (- 7 6) 4)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pooya-eghbali/bridge", "keywords": "natural language processing,nlp", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "pybridge", "package_url": "https://pypi.org/project/pybridge/", "platform": "Any", "project_url": "https://pypi.org/project/pybridge/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/pooya-eghbali/bridge" }, "release_url": "https://pypi.org/project/pybridge/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "Bridge for Python (Bridge is a light-weight portable Natural Language Processing Library)", "version": "1.0.1" }, "last_serial": 1670420, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "0536336994e58103d74a25c12cf1efb6", "sha256": "e36c2ea2fa4166183bb0d3970ddda7bc32ca7a8037ed1908f0e8080cb4c537da" }, "downloads": -1, "filename": "pybridge-1.0.0.zip", "has_sig": false, "md5_digest": "0536336994e58103d74a25c12cf1efb6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4530, "upload_time": "2015-07-26T01:44:06", "url": "https://files.pythonhosted.org/packages/bf/b7/a129fff475a425db3ec4eac5c12b38eabe73fdc1efdc657e5ce3c524c46b/pybridge-1.0.0.zip" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "d605d855db98c6975e7282eace1b2f7e", "sha256": "7a39d7eed7cf3959ec48ead5476c05a7efaadbc910252859341b44c62ca8966a" }, "downloads": -1, "filename": "pybridge-1.0.1.zip", "has_sig": false, "md5_digest": "d605d855db98c6975e7282eace1b2f7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4803, "upload_time": "2015-07-29T10:40:42", "url": "https://files.pythonhosted.org/packages/00/6d/903bdf7f0960b9b33ad9124de35a0b897a41ebc64e5451fedd837cb6a271/pybridge-1.0.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d605d855db98c6975e7282eace1b2f7e", "sha256": "7a39d7eed7cf3959ec48ead5476c05a7efaadbc910252859341b44c62ca8966a" }, "downloads": -1, "filename": "pybridge-1.0.1.zip", "has_sig": false, "md5_digest": "d605d855db98c6975e7282eace1b2f7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4803, "upload_time": "2015-07-29T10:40:42", "url": "https://files.pythonhosted.org/packages/00/6d/903bdf7f0960b9b33ad9124de35a0b897a41ebc64e5451fedd837cb6a271/pybridge-1.0.1.zip" } ] }