{ "info": { "author": "huyifeng", "author_email": "solopointer@qq.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Indexing", "Topic :: Utilities" ], "description": "Overview\n========\n\nA sample python lib to test gibberish, the model can give a score for a given string.\nThis score will be very low if this string is gibberish.\nIt uses a N character markov chain.\n[![Markov_chain]](http://en.wikipedia.org/wiki/Markov_chain)\n\nUsage\n=====\n```\nimport pygibberish\n#This demo show you how to train model & save model\nif __name_ == '__main__':\n gib = pygibberish.Gibberish(3) # 3 is the n of gram len. eg.ilovepython ->ilo,lov,loe...\n # You can find these train data in the root dir of package\n gib.train('pygibberish/train_data/en_big.txt') \n gib.save('en2.pki')\n print gib.calc(\"asdfasdf\")\n print gib.calc(\"apple\")\n\nor\n\n#This demo show you how to use a model file to calc the score\nimport pygibberish\nif __name_ == '__main__':\n gib = pygibberish.Gibberish('en2.pki')\n print gib.calc(\"asdfasdf\")\n```\n\nHow it works\n============\n*The markov chain first 'trains' or 'studies' a few MB of English/Chinese text, recording how often characters appear next to each other. Eg, given the text \"Rob likes hacking\" it sees Ro, ob, o[space], [space]l, ... It just counts these pairs. After it has finished reading through the training data, it normalizes the counts. Then each character has a probability distribution of 26 followup character following the given initial.\n\n*So then given a string, it measures the probability of generating that string according to the summary by just multiplying out the probabilities of the adjacent pairs of characters in that string. EG, for that \"Rob likes hacking\" string, it would compute prob['r']['o'] * prob['o']['b'] * prob['b']['l'] ... This probability then measures the amount of 'surprise' assigned to this string according the data the model observed when training. If there is funny business with the input string, it will pass through some pairs with very low counts in the training phase, and hence have low probability/high surprise.\n\n*I then look at the amount of surprise per character for a few known good strings, and a few known bad strings, and pick a threshold between the most surprising good string and the least surprising bad string. Then I use that threshold whenever to classify any new piece of text.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/solopointer/pygibberish", "keywords": "gibberish", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pygibberish", "package_url": "https://pypi.org/project/pygibberish/", "platform": "", "project_url": "https://pypi.org/project/pygibberish/", "project_urls": { "Homepage": "https://github.com/solopointer/pygibberish" }, "release_url": "https://pypi.org/project/pygibberish/0.0.9/", "requires_dist": null, "requires_python": "", "summary": "Gibberish train/test", "version": "0.0.9" }, "last_serial": 3976210, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "a4fb407c50096a02768f1b04921754bc", "sha256": "31125d56c065d08a4abb601395f3358bf0fbd9ae9fa69ca64b53dd436587836d" }, "downloads": -1, "filename": "pygibberish-0.0.2.tar.gz", "has_sig": false, "md5_digest": "a4fb407c50096a02768f1b04921754bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4459, "upload_time": "2018-06-13T09:13:28", "url": "https://files.pythonhosted.org/packages/d0/8d/1582aacffd7724baea07e0f347ef75d76d24fc27520916260d87808d4733/pygibberish-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "7ead4220a21fde1841636d2a4941bea0", "sha256": "5343cdcd25a6d8dde14a1e33146d37042c346a7b61df174e590ad0dcfb1b5b87" }, "downloads": -1, "filename": "pygibberish-0.0.3.tar.gz", "has_sig": false, "md5_digest": "7ead4220a21fde1841636d2a4941bea0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4477362, "upload_time": "2018-06-13T09:33:13", "url": "https://files.pythonhosted.org/packages/8a/18/2dd97233de905c1e374de595f4b93ad59334d166dcf8b4a1f3c141b66fae/pygibberish-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "8c97fb2167027809538a1b546f7366d9", "sha256": "91bec21e2bdfebde46c0ce1159a40d227bef3eef02c61db236c7dd5e14c1266d" }, "downloads": -1, "filename": "pygibberish-0.0.4.tar.gz", "has_sig": false, "md5_digest": "8c97fb2167027809538a1b546f7366d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4477365, "upload_time": "2018-06-13T09:47:42", "url": "https://files.pythonhosted.org/packages/29/c0/b54a2d06c388b404dfa3bec79cbf24c9ca28437b186367c95763b86f7cc2/pygibberish-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "9ea93150859ee3dd51270db987cd851d", "sha256": "0781589e7684fae0b94a4dbe46f4ed801f7c74449e552246476f1a9e57792b08" }, "downloads": -1, "filename": "pygibberish-0.0.5.tar.gz", "has_sig": false, "md5_digest": "9ea93150859ee3dd51270db987cd851d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4477363, "upload_time": "2018-06-13T09:49:40", "url": "https://files.pythonhosted.org/packages/f9/c4/a431ce2986d6d18cce1c27ccf090e3e340658c6cdedcfd1fd02efa498430/pygibberish-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "122c9e514184bb302bb1e992ada1e434", "sha256": "d03dde524d32a57b7ad4ba872f399a7e58a1cc3b1f6fe3125b9a32fe7107a95f" }, "downloads": -1, "filename": "pygibberish-0.0.6.tar.gz", "has_sig": false, "md5_digest": "122c9e514184bb302bb1e992ada1e434", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4476873, "upload_time": "2018-06-13T10:00:24", "url": "https://files.pythonhosted.org/packages/9d/7a/510613c337c8bd49fce71309fa1a456ce614c3fcf11268117d87957403a7/pygibberish-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "0c438ba1f6f4931abcd486c1935d916d", "sha256": "a28e186ccb1494b10cba9edd62eb6da773a0b21e5a482a5505dd1f0799738f18" }, "downloads": -1, "filename": "pygibberish-0.0.7.tar.gz", "has_sig": false, "md5_digest": "0c438ba1f6f4931abcd486c1935d916d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4477007, "upload_time": "2018-06-13T10:16:01", "url": "https://files.pythonhosted.org/packages/56/ea/541dae320d9a4752f626f53939920e97a6d84189443e1f4b3f79f08104ed/pygibberish-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "b0d542a08a7ecb2632ba6e3f65880610", "sha256": "1c2e2626be330ac53a60cbf85b122b10703e7cea146e84af19ad7c9cd8984c4f" }, "downloads": -1, "filename": "pygibberish-0.0.8.tar.gz", "has_sig": false, "md5_digest": "b0d542a08a7ecb2632ba6e3f65880610", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4479700, "upload_time": "2018-06-13T11:15:03", "url": "https://files.pythonhosted.org/packages/e4/06/578eed34306b9109b05c82938bda767cb5c4c2e718d5133e0842deb81468/pygibberish-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "4330c8c9e3686046850d39e6b84a5230", "sha256": "28c845d5e70e2996d08396e24815c9a799b2917de40cb316a16f058f2b7f0fc3" }, "downloads": -1, "filename": "pygibberish-0.0.9.tar.gz", "has_sig": false, "md5_digest": "4330c8c9e3686046850d39e6b84a5230", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4479728, "upload_time": "2018-06-19T06:07:57", "url": "https://files.pythonhosted.org/packages/fd/9d/d21dd6a12364f5b8fa1aac4c0ad1959a52fd7bca85fc0927aee581821169/pygibberish-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4330c8c9e3686046850d39e6b84a5230", "sha256": "28c845d5e70e2996d08396e24815c9a799b2917de40cb316a16f058f2b7f0fc3" }, "downloads": -1, "filename": "pygibberish-0.0.9.tar.gz", "has_sig": false, "md5_digest": "4330c8c9e3686046850d39e6b84a5230", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4479728, "upload_time": "2018-06-19T06:07:57", "url": "https://files.pythonhosted.org/packages/fd/9d/d21dd6a12364f5b8fa1aac4c0ad1959a52fd7bca85fc0927aee581821169/pygibberish-0.0.9.tar.gz" } ] }