Code Monkey home page Code Monkey logo

tyccl's Introduction

Tyccl

tyccl(同义词词林 哈工大扩展版) is a ruby gem that provides friendly functions to analyse similarity between Chinese Words.

all of Tyccl`s source files using charset: UTF-8
Finding algorithm using Tire and Hash, Time complexity O(m) m<=5, Space complexity O(n), n is proportional to the records of Cilin.
Cilin.txt(892.6KB).

Installation

Add this line to your application's Gemfile:

gem 'tyccl'  
gem 'algorithms'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tyccl  
$ gem install algorithms  

Usage

simple example:

  
  # Result_t = Struct.new(:value,:x_id,:y_id)
  # this struct is used to return analysing result
  # * field 'value' store the analysing value
  # * field 'x_id' 'y_id' store the ID of word X and Y 
	
  require 'tyccl'
 
  # Given wordA(string) and wordB(string). 
  # Returns a Struct Result_t which contains idA, idB, and shortest semantic distance(int) between wordA and wordB. 

  	result = Tyccl.dist("西红柿","黄瓜") 
	  	puts result.value
	  	puts result.x_id
	  	puts result.y_id

  # Given wordA(string) and wordB(string).
  # Returns a Struct Result_t which contains the most similar Pairs wordA`s ID and wordB`s ID, and similarity(float) between idA and idB.
  	result = Tyccl.sim("西红柿","黄瓜")
	  	puts result.value
	  	puts result.x_id
	  	puts result.y_id

  # Given a word(string) and a level(int),level`s value range is [0,4],4 is default, value of level is more bigger, the similarity between returned words and the given word is more less.   
  # Returns a two dimensional array that contains the parameter Word`s similar words which divided by different ID that the word matchs.
  # If the word has no similar, nil is returned.

	m = Tyccl.get_similar("人")  
	puts m
	#[	["人", "士", "人物", "人士", "人氏", "人选"],
 	#	["成年人", "壮年人", "大人", "人", "丁", "壮丁", "佬", "中年人"],
 	#	["身体", "人"],
 	#	["人格", "人品", "人头", "人", "品质", "质地", "格调", "灵魂", "为人"],
 	#	["人数", "人头", "人口", "人", "口", "丁", "家口", "食指", "总人口"]	]

download and see more methods in api doc and more examples in test.

Contributing

  1. Fork it ( http://github.com/JoeWoo/tyccl/fork )
  2. Create your feature branch (git checkout -b fork-new)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin fork-new)
  5. Create new Pull Request

tyccl's People

Contributors

joewoo avatar

Watchers

 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.