-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8762829
commit 26631fa
Showing
6 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
var pinyinify = require("./src/pinyinify"), | ||
segment = require("./src/segment"), | ||
tag = require('./src/tag'), | ||
{ simplify, traditionalize } = require("./src/simplify"); | ||
let nodejieba = require("nodejieba"); | ||
|
||
|
||
module.exports = { | ||
pinyinify, | ||
segment, | ||
simplify, | ||
traditionalize, | ||
tag: nodejieba.tag | ||
tag | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
let nodejieba = require("nodejieba"), | ||
{ isCharacterText } = require("./util"); | ||
|
||
function tag(text) { | ||
let tokens = nodejieba.tag(text); | ||
let outTokens = []; | ||
for (let { word, tag } of tokens) { | ||
if (word.length > 1 && tag === "x") { | ||
for (let char of word) { | ||
outTokens.push(nodejieba.tag(char)[0]); | ||
} | ||
} | ||
else outTokens.push({ word, tag }); | ||
} | ||
return outTokens; | ||
} | ||
|
||
module.exports = tag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
isCharacterText: (text) => { | ||
// https://stackoverflow.com/questions/21109011/javascript-unicode-string-chinese-character-but-no-punctuation | ||
return /^([\u4E00-\u9FCC\u3400-\u4DB5\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\ud840-\ud868][\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|[\ud86a-\ud86c][\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d])+$/.test(String(text)); | ||
} | ||
} |