shing-dev / jp-dimension-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jp-dimension-parser

License Test codecov Go Report Card

jp-dimension-parser is a simple parser useful for parsing dimension of a thing from unstructured text.

Installation

$ go get -u github.com/k-yomo/jp-dimension-parser

Example

import (
    "fmt"
	
    "github.com/k-yomo/jp-dimension-parser/dimparser"
)

func main() {
    dimensions := dimparser.Parse("幅62cm×奥行73cm×高さ189cm")
    if dimensions != nil {
        fmt.Println("width(cm):", dimensions.Width.Centimeter())
        fmt.Println("depth(cm):", dimensions.Depth.Centimeter())
        fmt.Println("height(cm):", dimensions.Height.Centimeter())
        // => width(cm): 62 
        // => depth(cm): 73 
        // => height(cm): 189
    }
}

More parsable formats are listed in the test code.

About

License:Apache License 2.0


Languages

Language:Go 98.4%Language:Makefile 1.6%