Git Product home page Git Product logo

chinesecharactersimilarity's Introduction

Chinese Character Similarity

A tool for calculating the similarity of two chars.

Key Idea

Tone Similarity:

  • PinYin edit distance

Shape Similarity:

  • Stroke counts difference
  • Sijiao Encoding edit distance
  • Character images differences ratio

CharSimilarity.similarity(ch1, ch2) Usage

Parameters:

  • tone:  - Flag for tone similarity computing. (default: True)
    • Type: Bool
  • shape:
    • Flag for shape similarity computing. (default: True)
    • Type: Bool
  • wpy:
    • Weight of PinYin similarity. (default: 0.4)
    • Type: Float
    • Range: 0.0 - 1.0
  • wst:
    • Weight of stroke count similarity. (default: 0.1)
    • Type: Float
    • Range: 0.0 - 1.0
  • wsj:
    • Weight of Sijiao encoding similarity. (default: 0.3)
    • Type: Float
    • Range: 0.0 - 1.0
  • wmatrix:
    • Weight of character image matrix similarity. (default: 0.2)
    • Type: Float
    • Range: 0.0 - 1.0
In [1]: import CharSimilarity

In [2]: ch1 = '侯'

In [3]: ch2 = '候'

In [4]: tone_similarity = CharSimilarity.similarity(ch1,ch2,tone=True,shape=False)

In [5]: print(tone_similarity)
1.0

In [6]: shape_similarity = CharSimilarity.similarity(ch1,ch2,tone=False,shape=True,wpy=0.0,wst=0.33,wsj=0.33,wmatrix=0.34)

In [7]: print(shape_similarity)
0.8253333333333334

In [8]: tone_shape_similarity = CharSimilarity.similarity(ch1,ch2,tone=True,shape=True,wpy=0.4,wst=0.1,wsj=0.3,wmatrix=0.2)

In [9]: print(tone_shape_similarity)
0.9066666666666667

References

chinesecharactersimilarity's People

Contributors

liu-hanwen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.