KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
go-khaiii
★ 23
Open GitHub ↗
No description available.
Download README (.md)
Explore Similar Repositories
packwerk-vscode
:
Packwerk extension for Visual Studio Code
sa-cli
:
No description available.
agent-plugins-grpc
:
Agent plugins' gRPC definitions
Options-Max-Pain-Calculator
:
A python command line tool to calculate options max pain for a given company symbol and options expiry date.
NeuralFRG
:
No description available.
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
go-khaiii
?
Download (.md)
# go-khaiii ## What is go-khaiii? [go-khaiii](https://github.com/AhaOfficial/go-khaiii) is [khaiii](https://github.com/kakao/khaiii) (Korean Morphological Analyzer) binding for Golang. ## Sample code - Create Model: - khaiii.Model.Create(rsc_dir string, opt_str string) - rsc_dir: a directory of dictionary resources (default: /usr/local/share/khaiii) - opt_str: options (JSON format) - Morphological Analysis: - khaiii.Model.ParseV1(line string) - (input e.g.) 나는 회사에 간다 - (output e.g.) [[나 NP] [는 JX] [회사 NNG] [에 JKB] [가 VV] [ㄴ다 EC]] - khaiii.Model.Parse(line string) - (input e.g.) 나는 회사에 간다 - (output e.g.) [{나 NP} {는 JX} {회사 NNG} {에 JKB} {가 VV} {ㄴ다 EC}] - khaiii.Model.Nouns(line string) - (input e.g.) 나는 백신접종을 하였다 - (output e.g.) [백신 접종] - khaiii.Model.NounsComposed(line string) - (input e.g.) 나는 백신접종을 하였다 - (output e.g.) [백신접종] - khaiii.Model.Analyze(line string) - (input e.g.) 나는 회사에 간다 - (output e.g.) [{나는 [{나 NP} {는 JX}]} {회사에 [{회사 NNG} {에 JKB}]} {간다 [{가 VV} {ㄴ다 EC}]}] - Destroy Model: - khaiii.Model.Destroy() ```go package main import ( "fmt" khaiii "github.com/AhaOfficial/go-khaiii" ) func main() { var model khaiii.Model err := model.Create("", "") // "": default if err != nil { fmt.Println("Create Error!") panic(err) } defer model.Destroy() var sentence string = "나는 회사에 간다" // ParseV1 resultParseV1, err := model.ParseV1(sentence) if err != nil { fmt.Println("Parsing Error!") panic(err) } fmt.Println(resultParseV1) // Parse resultParse, err := model.Parse(sentence) if err != nil { fmt.Println("Parsing Error!") panic(err) } for _, m := range resultParse { fmt.Printf("(%s/%s) ", m.Lex, m.Tag) } fmt.Println() // Nouns resultNouns, err := model.Nouns(sentence) if err != nil { fmt.Println("Parsing Error!") panic(err) } fmt.Println(resultNouns) // NounsComposed resultNouns, err := model.NounsComposed(sentence) if err != nil { fmt.Println("Parsing Error!") panic(err) } fmt.Println(resultNouns) // Analyze resultAnalyze, err := model.Analyze(sentence) if err != nil { fmt.Println("Parsing Error!") panic(err) } for _, r := range resultAnalyze { fmt.Printf("%s\t", r.Word) for _, m := range r.Morphs { fmt.Printf("(%s/%s) ", m.Lex, m.Tag) } fmt.Println() } } ``` # Install Before using [go-khaiii](https://github.com/AhaOfficial/go-khaiii), need to install [khaiii](https://github.com/kakao/khaiii). Here is how to install [go-khaiii](https://github.com/AhaOfficial/go-khaiii) with [khaiii](https://github.com/kakao/khaiii) depending on OS (MacOS, Ubuntu 20.04, and Amazon Linux). There are also dockerfiles with [go-khaiii](https://github.com/AhaOfficial/go-khaiii) installed ([Ubuntu 20.04](https://github.com/AhaOfficial/go-khaiii/blob/main/docker/ubuntu/Dockerfile) and [Amazon Linux](https://github.com/AhaOfficial/go-khaiii/blob/main/docker/amazonlinux/Dockerfile)). ### MacOS ```bash $ brew install git cmake go # Download go-khaiii $ git clone https://github.com/AhaOfficial/go-khaiii.git # Install khaiii $ cd go-khaiii $ sudo bash install_khaiii.sh # Export variables $ go get github.com/AhaOfficial/go-khaiii ``` ### Ubuntu 20.04 (Focal Fossa) ```bash $ sudo apt-get install -y git cmake golang-go language-pack-ko # Download go-khaiii $ git clone https://github.com/AhaOfficial/go-khaiii.git # Install khaiii $ cd go-khaiii $ sudo bash install_khaiii.sh # Export variables $ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" $ go get github.com/AhaOfficial/go-khaiii ``` ### Amazon Linux ```bash $ yum install -y git golang gcc-c++ wget tar make python3 cmake3 $ ln -sf /usr/bin/cmake3 /usr/bin/cmake # Download go-khaiii $ git clone https://github.com/AhaOfficial/go-khaiii.git # Install khaiii $ cd go-khaiii $ bash install_khaiii.sh # Export variables $ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" $ go get github.com/AhaOfficial/go-khaiii ```