Skip to content

Commit

Permalink
test: 人工檢查分詞系統產生的結果列表來了解為什麼沒有發生預期的轉換
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Jan 22, 2022
1 parent 4ad089f commit 5183324
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/segment-check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { async as FastGlob } from '@bluelovers/fast-glob/bluebird';
import { join } from 'upath2';
import { __root } from './__root';
import { outputJSON, readFile } from 'fs-extra';
import { initIdeaSegmentText } from '../lib/segment';

const cwd = join(__root, 'test', 'temp');

/**
* 人工檢查分詞系統產生的結果列表來了解為什麼沒有發生預期的轉換
*/
export default FastGlob<string>([
'*.txt',
], {
cwd,
})
.mapSeries(async (file) =>
{
const input = await readFile(join(cwd, file)).then(buf => buf.toString());

return initIdeaSegmentText()
.then(seg => seg.doSegment(input))
.then(result => outputJSON(join(cwd, file + '.json'), result, {
spaces: 2,
}))
;
})
;
Empty file added test/temp/.gitkeep
Empty file.

0 comments on commit 5183324

Please sign in to comment.