{"id":18547708,"url":"https://github.com/silviomessi/nlu","last_synced_at":"2025-04-09T21:31:51.061Z","repository":{"id":234752212,"uuid":"95097683","full_name":"SilvioMessi/nlu","owner":"SilvioMessi","description":"Python library for Natural Language Understanding","archived":false,"fork":false,"pushed_at":"2017-07-14T10:31:02.000Z","size":188,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T11:22:02.033Z","etag":null,"topics":["chatbot","natural-language-understanding","nlu"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SilvioMessi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-06-22T09:20:08.000Z","updated_at":"2024-06-23T20:39:18.000Z","dependencies_parsed_at":"2024-04-20T17:23:47.017Z","dependency_job_id":"cb063f66-ad6d-4f94-a01c-016fa539f2d7","html_url":"https://github.com/SilvioMessi/nlu","commit_stats":null,"previous_names":["silviomessi/nlu"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SilvioMessi%2Fnlu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SilvioMessi%2Fnlu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SilvioMessi%2Fnlu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SilvioMessi%2Fnlu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SilvioMessi","download_url":"https://codeload.github.com/SilvioMessi/nlu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248114742,"owners_count":21050102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatbot","natural-language-understanding","nlu"],"created_at":"2024-11-06T20:30:49.671Z","updated_at":"2025-04-09T21:31:50.345Z","avatar_url":"https://github.com/SilvioMessi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NLU\nPython library for NLU (Natural Language Understanding).  \nThis python library allows to identify intents and entities present in a sentence, starting from a train set of examples. \n\n## Installation\n``` \npip install git+https://github.com/SilvioMessi/nlu.git \n```\n### Dependencies\n*  Stanford CoreNLP  \nAt the moment all the NLP (Natural Language Processing) task are made by [Stanford CoreNLP](https://stanfordnlp.github.io/CoreNLP/), used like external [server](https://stanfordnlp.github.io/CoreNLP/corenlp-server.html).  \nBefore use NLU library make sure that an instance of CoreNLP Server is correctly running on port 9000.\n* Wordnet  \nThe NLU library use [Wordnet](https://wordnet.princeton.edu/).  \nBefore use NLU library make sure that Wordnet corpora is correctly \"intstalled\" by [NTLK](http://www.nltk.org/data.html).\n\n## Basic Usage\n```python\nfrom nlu.entity_recognizer import EntityRecognizer\nfrom nlu.intent_recognizer import IntentRecognizer\n\nentity_recongizer = EntityRecognizer()\nintent_recognizer = IntentRecognizer()\n    \n# load entities definitions from datastore and put them in data structure\n entities = {\n  'pizza_type': {\n    'Margherita' : ['Margherita', 'margherita'],\n    'Neapolitan' : ['Neapolitan', 'neapolitan'],\n    'Sicilian' : ['Sicilian', 'sicilian']\n  },\n  'drink_type' : {\n    'Coca-Cola' : ['Coca-Cola', 'coca cola', 'coke'],\n    'Beer' : ['Beer', 'beer'],\n    'Water' : ['Water', 'water'],\n    'Wine' : ['Wine', 'wine']\n  }\n}\n\n# load intents definitions from datastore and put them in data structure\nintents = {\n  'order_a_pizza': ['Can i have a pizza margherita?', 'A pizza margherita, please !', 'Two margherita please!'],\n  'order_a_drink': ['Can i have a can of coke?', 'I\\'ll have a glass of wine!']\n}\n\n# intents definitions can be pre tagged with entities\nintents_pre_tagged = {\n  'order_a_pizza': ['Can i have a pizza pizza_type?', 'A pizza pizza_type, please !', 'Two pizza_type please!'],\n  'order_a_drink': ['Can i have a can of drink_type?', 'I\\'ll have a glass of drink_type!']\n}\n\nnew_sentence = 'I want order a pizza margherita and a can of coca cola!'\n\n# find entities in new sentence\nsentence_tokens, final_entities_positions, tagged_sentence = entity_recongizer.get_entities(entities, new_sentence, tag_sentence=True)\n\nprint(sentence_tokens)\n['I', 'want', 'order', 'a', 'pizza', 'margherita', 'and', 'a', 'can', 'of', 'coca', 'cola', '!']\n\nprint(final_entities_positions)\n[{'entity_id': 'pizza_type', 'value_id': 'Margherita', 'start': 21, 'end': 31}, {'entity_id': 'drink_type', 'value_id': 'Coca-Cola', 'start': 45, 'end': 54}]\n\n# if parameter tag_sentence=True\nprint(tagged_sentence)\nI want order a pizza pizza_type and a can of drink_type !\n\n# find intents probabilities \nintents_probabilities = intent_recognizer.get_intents_probabilities(intents, new_sentence)\n\nprint(intents_probabilities)\n{'order_a_pizza': 0.51000000000000001, 'order_a_drink': 0.161}\n\n# better performance can be achieved used tagged sentences\nintents_probabilities = intent_recognizer.get_intents_probabilities(intents_pre_tagged, tagged_sentence)\n\nprint(intents_probabilities)\n{'order_a_pizza': 0.53653846153846152, 'order_a_drink': 0.23928846153846156}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviomessi%2Fnlu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilviomessi%2Fnlu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviomessi%2Fnlu/lists"}