{"id":21435534,"url":"https://github.com/mountain/nseg","last_synced_at":"2025-08-04T02:11:43.371Z","repository":{"id":2230522,"uuid":"3183422","full_name":"mountain/nseg","owner":"mountain","description":"Node.js Version of MMSG for Chinese Word Segmentation","archived":false,"fork":false,"pushed_at":"2012-01-28T13:04:12.000Z","size":5735,"stargazers_count":96,"open_issues_count":0,"forks_count":15,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-07-23T11:54:27.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/mountain.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":"2012-01-15T12:09:35.000Z","updated_at":"2023-11-03T17:09:29.000Z","dependencies_parsed_at":"2022-07-31T12:08:03.848Z","dependency_job_id":null,"html_url":"https://github.com/mountain/nseg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mountain/nseg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fnseg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fnseg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fnseg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fnseg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mountain","download_url":"https://codeload.github.com/mountain/nseg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fnseg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268639795,"owners_count":24282671,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-22T23:44:31.995Z","updated_at":"2025-08-04T02:11:43.332Z","avatar_url":"https://github.com/mountain.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Node.js Version of MMSG for Chinese Word Segmentation\n======================================================\n[![Build Status](https://secure.travis-ci.org/mountain/nseg.png)](http://travis-ci.org/mountain/nseg)\n\nMMSG originally invented by Chih-Hao Tsai is a very popular Chinese word\nsegmentation algorithm. Many implementations are available on different\nplatforms including Python, Java, etc.\n\nThis package provide Node.js version of MMSG algorithm. The API is async and evented sytle.\n\nSo far this package is still in developing, but the basic functionalities are ready.\n\nInstall\n=======\n\nUse nseg in your own package\n\n    $ npm install nseg\n\nOr if you want to use `nseg` command\n\n    $ npm install -g nseg\n\nCommand line\n============\n\nAfter intsalling globally, you can use `nseg` command to:\n\nhelp\n\n    $ nseg help\n\nsegment text using default dictionary\n\n    $ nseg segf -i ~/project/text/shi.txt -o ~/project/output/shi.txt\n    $ nseg segd -i ~/project/text -o ~/project/output\n\nbuild user dictionary for loading aftermath\n\n    $ nseg dict ~/project/data/dict.js ~/dict/dict1.txt ~/dict/dict2.txt\n    $ nseg dict ~/project/data/dict.js ~/dict\n\nbuild character-frequecy map for loading aftermath\n\n    $ nseg freq ~/project/data/freq.js ~/freq/data1.csv ~/freq/data2.csv\n    $ nseg freq ~/project/data/freq.js ~/freq\n\nsegment text using customized settings\n\n    $ nseg segd -d ~/project/data/dict.js -f ~/project/data/freq.js -i ~/project/text -o ~/project/output\n    $ nseg segd -l ~/project/lex/ -i ~/project/text -o ~/project/output\n\ncheck the existence of a word\n\n    $ nseg check \"石狮\"\n    $ nseg check -d ~/project/data/dict.js \"石狮\"\n\nUsing nseg in program\n======================\n\nPreparation\n-----------\n\n- (Optional) build your own dictionay and freqency map\n- (Optional) create your own lexical handler for special text pattern\n\nExamples\n--------\n\nStream-pipe style\n\n````javascript\nvar dict  = require('../data/dict'),\n    freq  = require('../data/freq'),\n    date  = require('../lex/datetime'),\n    sina  = require('../lex/sina');\n\nvar opts  = {\n        dict: dict,\n        freq: freq,\n        lexers: [date, sina],\n    };\n\nvar nseg = require('nseg').evented(opts);\n\nvar strmOut = fs.createWriteStream(target, {flags: 'w+', encoding: 'utf-8'}),\n    strmIn  = fs.createReadStream(input);\n\nvar pipe = nseg(strmIn, strmOut);\npipe.on('error', function (err) {\n    console.log('error', err);\n});\n\npipe.start();\n\n````\n\nNormal callback style (buggy)\n\n````javascript\nvar dict  = require('../data/dict'),\n    freq  = require('../data/freq'),\n    date  = require('../lex/datetime'),\n    sina  = require('../lex/sina');\n\nvar opts  = {\n        dict: dict,\n        freq: freq,\n        lexers: [date, sina],\n    };\n\nvar nseg = require('nseg').normal(opts);\n\nnseg('研究生源计划', function (result) {\n    console.log(result);\n});\n\n````\n\nLexical handler customization\n=============================\n\nLexical handlers support definitions by acceptor functions.\n\nAn acceptor function is a function with signature of\n\nfunction accept(curchar, undecidedprefix, nextchar)\n\nAnd return value should be one value from -1, 0, 1 on case of:\n\n* -1: we can decide a negitive result for the current character.\n* 0 : we should read more characters.\n* 1 : we can decide a negitive result for the current character.\n\nLicense\n=======\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountain%2Fnseg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmountain%2Fnseg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountain%2Fnseg/lists"}