Skip to main content

Python implementation of the Chinese soundex project DimSim

Project description

DimSim - A Chinese Soundex Library (Python version)

DimSim is a library developed by the Scalable Knowledge Intelligence team at IBM Almaden Research Center as part of the SystemT project.

The PyPi project page can be found here. It was created in collaboration with IBM Center for Open-Source Data and AI Technologies (CODAIT).

Overview

We provide a phonetic algorithm for indexing Chinese characters by sound. The technical details can be found in the following paper:

Min Li, Marina Danilevsky, Sara Noeman and Yunyao Li. DIMSIM: An Accurate Chinese Phonetic Similarity Algorithm based on Learned High Dimensional Encoding. CoNLL 2018.

In this library, we provide a pre-trained model that can perform the following functions:

  • Given two Chinese phrases (of the same length), return the phonetic distance of the input phrases. Optionally you can feed in pinyin strings of Chinese phrases too.
  • Given a Chinese phrase, return its top-k similar (phoentically) Chinese phrases.

How to install

Dependencies:

  • pypinyin: used for translating Chinese characters into their correponding pinyins.

There are two ways to install this library:

  • Install from PyPi
pip install dimsim
  • Download the source code by cloning this repo and compile it yourself.
git clone git@github.com:System-T/DimSim.git

cd DimSim/

pip install -e .

How to use

Once you have the package installed you can use it for the two functions as shown below.

  • Computing phonetic distance of two Chinese phrases. The optional argument pinyin (False by default) can be used to provide a pinyin string list directly. See example usage below.
import dimsim

dist = dimsim.get_distance("大侠","大虾")
0.0002380952380952381

dist = dimsim.get_distance("大侠","大人")
25.001417183349876

dist = dimsim.get_distance(['da4','xia2'],['da4','xia1']], pinyin=True)
0.0002380952380952381

dist = dimsim.get_distance(['da4','xia2'],['da4','ren2']], pinyin=True)
25.001417183349876

  • Return top-k phonetically similar phrases of a given Chinese phrase. Two parameters:
  • mode controls the character type of the returned Chinese phrases, where 'simplified' represents simplified Chinese and 'traditional' represents traditional Chinese.
  • theta controls the size of search space for the candidate phrases.
import dimsim

candidates = dimsim.get_candidates("大侠", mode="simplified", theta=1)
['打下', '大虾', '大侠']

candidates = dimsim.get_candidates("粉丝", mode="traditinoal", theta=1)
['門市', '分時', '焚屍', '粉飾', '粉絲']

Citation

Please cite the library by referencing the published paper:

@InProceedings{K18-1043,
  author = 	{Li, Min and Danilevsky, Marina and Noeman, Sara and Li, Yunyao},
  title = 	{{DIMSIM:} An Accurate Chinese Phonetic Similarity Algorithm Based on Learned High Dimensional Encoding},
  booktitle = 	{Proceedings of the 22nd Conference on Computational Natural Language Learning},
  year = 	{2018},
  publisher = 	{Association for Computational Linguistics},
  pages = 	{444-453},
  location = 	{Brussels, Belgium},
  url = 	{http://aclweb.org/anthology/K18-1043}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dimsim-0.2.2.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dimsim-0.2.2-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file dimsim-0.2.2.tar.gz.

File metadata

  • Download URL: dimsim-0.2.2.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for dimsim-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1b1b1df6efb989ccbb23f3d0a3788a0cd59de563c511e58fe057ddd9fc49d3be
MD5 a40d82191a0f87979b64759b54bba857
BLAKE2b-256 25ca9f0c5fa7eea40ef1f509d872a8e8a7c6b0144d3593913abad834db2415a6

See more details on using hashes here.

File details

Details for the file dimsim-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: dimsim-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for dimsim-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f2babc83c26bc2650207716cc98f06e8d2642c3c592fd320c7061ea5a7b9b54c
MD5 9ca40666ae5b8619bbe965b77a40cf18
BLAKE2b-256 b704f2245b7260ea8fa61400cd25149a90c3a55d691301b0826d408222b5bf3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page