{"id":20374241,"url":"https://github.com/snwfdhmp/prose","last_synced_at":"2025-04-12T07:12:31.864Z","repository":{"id":57552806,"uuid":"117458265","full_name":"snwfdhmp/prose","owner":"snwfdhmp","description":"Chatbot framework powered by regular expressions","archived":false,"fork":false,"pushed_at":"2019-02-25T22:19:32.000Z","size":16,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T07:12:26.237Z","etag":null,"topics":["golang","language-processing","natural-language-processing","natural-language-understanding","regex","regexp"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/snwfdhmp/prose","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snwfdhmp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-14T19:04:26.000Z","updated_at":"2023-04-06T06:15:57.000Z","dependencies_parsed_at":"2022-09-26T18:50:55.399Z","dependency_job_id":null,"html_url":"https://github.com/snwfdhmp/prose","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snwfdhmp%2Fprose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snwfdhmp%2Fprose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snwfdhmp%2Fprose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snwfdhmp%2Fprose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snwfdhmp","download_url":"https://codeload.github.com/snwfdhmp/prose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530571,"owners_count":21119600,"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":["golang","language-processing","natural-language-processing","natural-language-understanding","regex","regexp"],"created_at":"2024-11-15T01:23:11.299Z","updated_at":"2025-04-12T07:12:31.842Z","avatar_url":"https://github.com/snwfdhmp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prose\n\n## Introduction\n\nProse implements simple language-processing by using simple regexps to recognize certain \"meaning entities\" inside a message.\n\nIt's good at :\n\n- Understanding a command request and its parameters out of a human message\n\nIt's not good at :\n\n- Understanding the meaning of a message outside pre-defined scopes\n\nExtended documentation can be found [here](https://godoc.org/github.com/snwfdhmp/prose).\n\n## Summary\n\n- [Get Started](#get-started)\n\t- [Entity](#entity)\n\t- [Action](#action)\n\t- [AI](#ai)\n- [Example](#example)\n- [Author](#author)\n\n# Get Started\n\nYou can install package simply by\n\n```\ngo get github.com/snwfdhmp/prose\n```\n\nThen you can use it simply by importing `github.com/snwfdhmp/prose`.\n\nFull documentation can be found [here](https://godoc.org/github.com/snwfdhmp/prose).\n\n## Entity\n\nAn entity object contains a compiled regexp that will match strings if the entity exists in it.\nYou can consider an entity as a named-regexp.\n\nExample:\n\nAn entity can check *words* ...\n\n```go\nwhat := prose.NewEntity(\"what\", prose.RegexpWords(\"what\"))\n```\n\n... it can also detect *topics* or *abstract concepts* ...\n```go\nsport := prose.NewEntity(\"sport\", prose.RegexpWords(\"football\", \"basketball\", \"hockey\"))\nlove := prose.NewEntity(\"love\", prose.RegexpWords(\"love\", \"romance\", \"wife\"))\n```\n\n... or even *character types*.\n```go\nnumber := prose.NewEntity(\"number\", \"[1-9]\")\n```\n\n\u003e All that you can track with regexps, you can track it with prose.\n\n## Action\n\nAn action is _an object containing a function_ that will be run in a particular context.\n\nExample :\n\nAn action can be a *shell command* ...\n\n```go\nai := prose.NewAI(\"Jarvis\", logrus.New())\naction := ai.NewCommandAction(\"echo 'Ran at $(date +%H:%M:%S)'\")\n```\n\n... or a *custom function* of your choice.\n\n```go\nai := prose.NewAI(\"Jarvis\", logrus.New())\n\nrun := func (a *prose.Action) error {\n\tai.Logger.Println(\"I'm an awesome func.\")\n\n\tio.WriteString(a.Writer, \"And I can also write to streams.\")\n}\n\naction := prose.NewAction(run)\n```\n\n## AI\n\nAn AI is an object containing the *executive part of the scheme*.\nIt will reference actions to run, and will process the input string from _(the user|an http request|a slack message|whatever)_\n\nThey are simply created by :\n\n```go\nai := prose.NewAI(\"Jarvis\", logrus.New())\n```\n\n# Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\tgotime \"time\"\n\n\t\"github.com/sirupsen/logrus\"\n\t\"github.com/snwfdhmp/prose\"\n)\n\nvar (\n\tlog = logrus.New()\n)\n\nfunc main() {\n\tai := prose.NewAI(\"Jarvis\", log) // We create an AI named Jarvis\n\n\t// Let's create an entity matching 'what'\n\twhat := prose.NewEntity(\"what\", prose.RegexpWords(\"what\"))\n\t// ...and another matching 'time'\n\ttime := prose.NewEntity(\"time\", prose.RegexpWords(\"time\"))\n\n\t// Now we create an action : writing time\n\tsendTime := prose.NewAction(func(a *prose.Action) error {\n\t\tmsg := fmt.Sprintf(\"It's %s\\n\", gotime.Now().Format(\"15:04\"))\n\t\ta.Write(msg)\n\t\treturn nil\n\t})\n\tsendTime.On(what, time) // it'll be run if 'what' and 'time' are in the tested strign\n\tai.Handle(sendTime)     // it'll be run by ai\n\n\tinput := \"Hey ! What time is it ?\" //Let's say that's our user input\n\n\tactions := ai.Process(input) // Our AI processes the input and decide which actions to run\n\n\t// Now we tell the AI to runs the actions, to output to w, and to stop at first error\n\terrs := ai.Run(actions, os.Stdout, true) // note that we receive a slice of errors\n\tif len(errs) \u003e 0 {\n\t\tlog.Errorln(\"Errors:\", errs)\n\t\treturn\n\t}\n}\n```\n\nLet's run the example above :\n\n```sh\n$ go run example.go\nIt's 01:53\n```\n\n# Author\n\nClick my awesome [GitHub profile](https://github.com/snwfdhmp), the 1000000th visitor will be offered a special gift.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnwfdhmp%2Fprose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnwfdhmp%2Fprose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnwfdhmp%2Fprose/lists"}