dips.js

0.0.2 • Public • Published

dips.js

Multi-criteria Cantonese segmentation with dashes, intermediates, pipes, and spaces.

Note: This package is still in beta, there might be breaking changes in the future.

Install

npm install dips.js

Via CDN

<script type="module">
const { BertModel } = await import('https://unpkg.com/dips.js/dist/main.js');
</script>

Usage

>>> const { BertModel } = await import('dips.js');
>>> const model = await BertModel.init();

>>> await model.cut('阿張先生嗰時好nice㗎', mode='coarse')
['阿張先生', '嗰時', '好', 'nice', '㗎']

>>> await model.cut('阿張先生嗰時好nice㗎', mode='fine')
['阿', '張', '先生', '嗰', '時', '好', 'nice', '㗎']

>>> await model.cut('阿張先生嗰時好nice㗎', mode='dips_str')
'阿-張|先生 嗰-時 好 nice 㗎'

>>> await model.cut('阿張先生嗰時好nice㗎', mode='dips')
['S', 'D', 'P', 'I', 'S', 'D', 'S', 'S', 'I', 'I', 'I', 'S']

>>> model.free()

Note: BertModel.init() always returns the same model instance. Only free the model when you're done with all instances.

Package Sidebar

Install

npm i dips.js

Weekly Downloads

7

Version

0.0.2

License

MIT

Unpacked Size

5.32 MB

Total Files

4

Last publish

Collaborators

  • alienkevin