novel-segment-cli
cli & lazy version for novel-segment 修正常見簡轉繁時難以處理的字詞
Last updated 2 days ago by bluelovers .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install novel-segment-cli 
SYNC missed versions from official npm registry.

README

cli & lazy version for novel-segment 修正常見簡轉繁時難以處理的字詞

usage

npm install -g novel-segment-cli
npx novel-segment-cli --file input.txt --outDir output_dir
npx novel-segment-cli --glob *.txt --outDir output_dir

npx novel-segment-cli --help

file
  --file, -f    處理的檔案,可同時處理多個檔案                           [array]
  --glob, -g                                                             [array]
  --mapSeries   按照順序並且每次只處理一個檔案                         [boolean]
  --createDir   允許當目標資料夾不存在時自動建立                       [boolean]
  --outDir, -o  將處理後的結果儲存到目標資料夾                          [string]

text
  --text, -t  處理的文字,可搭配其他 cli 程式一起使用

Options:
  --overwrite                                                          [boolean]
  --useGlobalCache                                                     [boolean]
  --convertToZhTw   是否在轉換後轉為繁體                               [boolean]
  --crlf            轉換換行符號                                       [boolean]
  --version         Show version number                                [boolean]
  --help            Show help                                          [boolean]

install

yarn add novel-segment-cli
npm install novel-segment-cli

demo

API

demo.ts

import { textSegment, stringify, fileSegment, processText, processFile, ISegmentOptions } from 'novel-segment-cli';
import { console } from 'novel-segment-cli/lib/util';
import jsdiff = require('diff');

(async () =>
{
	let input = `

「这里是···什么地方?」
「好了,这样最后的班会结束了」
「喂,灰斗,接下来干什么?」

`;


	let ls = await textSegment(input);

	//console.dir(ls);

	console.gray(`------------------`);

	let out = stringify(ls);

	console.dir(out);

	console.log(diff_log(input, out));

	console.gray(`------------------`);

	let text = await processText(input);

	console.dir(text);

})();

function diff_log(src_text: string, new_text: string): string
{
	let diff = jsdiff.diffChars(src_text, new_text);

	let diff_arr = diff
		.reduce(function (a, part)
		{
			let color = part.added ? 'green' :
				part.removed ? 'red' : 'grey';

			let t = console[color].chalk(part.value);

			a.push(t);

			return a;
		}, [])
	;

	return diff_arr.join('');
}

image

「这裡是···什麼地方?」
「好了,这样最後的班会结束了」
「喂,灰斗,接下来幹什麼?」

Current Tags

  • 1.1.20                                ...           latest (2 days ago)

37 Versions

  • 1.1.20                                ...           2 days ago
  • 1.1.18                                ...           3 days ago
  • 1.1.17                                ...           4 days ago
  • 1.1.15                                ...           5 days ago
  • 1.1.14                                ...           5 days ago
  • 1.1.12                                ...           8 days ago
  • 1.1.11                                ...           13 days ago
  • 1.1.9                                ...           24 days ago
  • 1.1.8                                ...           a month ago
  • 1.1.7                                ...           a month ago
  • 1.1.6                                ...           a month ago
  • 1.1.5                                ...           a month ago
  • 1.1.1                                ...           5 months ago
  • 1.1.0                                ...           10 months ago
  • 1.0.24                                ...           10 months ago
  • 1.0.22                                ...           a year ago
  • 1.0.21                                ...           a year ago
  • 1.0.20                                ...           a year ago
  • 1.0.19                                ...           a year ago
  • 1.0.17                                ...           a year ago
  • 1.0.16                                ...           a year ago
  • 1.0.15                                ...           a year ago
  • 1.0.14                                ...           a year ago
  • 1.0.13                                ...           a year ago
  • 1.0.12                                ...           a year ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 50
This Month 50
Last Day 1
Last Week 11
Last Month 86
Dependencies (22)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |