{"id":22054156,"url":"https://github.com/llimllib/segment","last_synced_at":"2025-05-12T03:08:07.458Z","repository":{"id":66393079,"uuid":"11706419","full_name":"llimllib/segment","owner":"llimllib","description":"A golang implementation of Norvig's segmenter","archived":false,"fork":false,"pushed_at":"2013-07-29T17:42:17.000Z","size":988,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T21:08:24.516Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/llimllib.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}},"created_at":"2013-07-27T14:59:37.000Z","updated_at":"2020-09-14T19:50:56.000Z","dependencies_parsed_at":"2023-02-20T04:00:39.149Z","dependency_job_id":null,"html_url":"https://github.com/llimllib/segment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llimllib%2Fsegment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llimllib%2Fsegment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llimllib%2Fsegment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llimllib%2Fsegment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llimllib","download_url":"https://codeload.github.com/llimllib/segment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253666090,"owners_count":21944621,"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-11-30T15:19:51.856Z","updated_at":"2025-05-12T03:08:07.439Z","avatar_url":"https://github.com/llimllib.png","language":"Go","readme":"A Go language implementation of the Norvig segmenter, given in [this pdf](http://norvig.com/ngrams/ch14.pdf).\n\nLicensed WTFPL; please use this code in any way you would like.\n\n### func MakeWordProb(reader io.Reader) func(string) float64\n\nMakeWordProb makes a word probability function from a reader.\n\nYou can create your own word probability function if you want, this just provides a default implementation. The word probability function should take any word as an argument and return a float64 0 \u0026lt;= x \u0026lt;= 1\n\n### func Segment(text string, wordprob func(string) float64) []string\n\nSegment a string. Return the highest-scoring segmentation of that string given the word probability function wordprob.\n\n# Example\n\n```go\npackage main\n\nimport (\n\t\"segment\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc getFile(filename string) *os.File {\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\tfmt.Println(\"Unable to read file\", filename)\n\t\tos.Exit(1)\n\t}\n\n\treturn f\n}\n\nfunc main() {\n\twordp := segment.MakeWordProb(getFile(\"mobydick.txt\"))\n\tfmt.Println(segment.Segment(\"thereareshortpeopleeverywhere\", wordp))\n\t// Output:\n\t// [there are short people everywhere]\n}\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllimllib%2Fsegment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllimllib%2Fsegment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllimllib%2Fsegment/lists"}