{"id":15881314,"url":"https://github.com/kalloc/typod","last_synced_at":"2025-10-30T13:32:40.184Z","repository":{"id":136768374,"uuid":"47200482","full_name":"kalloc/typod","owner":"kalloc","description":"Spelling errors correction for the search engine (based on SphinxSearch) on your site.","archived":false,"fork":false,"pushed_at":"2020-11-11T15:48:15.000Z","size":26,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T15:12:49.856Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/kalloc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2015-12-01T16:02:25.000Z","updated_at":"2022-05-14T13:31:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"41054384-5bc9-4cff-ad49-044611f4a49c","html_url":"https://github.com/kalloc/typod","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalloc%2Ftypod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalloc%2Ftypod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalloc%2Ftypod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalloc%2Ftypod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kalloc","download_url":"https://codeload.github.com/kalloc/typod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234817669,"owners_count":18891450,"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":[],"created_at":"2024-10-06T03:41:11.584Z","updated_at":"2025-10-01T03:30:24.749Z","avatar_url":"https://github.com/kalloc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typod\nSpelling errors correction for the search engine (based on [sphinx]) on your site.\n\n## What is it?\n\nTypod is a missing spelling corrector for [sphinx], and it uses sphinx dictionary as source for spell checking.\nIt's based on original research and PoC that were written by [@iamdonefor]\n\n\n\n## What have we?\n\nWe have python classes for spell checking and a tcp interface to them\n\n\n## How to use it?\n\nYou can use typod in your python application:\n```\nfrom typo import TypoDefault\n\nTYPO = 'начь улеца фанарь аптека бесмысленый итусклый светт'.decode('utf8')\ncorrector = TypoDefault('examples/http/test.index')\ncorrected, ok = corrector.suggestion(TYPO)\nprint corrected\n\"\"\"\nночь улица фонарь аптека бессмысленный и тусклый свет\n\"\"\"\n```\nand you can use typod as service (TaaS)\n\nTCP Server:\n\n```\nx@y.z typod[master] $ python -m typo --corrector-index examples/http/test.index server --port 3333\nINFO:typo.cmd_server:Run server on 0.0.0.0:3333, using default corrector\n```\n\n\n```\nx@y.z typod[master] $ (echo QUERY начь улеца фанарь аптека бесмысленый итусклый светт;sleep 1) | nc localhost 3333\nночь улица фонарь аптека бессмысленный и тусклый свет\n```\nor\n\n```\nimport socket\n\ndef suggest(query):\n    sock = socket.socket()\n    sock.settimeout(0.1)\n    try:\n        sock.connect(('localhost', 3333))\n        sock.send('QUERY {}\\n'.format(query.encode('utf-8')))\n        data = sock.recv(4096).strip().decode('utf-8')\n    except socket.error as e:\n        # TODO: do something with connection error\n        print e\n        data = None\n    except socket.timeout:\n        data = None\n    finally:\n        sock.close()\n    return data if data != query else query\n    \nprint suggest('w0rd') # word\n```\n\n\nuWSGI server:\n\n```\nuwsgi --plugin corerouter,python,http --http=:9090   --module typo.wsgi --pyargv='--index=examples/http/test.index'\n```\n\n\nExample for POST request:\n```\nPOST / HTTP/1.1\nContent-Length: 96\nAccept-Encoding: gzip, deflate\nHost: localhost:9090\nAccept: application/json\nUser-Agent: HTTPie/0.9.2\nConnection: keep-alive\nContent-Type: application/json\n\nначь улеца фанарь аптека бесмысленый итусклый светт\n\n\nHTTP/1.1 200 OK\nContent-Type: text/plain; charset=UTF-8\n\nночь улица фонарь аптека бессмысленный и тусклый свет\n```\n\nand for GET request:\n```\nGET /?query=%D0%BD%D0%B0%D1%87%D1%8C%20%D1%83%D0%BB%D0%B5%D1%86%D0%B0%20%D1%84%D0%B0%D0%BD%D1%82%D0%B0%D0%BD%20%D0%B0%D0%BF%D1%82%D0%B5%D0%BA%D0%B0%20%D0%B1%D0%B5%D1%81%D0%BC%D1%8B%D1%81%D0%BB%D0%B5%D0%BD%D1%8B%D0%B9%20%D0%B8%20%D1%82%D1%83%D1%81%D0%BA%D0%BB%D0%B8%D0%B9%20%D1%81%D0%B2%D0%B5%D0%B4 HTTP/1.1\nConnection: keep-alive\nHost: localhost:9090\nAccept-Encoding: gzip, deflate\nAccept: */*\nUser-Agent: HTTPie/0.9.2\n\n\n\nHTTP/1.1 200 OK\nContent-Type: text/plain; charset=UTF-8\n\nночь улица фонарь аптека бессмысленный и тусклый свет\n\n```\n\n\n## How to make an index?\n\n```\n# Run indextool to dump a sphinx dictionary\nse@goat $ indextool --dumpdict texts_index  \u003e ~/dumpdict.txt\n\n# copy to your machine\nscp se@goat:~/dumpdict.txt .\n\n# Convert a sphinx dictionary to typo index\nx@y.z typod[master*] $ python -m typo --corrector-index typo.index convert --sphinx-dump dumpdict.txt\nConvert indextool format to \"TypoDefault\" corrector format\nConverting  [####################################]  100%\nExport result to /usr/home/x/src/typod/typo.index\n//EOE\n\n# Test\nx@y.z typod[master*] $ python -m typo --corrector-index typo.index console\nPhrase: w0rd\nResult is word (True) spend time 0.000121, 216.26 mb usage\nPhrase: ploy\nResult is play (True) spend time 0.000217, 216.27 mb usage\nPhrase: w0rld\nResult is world (True) spend time 0.000109, 216.27 mb usage\n```\n\n\n## Special thanks:\n- [sphinx]\n- [@iamdonefor]\n\n## TODO\n- support [n-gram]\n- support [noisy_channel]\n- support blocking-server\n- support custom dictionaries\n- add tests\n\n[sphinx]: http://sphinxsearch.com/  \"Sphinx Search\"\n[noisy_channel]: https://en.wikipedia.org/wiki/Noisy_channel_model \"Noisy channel model\"\n[n-gram]: https://en.wikipedia.org/wiki/N-gram \"N-gram\"\n[@iamdonefor]: https://github.com/iamdonefor/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalloc%2Ftypod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkalloc%2Ftypod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalloc%2Ftypod/lists"}