https://github.com/realign/pinyin-so
🀄️🔍 拼音搜索方案,支持 全拼/简拼/同音字 等。
https://github.com/realign/pinyin-so
chinese pinyin search so
Last synced: 7 months ago
JSON representation
🀄️🔍 拼音搜索方案,支持 全拼/简拼/同音字 等。
- Host: GitHub
- URL: https://github.com/realign/pinyin-so
- Owner: ReAlign
- Created: 2020-05-03T19:24:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-13T22:54:20.000Z (almost 6 years ago)
- Last Synced: 2025-02-17T15:03:29.035Z (over 1 year ago)
- Topics: chinese, pinyin, search, so
- Language: TypeScript
- Homepage: https://realign.github.io/pinyin-so/code/demo/build/
- Size: 795 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pinyin-so
⚠️⚠️⚠️ 目前为非稳定版本
[![NPM version][npm-image]][npm-url]
[npm-image]: https://img.shields.io/npm/v/pinyin-so.svg?longCache=true&style=for-the-badge
[npm-url]: https://www.npmjs.com/package/pinyin-so
> 拼音搜索方案,支持 全拼/简拼/同音字 等。

## Demo
> by some framework as:
* [svelte-js-app](https://realign.github.io/pinyin-so/code/demo-svelte/build)
* [react-ts-app](https://realign.github.io/pinyin-so/code/demo-ts-react/build)
* [vue-ts-app](https://realign.github.io/pinyin-so/code/demo-ts-vue/build)
## Usage
```js
import PinyinSo from 'pinyin-so';
/**
* @name PinyinSo.so
* @param {String} targetStr 待搜索文本
* @param {String} keyword 搜索关键词
* @returns {Boolean | Array} 失败结果 或者 结果索引
*/
const res = PinyinSo.so(`${targetStr}`, `${keyword}`);
if(res) {
const [start, end] = res;
} else {
console.log('No matching results.');
}
```
## 待办
* [ ] 优化代码
* [ ] 发新版
## 参考|感谢
* [xmflswood/pinyin-match](https://github.com/xmflswood/pinyin-match)