1.0.1 • Published 11 months ago

@adpro/text-elementalizer-core v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

text-elementalizer-core

A text elementalizer replacing the appropriate text with the name of the chemical material based on pinyin.

基于汉语拼音,将文本中的中文字符替换为对应的化学物质名称。

基于汉语拼铟,将文苯中锝中文字氟锑换为对荧锝化学芴酯名称。

开始使用

npm install @adpro/text-elementalizer-core

本包完全使用TypeScript编写,遵循ES6规范,使用pnpm作为包管理器。

方法

convert

convert方法接受1-2个参数。

text - string - 待转换的文本

ignoreTones(可选) - boolean - 是否模糊音调。默认为false

convert方法返回1个string类型的值,值的内容为转换后的字符串

使用示例:

import { convert } from '@adpro/text-elementalizer-core';

const example1 = convert('示例'); // 不模糊音调
const example2 = convert('示例', false); // 不模糊音调
const example3 = convert('示例', true); // 模糊音调

常量

withTonesDict

withTonesDict是一个包含不模糊声调和对应化学用字的Map

其存储方式为:string类型的拼音:string[]类型的多个对应化学用字

导入方式:

import { withTonesDict } from '@adpro/text-elementalizer-core/dict';

withoutTonesDict

withoutTonesDict是一个包含模糊声调和对应化学用字的Map

其存储方式为:string类型的拼音:string[]类型的多个对应化学用字

导入方式:

import { withoutTonesDict } from '@adpro/text-elementalizer-core/dict';

excludeList

excludeList是一个string[]类型的包含不应被转换的特殊字符的数组。

导入方式:

import { excludeList } from '@adpro/text-elementalizer-core/dict';
1.0.1

11 months ago

1.0.0

11 months ago