Giter Club home page Giter Club logo

jiebago's Introduction

#结巴分词 Go 语言版:Jiebago

Build Status GoDoc

结巴分词 是由 @fxsjy 使用 Python 编写的中文分词组件,Iiebago 是结巴分词的 Golang 语言实现。

安装

go get github.com/wangbin/jiebago/...

使用

package main

import (
        "fmt"

        "github.com/wangbin/jiebago"
)

var seg jiebago.Segmenter

func init() {
        seg.LoadDictionary("dict.txt")
}

func print(ch <-chan string) {
        for word := range ch {
                fmt.Printf(" %s /", word)
        }
        fmt.Println()
}

func Example() {
        fmt.Print("【全模式】:")
        print(seg.CutAll("我来到北京清华大学"))

        fmt.Print("【精确模式】:")
        print(seg.Cut("我来到北京清华大学", false))

        fmt.Print("【新词识别】:")
        print(seg.Cut("他来到了网易杭研大厦", true))

        fmt.Print("【搜索引擎模式】:")
        print(seg.CutForSearch("小明硕士毕业于**科学院计算所,后在日本京都大学深造", true))
}

输出结果:

【全模式】: 我 / 来到 / 北京 / 清华 / 清华大学 / 华大 / 大学 /

【精确模式】: 我 / 来到 / 北京 / 清华大学 /

【新词识别】: 他 / 来到 / 了 / 网易 / 杭研 / 大厦 /

【搜索引擎模式】: 小明 / 硕士 / 毕业 / 于 / ** / 科学 / 学院 / 科学院 / **科学院 / 计算 / 计算所 / , / 后 / 在 / 日本 / 京都 / 大学 / 日本京都大学 / 深造 /

更多信息请参考文档

分词速度

  • 2MB / Second in Full Mode
  • 700KB / Second in Default Mode
  • Test Env: AMD Phenom(tm) II X6 1055T CPU @ 2.8GHz; 《金庸全集》

许可证

MIT: http://wangbin.mit-license.org

jiebago's People

Contributors

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