Package Exports
- dips.js
- dips.js/dist/main.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dips.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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.jsVia 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.