pangu

package module
v3.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2016 License: MIT Imports: 7 Imported by: 20

README

pangu.go

Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).

Installation

To install the package, pangu, for using in your Go programs:

$ go get -u github.com/vinta/pangu

To install the command-line tool, pangu-axe:

$ go get -u github.com/vinta/pangu/pangu-axe

Usage

Package
package main

import (
    "fmt"
    "github.com/vinta/pangu"
)

func main() {
    s := pangu.SpacingText("新八的構造成分有95%是眼鏡、3%是水、2%是垃圾")
    fmt.Println(s)
    // Output:
    // 新八的構造成分有 95% 是眼鏡、3% 是水、2% 是垃圾
}
Command-line Interface
$ pangu-axe text "所以,請問Jackey的鼻子有幾個?3.14個"
所以, 請問 Jackey 的鼻子有幾個? 3.14 個

$ pangu-axe file 銀河便車指南.txt
$ pangu-axe file 宇宙盡頭的餐廳.txt -o 宇宙盡頭的餐廳(好讀版).txt
$ pangu-axe file 生命、宇宙及萬事萬物.txt 再見,謝謝你的魚.txt 基本無害.txt

Documentation

Have a question? Ask it on the GitHub issues!

Documentation

Overview

Package pangu provides paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).

These whitespaces between Chinese and English characters are called "Pangu's Space" by sinologist, since it separates the chaos between full-width and half-width characters. Studies showed that who dislike to add whitespace between English and Chinese characters also have relationship problem. Almost 70 percent of them will get married to the one they don't love, the rest only can left the heritage to their cat. Indeed, love and writing need some space in good time.

For more information about pangu, see

https://github.com/vinta/paranoid-auto-spacing

Index

Examples

Constants

View Source
const VERSION = "3.0.0"

Variables

This section is empty.

Functions

func SpacingFile

func SpacingFile(filename string, w io.Writer) (err error)

SpacingFile reads the file named by filename, performs paranoid text spacing on its contents and writes the processed content to w. A successful call returns err == nil.

Example
package main

import (
	"fmt"
	"github.com/vinta/pangu"
	"os"
)

func main() {
	input := "_fixtures/test_file.txt"
	output := "_fixtures/test_file.pangu.txt"

	fw, err := os.Create(output)
	if err != nil {
		fmt.Println(err)
	}
	defer fw.Close()

	pangu.SpacingFile(input, fw)
}
Output:

func SpacingText

func SpacingText(text string) string

SpacingText performs paranoid text spacing on text. It returns the processed text, with love.

Example
package main

import (
	"fmt"
	"github.com/vinta/pangu"
)

func main() {
	s := pangu.SpacingText("所以,請問Jackey的鼻子有幾個?3.14個!")
	fmt.Println(s)
}
Output:

所以, 請問 Jackey 的鼻子有幾個? 3.14 個!

Types

This section is empty.

Directories

Path Synopsis
pangu-axe (盤古斧) is a command-line interface for pangu.
pangu-axe (盤古斧) is a command-line interface for pangu.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL