chinese

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

opencc - Golang version OpenCC

Introduction 介紹

opencc is a golang port of OpenCC(Open Chinese Convert 開放中文轉換) which is a project for conversion between Traditional and Simplified Chinese developed by BYVoid.

opencc stands for "Golang version OpenCC", it is a total rewrite version of OpenCC in Go. It just borrows the dict files and config files of OpenCC, so it may not produce the same output with the original OpenCC.

Usage 使用

package main

import (
	"fmt"
	"log"
	"context"

	"gitee.com/go-hutool/hutool/hutool-core/text/translate/chinese"
)

func main() {
	chinese.Init()
	in := `请不要怀疑,这是一个由人工智能推荐的频道。`
	out, err := chinese.Convert(context.Background(),in)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s:%s\n", in, out)
}
// 请不要怀疑,这是一个由人工智能推荐的频道。
// 請不要懷疑,這是一個由人工智慧推薦的頻道。

Conversions

  • s2t Simplified Chinese to Traditional Chinese
  • t2s Traditional Chinese to Simplified Chinese
  • s2tw Simplified Chinese to Traditional Chinese (Taiwan Standard)
  • tw2s Traditional Chinese (Taiwan Standard) to Simplified Chinese
  • s2hk Simplified Chinese to Traditional Chinese (Hong Kong Standard)
  • hk2s Traditional Chinese (Hong Kong Standard) to Simplified Chinese
  • s2twp Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom
  • tw2sp Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom
  • t2tw Traditional Chinese (OpenCC Standard) to Taiwan Standard
  • t2hk Traditional Chinese (OpenCC Standard) to Hong Kong Standard

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(ctx context.Context, in string) (out string)

Convert string from Simplified Chinese to Traditional Chinese .

func Converts

func Converts(ctx context.Context, in ...string) (out map[string]string)

Converts .

func Init

func Init()

Init construct an instance of OpenCC.

Types

type Group

type Group struct {
	Files []string
	Dicts []*dict
}

Group holds a sequence of dicts

func (*Group) String

func (g *Group) String() string

Jump to

Keyboard shortcuts

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