Skip to content

A jQuery plugin to do word segmentation in the browser using the browser's built-in word segmentation capabilities. (中文分词模块)

Notifications You must be signed in to change notification settings

psytau/browsergment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##BROWSER GMENTATION

This is a simple project that attempts to expose Chrome's natural language segmentation to JavaScript. It's particularly useful for languages like chinese that aren't easily parsed in to 'words'.

中文分词模块

Usage

This is a jQuery plugin.

To tokenize text in all 'p' tags on a page use...

var tokens = $('p').findTokens();
console.log(tokens);

To surround each token in a span so you can access them later...

<p> I like watermelon. </p>
<p> 我很喜歡西瓜。</p>

$('p').findAndSpanTokens();
// $('.word-watermelon').text() === 'watermelon';
// $('.word-西瓜').text() === '西瓜';

Example here: http://codepen.io/psytau/pen/sjJKl

Dev Setup

clone then...

npm install
karma run tests/karma.conf.js

to install karma and run tests

About

A jQuery plugin to do word segmentation in the browser using the browser's built-in word segmentation capabilities. (中文分词模块)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published