gocc

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

gocc - Golang version OpenCC

This is forked from https://github.com/liuzl/gocc.

Usage 使用

package main

import (
    "fmt"
    "log"
    
    "github.com/MontageApps/gocc"
)

func main() {
    s2t, err := gocc.New("s2t")
    if err != nil {
        log.Fatal(err)
    }
    in := `自然语言处理是人工智能领域中的一个重要方向。`
    out, err := s2t.Convert(in)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s\n%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

Overview

Package gocc is a golang port of OpenCC(Open Chinese Convert 開放中文轉換)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	Files []string
	Dicts []*da.Dict
}

Group holds a sequence of dicts

func (*Group) String

func (g *Group) String() string

type OpenCC

type OpenCC struct {
	Conversion  string
	Description string
	DictChains  []*Group
}

OpenCC contains the converter

func New

func New(conversion string) (*OpenCC, error)

New construct an instance of OpenCC.

Supported conversions: s2t, t2s, s2tw, tw2s, s2hk, hk2s, s2twp, tw2sp, t2tw, t2hk

func (*OpenCC) Convert

func (cc *OpenCC) Convert(in string) (string, error)

Convert string from Simplified Chinese to Traditional Chinese or vice versa

Directories

Path Synopsis
Package statik contains static assets.
Package statik contains static assets.

Jump to

Keyboard shortcuts

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