Git Product home page Git Product logo

tfidf's Introduction

TFIDF

Introduction

  • tokenizer support, contains english and jieba Chinese Tokenizer.
  • TFIDF, calculate tfidf value of giving document.
  • Cosine, calculate Cosine value of giving documents pair.
  • glide is used to manage go packages.

Guide

go get github.com/wilcosheh/tfidf
glide i
package main

import (
	"fmt"

	"github.com/wilcosheh/tfidf"
	"github.com/wilcosheh/tfidf/seg"
	"github.com/wilcosheh/tfidf/similarity"
)

func main() {

	f := tfidf.New()
	f.AddDocs("how are you", "are you fine", "how old are you", "are you ok", "i am ok", "i am file")

	t1 := "it is so cool"
	w1 := f.Cal(t1)
	fmt.Printf("weight of %s is %+v.\n", t1, w1)

	t2 := "you are so beautiful"
	w2 := f.Cal(t2)
	fmt.Printf("weight of %s is %+v.\n", t2, w2)

	sim := similarity.Cosine(w1, w2)
	fmt.Printf("cosine between %s and %s is %f .\n", t1, t2, sim)

	tokenizer := seg.NewJieba()
	defer tokenizer.Free()

	f = tfidf.NewTokenizer(tokenizer)

	f.AddDocs("重庆大学", "上海市复旦大学", "上海交通大学", "重庆理工大学")

	t1 = "重庆市西南大学"
	w1 = f.Cal(t1)
	fmt.Printf("weight of %s is %+v.\n", t1, w1)

	t2 = "重庆市重庆大学"
	w2 = f.Cal(t2)
	fmt.Printf("weight of %s is %+v.\n", t2, w2)

	sim = similarity.Cosine(w1, w2)
	fmt.Printf("cosine between %s and %s is %f .\n", t1, t2, sim)
}

tfidf's People

Contributors

wilcosheh avatar

Stargazers

H avatar Maxim Yurevich avatar  avatar Marcel Molina avatar Elliot Courant avatar Benn Huang avatar Jack avatar  avatar Derek Perkins avatar JrArkaan avatar Mahdi Karimi avatar Daisuke Mino avatar Toan Nhu avatar Connor Shorten avatar Tekin Tian avatar garycao avatar 07 avatar  avatar ForthXu avatar  avatar Samar Arora avatar Hans avatar Michal Dobrzynski avatar Chin allan avatar たふみ avatar William avatar Ybb avatar Pulkit Kathuria avatar  avatar Hebah avatar Vojtěch Mareš avatar  avatar Kenichi Ebinuma avatar Vadim Kulibaba avatar  avatar Ruben Diaz avatar Xu avatar

Watchers

James Cloos avatar  avatar

tfidf's Issues

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.