Code Monkey home page Code Monkey logo

chinese-synonyms's Introduction

Chinese-Synonyms

Chinese Synonyms 中文同义词查询工具包 Chinese Synonyms for Natural Language Processing and Understanding.

cnsyn

"cnsyn":Python 中文同义词查询工具组件

"cnsyn" : Python Query tools for Chinese Synonyms.

GitHub: https://github.com/shangfr/Chinese-Synonyms

特点

  • 支持同义词查询
  • 支持自定义词典 > 已删除
  • Apache License 2.0 授权协议

在线演示:

安装说明

  • 全自动安装:pip install cnsyn
  • 半自动安装:先下载 https://pypi.python.org/pypi/cnsyn/ ,解压后运行 python setup.py install
  • 手动安装:将 cnsyn 目录放置于当前目录或者 site-packages 目录,通过 import cnsyn 来引用。

同义词库说明

  • 1、wiki:通过维基百科构建的一个中文同义词库-AitSimwords.txt;
  • 2、cndict:中文同义词字典-chinese_dictionary.txt;
  • 3、words_id_emb: 基于PaddleNLP开源语义模型 batch_neg_v1.0 进行Embedding语义表示抽取,获得每个词的词向量。合并wiki、cndict词库,共计129691个词;

查询原理

  • 基于词的传统召回 基于倒排索引,当用户输入查询词后,根据该词到倒排索引中进行查找该词的同义词。

  • 基于向量的语义召回 基于KNN-BallTree算法,找出某一个词向量最相近的词集合;(词>同义词向量>降维>语义索引(BallTree算法))

代码示例

# encoding=utf-8

import cnsyn

# 查询同义词(全部词库)
word = '垃圾'
cnsyn.search(word)
cnsyn.search(word,topK=3)
# 使用wiki词库
cnsyn.search(word, origin='wiki')
# 使用中文同义词字典库
cnsyn.search(word, origin='cndict')

# 基于向量的语义召回Approximate Nearest Neighbor Search 
cnsyn.anns(word)
cnsyn.anns(word,topK=3)

chinese-synonyms's People

Contributors

shangfr 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.