{"id":13366796,"url":"https://github.com/nuance/Go-nlp","last_synced_at":"2025-03-12T18:31:23.136Z","repository":{"id":57496888,"uuid":"1690313","full_name":"nuance/go-nlp","owner":"nuance","description":"Utilities for working with discrete probability distributions and other tools useful for doing NLP work","archived":true,"fork":false,"pushed_at":"2011-11-15T17:49:45.000Z","size":122,"stargazers_count":96,"open_issues_count":0,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-16T23:32:24.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/nuance.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}},"created_at":"2011-05-02T06:43:36.000Z","updated_at":"2024-09-22T06:26:00.000Z","dependencies_parsed_at":"2022-09-03T03:33:47.769Z","dependency_job_id":null,"html_url":"https://github.com/nuance/go-nlp","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/nuance%2Fgo-nlp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuance%2Fgo-nlp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuance%2Fgo-nlp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuance%2Fgo-nlp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuance","download_url":"https://codeload.github.com/nuance/go-nlp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243271290,"owners_count":20264431,"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-07-30T00:01:32.085Z","updated_at":"2025-03-12T18:31:22.860Z","avatar_url":"https://github.com/nuance.png","language":"Go","readme":"GNLP\n====\n\nA few structures for doing NLP analysis / experiments.\n\nBasics\n------\n\n* counter.Counter\n\nA map-like data structure for representing discrete probability\ndistributions. Contains an underlying map of event -\u003e probability\nalong with a probability for all other events. Supports some\nelement-wise mathematical operations with other counter.Counter\nobjects.\n\n```go\n// Create a counter with 0 probability for unknown events (and with \"\"\n// corresponding to the unknown event)\nballs := counter.New(0.0)\n\t\n// Add some observations\nballs.Incr(\"blue\")\nballs.Incr(\"blue\")\nballs.Incr(\"red\")\n\n// Normalize into a discrete distribution\nballs.Normalize()\n\n// blue =\u003e 0.666666\nballs.Get(\"blue\")\n\n// purple =\u003e 0.0\nballs.Get(\"purple\")\n\npreference = counter.New(0.0)\npreference.Set(\"red\", 2.0)\npreference.Set(\"blue\", 1.0)\npreference.Normalize()\n\nexpected_with_preference = counter.Multiply(balls, preference)\nexpected_with_preference.Normalize()\n\n// blue =\u003e 0.5\nexpected_with_preference.Get(\"blue\")\n// red =\u003e 0.5\nexpected_with_preference.Get(\"red\")\n\n// You can also use log probabilities\nballs.LogNormalize()\npreferences.LogNormalize()\n\n// And do in-place operations\nballs.Add(preferences)\n\n// Log-normalize expects counters with positive counts, so\n// exponentiate-then-normalize\nballs.Exp()\nballs.LogNormalize()\n\n// blue =\u003e -1 (== lg(0.5))\nballs.Get(\"blue\")\n```\n\n* frozencounter.Counter\n\nSimilar to counter.Counters, but with a fixed set of keys and no\ndefault value. Represented under the hood as an array of doubles (with\norder fixed according to the set of keys). Supports element-wise math\noperations with other frozencounter.Counters that share the same set\nof keys. Some mathematical operations are accelerated by the BLAS\nlibrary.\n\n```go\nfBalls := frozencounter.Freeze(balls)\nfPrefs := frozencounter.Freeze(preference)\n\nfExpectedWithPreference := frozencounter.Multiply(fBalls, fPrefs)\n```\n","funding_links":[],"categories":["自然语言处理","自然語言處理"],"sub_categories":["高级控制台界面","高級控制台界面"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuance%2FGo-nlp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuance%2FGo-nlp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuance%2FGo-nlp/lists"}