-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release version 1.0
- Loading branch information
Showing
37 changed files
with
824 additions
and
131,635 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 |
---|---|---|
|
@@ -121,4 +121,5 @@ nbproject | |
obj | ||
# build | ||
deps | ||
package-lock.json | ||
package-lock.json | ||
test.js |
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,3 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "4.4" | ||
- "4.4" | ||
|
||
install: | ||
- npm install --update-binary |
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,55 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const crfsuite = require('crfsuite'); | ||
const tokenizer = require('../tokenizer'); | ||
const pos_tag = require('../pos_tag'); | ||
const fe = require('../features'); | ||
|
||
const logger = require('../logger')('Chucking'); | ||
|
||
class Chucking { | ||
|
||
constructor() { | ||
this.tagger = crfsuite.Tagger(); | ||
this.logger = logger; | ||
|
||
this.model_filename = path.resolve(__dirname, './model.bin'); | ||
if (this.tagger.open(this.model_filename)) { | ||
logger.info(`open ${this.model_filename} success!`); | ||
} | ||
|
||
} | ||
|
||
get template() { | ||
return [ | ||
"T[-2].lower", "T[-1].lower", "T[0].lower", "T[1].lower", "T[2].lower", | ||
"T[0].istitle", "T[-1].istitle", "T[1].istitle", | ||
//# word unigram and bigram | ||
"T[-2]", "T[-1]", "T[0]", "T[1]", "T[2]", | ||
"T[-2,-1]", "T[-1,0]", "T[0,1]", "T[1,2]", | ||
//# pos unigram and bigram | ||
"T[-2][1]", "T[-1][1]", "T[0][1]", "T[1][1]", "T[2][1]", | ||
"T[-2,-1][1]", "T[-1,0][1]", "T[0,1][1]", "T[1,2][1]", | ||
//# chunk | ||
"T[-3][2]", "T[-2][2]", "T[-1][2]", | ||
]; | ||
} | ||
|
||
tag(text) { | ||
let pos_tags = pos_tag.tag(text); | ||
let tokens = pos_tags.map((tags) => { | ||
return [tags[0], tags[1], 'X'] | ||
}); | ||
|
||
let x = this.transform(tokens); | ||
let tags = this.tagger.tag(x); | ||
return pos_tags.map((pos_tags, index) => [pos_tags[0], pos_tags[1], tags[index]]); | ||
} | ||
|
||
transform(tokens) { | ||
let template = this.template; | ||
return tokens.map((token, i) => fe.word2features(tokens, i, template)); | ||
} | ||
} | ||
|
||
module.exports = new Chucking(); |
Binary file not shown.
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,2 @@ | ||
// Features Engineering (default) | ||
module.exports = require('./word_features'); |
Oops, something went wrong.