Giter Club home page Giter Club logo

kuromojist's Introduction

kuromojist

Calculate some costs ( like Mecab, %pw, %pc, %pC) from kuromoji.js (kuromojin)

Attention

This package use Unexposed API

  • Tokenizer.getLattice
  • lattice.nodes_end_at
  • Tokenizer.viterbi_searcher.search

Example

const { analyzeCosts } = require('kuromojist')

analyzeCosts('すもももももももものうち').then( result => {
  console.log(result)
})

This result

[
  { word_id: -1, surface_form: '', cost: 0, edge_cost: 0, shortest_cost: 0 },
  { word_id: 415760, surface_form: 'すもも', cost: 7546, edge_cost: -283, shortest_cost: 7263 },
  { word_id: 93220, surface_form: 'も', cost: 4669, edge_cost: -4158, shortest_cost: 7774 },
  { word_id: 1614710, surface_form: 'もも', cost: 7219, edge_cost: 17, shortest_cost: 15010 },
  { word_id: 93220, surface_form: 'も', cost: 4669, edge_cost: -4158, shortest_cost: 15521 },
  { word_id: 1614710, surface_form: 'もも', cost: 7219, edge_cost: 17, shortest_cost: 22757 },
  { word_id: 93100, surface_form: 'の', cost: 4816, edge_cost: -4442, shortest_cost: 23131 },
  { word_id: 62510, surface_form: 'うち', cost: 5796, edge_cost: -5198, shortest_cost: 23729 },
  { word_id: -1, surface_form: '', cost: 0, edge_cost: -2484, shortest_cost: 21245 }
]

Result Object

  • word_id
    • Same as kuromoji.tokenize
  • surface_form
    • Same as kuromoji.surface_form
  • cost
    • Word Cost
    • Mecab format: %pw
  • edge_cost
    • Lattice Edge Cost
    • Mecab format:%pC
  • shortest_cost
    • Minimum connection costs (accumulated)
    • Mecab format: %pc

kuromojist's People

Contributors

greenkeeperio-bot avatar

Watchers

 avatar  avatar

Forkers

kadeercanada

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.