Giter Site home page Giter Site logo

segmenter.go第185行 about sego HOT 2 CLOSED

guotie avatar guotie commented on August 20, 2024
segmenter.go第185行

from sego.

Comments (2)

guotie avatar guotie commented on August 20, 2024

为什么Segment()函数没有设置searchMode的参数?

from sego.

huichen avatar huichen commented on August 20, 2024

你的第一个问题:

注释和代码是对应的,下面的代码创建了一个pos类型为x的伪分词
&Token{text: []Text{text[current]}, frequency: 1, distance: 32, pos: "x"}

第二个问题:

Segment()不需要searchMode参数,因为分词的细分本身就是已经存储在分词中的,见Token.segments

https://github.com/huichen/sego/blob/master/token.go#L26

segmentWords函数需要这个searchMode是因为true模式用在词典导入时的分词细分,而false模式用在切分文本时。之所以internalSegment有这个参数,完全是因为想在单元测试中测试segmentWords的两种模式,所以从Segment中重构出了internalSegment。

from sego.

Related Issues (20)

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.