{"id":13656661,"url":"https://github.com/chanind/cn-grammar-matcher","last_synced_at":"2025-04-14T11:31:26.451Z","repository":{"id":54171076,"uuid":"93301514","full_name":"chanind/cn-grammar-matcher","owner":"chanind","description":"A tool to find grammar patterns in Chinese text","archived":false,"fork":false,"pushed_at":"2019-12-06T08:15:31.000Z","size":9163,"stargazers_count":27,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T00:44:06.681Z","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/chanind.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":"2017-06-04T08:54:06.000Z","updated_at":"2025-03-18T19:27:11.000Z","dependencies_parsed_at":"2022-08-13T08:11:07.274Z","dependency_job_id":null,"html_url":"https://github.com/chanind/cn-grammar-matcher","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/chanind%2Fcn-grammar-matcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanind%2Fcn-grammar-matcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanind%2Fcn-grammar-matcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanind%2Fcn-grammar-matcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanind","download_url":"https://codeload.github.com/chanind/cn-grammar-matcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248871806,"owners_count":21175295,"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-08-02T05:00:29.307Z","updated_at":"2025-04-14T11:31:26.384Z","avatar_url":"https://github.com/chanind.png","language":"JavaScript","funding_links":[],"categories":["Libraries/Packages"],"sub_categories":["Javascript"],"readme":"![Build status](https://circleci.com/gh/chanind/cn-grammar-matcher/tree/master.svg?style=shield\u0026circle-token=91c14be1d2232021ab3d7ee3908315a8456d9859)\n\n# cn-grammar-matcher\nA tool to find grammar patterns in Chinese text.\n\n\n## Installation\n\nInstallation is easiest via NPM: `npm install cn-grammar-matcher`\n\nFor most uses of Chinese Grammar Matcher that should be all you need to do!\n\n## Basic usage\nThis library takes a string of chinese text as an input and analyzes it to find which Chinese grammar\npatterns are present. Usage looks like the following:\n\n```javascript\nconst GrammarMatcher = require('cn-grammar-matcher');\nconst matcher = new GrammarMatcher();\nmatcher.matchGrammar('中文太难了').then((results) =\u003e {\n    // do something exciting with the results!\n});\n```\n\nFor the above example, results for `'中文太难了'` should look something like the following:\n\n```javascript\n/* results for '中文太难了' */\n[{\n    // all grammar patterns found in this sentence\n    grammar: [{\n        id: \"expressingExcessivelyWithTai\",\n        structures: [\n            \"太 + Adj. + 了\"\n        ],\n        description: \" ... \", // A description of this grammar pattern\n        // more examples of this grammar pattern\n        examples: [\n            {\n                zh: \"你太好了。\",\n                en: \"You are so great.\",\n                src: {\n                    type: \"website\",\n                    url: \"https://resources.allsetlearning.com/chinese/grammar/ASG8HVFN\",\n                    name: \"AllSet Chinese Grammar Wiki\"\n                }\n            },\n            ...\n        ],\n        // More info on this grammar pattern\n        sources: [\n            {\n                type: \"website\",\n                url: \"https://resources.allsetlearning.com/chinese/grammar/ASG8HVFN\",\n                name: \"AllSet Chinese Grammar Wiki\"\n            }\n        ],\n        // where in the sentence this grammar pattern was found\n        // You can use this to highlight words in the sentence\n        matches: [\n            [\n                { start: 2, end: 3 },\n                { start: 4, end: 5 }\n            ]\n        ]\n    }],\n    text: \"中文太难了\",\n    tokens: [/* raw tokenization from Stanford Core NLP */]\n}]\n```\n\nMost of the patterns this library can detect come from the [Allset Chinese Grammar Wiki](https://resources.allsetlearning.com/chinese/grammar). This library uses the Stanford CoreNLP server for Chinese.\nBy default the library will use a copy of the CoreNLP server hosted at https://core-nlp.cn-grammar-matcher.com, but\nif you expect to have a lot of traffic it's best to run a copy of the server yourself.\n\n# Contributing to Chinese Grammar Matcher\nIf you would like to help improve Chinese Grammar Matcher there's a number of ways that you can help! If\nyou find any bugs with the patterns being detected please [Open an Issue](https://github.com/chanind/cn-grammar-matcher/issues/new) in this repo. Don't be shy!\n\nIf you can code and want to add more grammar patterns or improve existing patterns, great! Pull requests\nare always welcome and encouraged! If you have any questions or problems [Open an Issue](https://github.com/chanind/cn-grammar-matcher/issues/new) here.\n\n## Running Chinese Grammar Matcher for development\nIf you want to contribute code to this repo you'll need to get the repo and tests running first. After you\nclone this repo, run `yarn install` to get everything set up. \n\nThis project requires the Stanford CoreNLP server to be running with Chinese enabled. The easiest way to do this is to use a pre-built docker image. The following command will bring up an Stanford CoreNLP server on port 9000 of your local computer: `docker run -p 9000:9000 --memory=4g skywidesoft/corenlp-chinese:3.7.0`\n\nOnce you have a Stanford CoreNLP server running locally, you can run tests with `yarn test`. If all tests pass you should be good to go! It might take 2 tries to get the tests to pass after starting the Core NLP server since it takes a few minutes to load everything the first run.\n\n## Adding/editing grammar patterns\nYou can scaffold a new grammar pattern by running `yarn gen-pattern \u003cpattern-name\u003e`. This will add a shell of\na grammar pattern and a test to `src/patterns`. If you fix a bug or improve an existing grammar pattern make sure to update the corresponding test case for the patten too!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanind%2Fcn-grammar-matcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanind%2Fcn-grammar-matcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanind%2Fcn-grammar-matcher/lists"}