Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8dbc66b27 | ||
|
|
08ed8866d0 | ||
|
|
620d0ef9de | ||
|
|
312d38ac6d | ||
|
|
4aec0e4e9a | ||
|
|
4f1002ee2d | ||
|
|
f291891139 | ||
|
|
230cefb85d | ||
|
|
84df8142c6 | ||
|
|
38e45c4f60 | ||
|
|
221f4e59e1 | ||
|
|
8ccafd5c0c | ||
|
|
59fcf3e2f0 | ||
|
|
59cc61105a | ||
|
|
ea438a7f40 |
BIN
NewLennon.png
Normal file
BIN
NewLennon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 228 KiB |
90
README.md
90
README.md
@@ -16,6 +16,8 @@ go get -u gitlab.com/bradley.richins/nmslib
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -32,12 +34,98 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Input:\t%s\nExpecting:\t042F:0079:0D55:006A\nHave:\t%s\n", portalcode, tstvar)
|
fmt.Printf("Input:\t%s\nExpecting:\t042F:0079:0D55:006A\nHave:\t%s\n", portalcode, tstvar)
|
||||||
|
|
||||||
nmslib.CreateBanner(portalcode, "NewLennon.png", 0)
|
nmslib.CreateBanner(portalcode, "NewLennon.png", 0)
|
||||||
|
|
||||||
fmt.Println(nmslib.Korvax2Eng("eapoluch"))
|
fmt.Println(nmslib.Korvax2Eng("eapoluch"))
|
||||||
fmt.Println(nmslib.Eng2Korvax("emergency"))
|
fmt.Println(nmslib.Eng2Korvax("emergency"))
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Creating a Glyph banner with CreateBanner()
|
||||||
|
|
||||||
|
This function takes 3 parameters:
|
||||||
|
|
||||||
|
* portalcode: 12 char hex string of portal location
|
||||||
|
* savename: Save location and name
|
||||||
|
* Horizontal/Vertical layout: 0 is horizontal, 1 is vertical
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
Horizontal Layout for Galactic Hub [HUB10-6A Icarus Sun](https://nomanssky.gamepedia.com/HUB10-6A_Icarus_Sun) Eniwa 68/L3
|
||||||
|
|
||||||
|
```golang
|
||||||
|
nmslib.CreateBanner("006afa556c30", "NewLennon.png", 0)
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Converting Portal code to Galactic address with P2gc()
|
||||||
|
|
||||||
|
This function only takes 1 parameter and returns a string
|
||||||
|
|
||||||
|
* portalcode: 12 char hex string of portal glyphs
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```golang
|
||||||
|
ga, _ := nmslib.P3gc("006afa556c30")
|
||||||
|
fmt.Println(ga)
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
``042F:0079:0D55:006A``
|
||||||
|
|
||||||
|
### Converting Galactic coordinates to Portal codes with Gc2p()
|
||||||
|
|
||||||
|
This function only takes 1 parameter and returns a string
|
||||||
|
|
||||||
|
* galacticaddress: 16 char 4 block hex address
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```golang
|
||||||
|
pc, _ := nmslib.P3gc("042F:0079:0D55:006A")
|
||||||
|
fmt.Println(pc)
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
``006AFA556C30``
|
||||||
|
|
||||||
|
### Translate Korvax to English with Korvax2Eng()
|
||||||
|
|
||||||
|
This function takes only 1 parameter and returns a string
|
||||||
|
|
||||||
|
* korvaxword: Any known Korvaxen word (ex. eapoluch)
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```golang
|
||||||
|
fmt.Println(Korvax2Eng("eapoluch"))
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
``emergency``
|
||||||
|
|
||||||
|
### Translate English to Korvax with Eng2Korvax()
|
||||||
|
|
||||||
|
This function takes only 1 parameter and returns a string
|
||||||
|
|
||||||
|
* engword: English word to attempt conversion
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```golang
|
||||||
|
fmt.Println(Eng2Korvax("emergency"))
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
``eapoluch``
|
||||||
|
|
||||||
## License
|
## License
|
||||||
[MIT](https://choosealicense.com/licenses/mit/)
|
[MIT](COPYING)
|
||||||
|
|||||||
17
convert.go
17
convert.go
@@ -70,22 +70,23 @@ func P2gc(p string) (gc string, err error) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Gc2p - Galactic coordinates to portal code
|
Gc2p - Galactic coordinates to portal code
|
||||||
Requires 1 string and returns a string and error
|
Requires 1 string and 1 int returns a string and error
|
||||||
var gc string
|
var gc string
|
||||||
Galactic address (ex. 042F:0079:0D55:006A)
|
Galactic address (ex. 042F:0079:0D55:006A)
|
||||||
|
var p int
|
||||||
|
Planet ID [1-6]
|
||||||
Return var string
|
Return var string
|
||||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||||
*/
|
*/
|
||||||
func Gc2p(gc string) (portalcode string, err error) {
|
func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*TODO: add option for Planet choice (1-6)*/
|
|
||||||
// split and store string
|
// split and store string
|
||||||
// coords[0] == X; coords[1] == Y coords[2] == Z;
|
// coords[0] == X; coords[1] == Y coords[2] == Z;
|
||||||
// coords[3] == SSI coords[4] == P
|
// coords[3] == SSI coords[4] == P
|
||||||
coords := strings.Split(gc+":1", ":")
|
if p > 6 {
|
||||||
|
p = 1
|
||||||
|
}
|
||||||
|
nustring := fmt.Sprintf("%s:%d", gc, p)
|
||||||
|
coords := strings.Split(nustring, ":")
|
||||||
for n := 0; n < len(coords); n++ {
|
for n := 0; n < len(coords); n++ {
|
||||||
portalcode = portalcode + coords[n]
|
portalcode = portalcode + coords[n]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/nfnt/resize"
|
||||||
|
|
||||||
gim "github.com/ozankasikci/go-image-merge"
|
gim "github.com/ozankasikci/go-image-merge"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,6 +26,16 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
|||||||
var err error
|
var err error
|
||||||
var GlyphHex [12]int64
|
var GlyphHex [12]int64
|
||||||
var glyphImg [12]string
|
var glyphImg [12]string
|
||||||
|
var vert int
|
||||||
|
var horz int
|
||||||
|
|
||||||
|
// Setup temp dir
|
||||||
|
tempdir, err := ioutil.TempDir("", "nmslib-")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tempdir)
|
||||||
|
|
||||||
// verify len of portalhex
|
// verify len of portalhex
|
||||||
if len(portalhex) == 12 {
|
if len(portalhex) == 12 {
|
||||||
// get hex value from each digit in given string to an array of int64
|
// get hex value from each digit in given string to an array of int64
|
||||||
@@ -35,7 +47,7 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
|||||||
}
|
}
|
||||||
// assign image location of its glyph hex value to an array of strings
|
// assign image location of its glyph hex value to an array of strings
|
||||||
for j := 0; j < len(glyphImg); j++ {
|
for j := 0; j < len(glyphImg); j++ {
|
||||||
glyphImg[j] = fmt.Sprintf("tmp.nmslib/glyphs/GLYPH-%X.png", GlyphHex[j])
|
glyphImg[j] = fmt.Sprintf("glyphs/GLYPH-%X.png", GlyphHex[j])
|
||||||
}
|
}
|
||||||
// pull images need from glyph.go and saved them to ./glyphs/
|
// pull images need from glyph.go and saved them to ./glyphs/
|
||||||
for k := 0; k < len(glyphImg); k++ {
|
for k := 0; k < len(glyphImg); k++ {
|
||||||
@@ -43,49 +55,47 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
_, err2 := os.Stat("tmp.nmslib/glyphs")
|
_, err2 := os.Stat(tempdir + "/glyphs/")
|
||||||
if os.IsNotExist(err2) {
|
if os.IsNotExist(err2) {
|
||||||
errDir := os.MkdirAll("tmp.nmslib/glyphs", 0755)
|
errDir := os.MkdirAll(tempdir+"/glyphs", 0755)
|
||||||
if errDir != nil {
|
if errDir != nil {
|
||||||
panic(errDir)
|
panic(errDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(glyphImg[k], []byte(data), 0644)
|
|
||||||
|
err = ioutil.WriteFile(tempdir+"/"+glyphImg[k], []byte(data), 0644)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// load images for processing using github.com/ozankasikci/go-image-merge
|
// load images for processing using github.com/ozankasikci/go-image-merge
|
||||||
grids := []*gim.Grid{
|
grids := []*gim.Grid{
|
||||||
{ImageFilePath: glyphImg[0]}, {ImageFilePath: glyphImg[1]},
|
{ImageFilePath: tempdir + "/" + glyphImg[0]}, {ImageFilePath: tempdir + "/" + glyphImg[1]},
|
||||||
{ImageFilePath: glyphImg[2]}, {ImageFilePath: glyphImg[3]},
|
{ImageFilePath: tempdir + "/" + glyphImg[2]}, {ImageFilePath: tempdir + "/" + glyphImg[3]},
|
||||||
{ImageFilePath: glyphImg[4]}, {ImageFilePath: glyphImg[5]},
|
{ImageFilePath: tempdir + "/" + glyphImg[4]}, {ImageFilePath: tempdir + "/" + glyphImg[5]},
|
||||||
{ImageFilePath: glyphImg[6]}, {ImageFilePath: glyphImg[7]},
|
{ImageFilePath: tempdir + "/" + glyphImg[6]}, {ImageFilePath: tempdir + "/" + glyphImg[7]},
|
||||||
{ImageFilePath: glyphImg[8]}, {ImageFilePath: glyphImg[9]},
|
{ImageFilePath: tempdir + "/" + glyphImg[8]}, {ImageFilePath: tempdir + "/" + glyphImg[9]},
|
||||||
{ImageFilePath: glyphImg[10]}, {ImageFilePath: glyphImg[11]},
|
{ImageFilePath: tempdir + "/" + glyphImg[10]}, {ImageFilePath: tempdir + "/" + glyphImg[11]},
|
||||||
}
|
}
|
||||||
if vopt == 1 {
|
|
||||||
// Merge images horizontally
|
if vopt == 1 { // set vertical rendering
|
||||||
rgba, err := gim.New(grids, 1, 12).Merge()
|
vert, horz = 1, 12
|
||||||
if err != nil {
|
} else { // set horizontal rendering (default)
|
||||||
panic(err)
|
vert, horz = 12, 1
|
||||||
}
|
}
|
||||||
// save the output to png
|
|
||||||
fmt.Printf("Saving %s to %s in vertical format\n", portalhex, savename)
|
// create new image from grids
|
||||||
file, err := os.Create(savename)
|
rgba, err := gim.New(grids, vert, horz).Merge()
|
||||||
err = png.Encode(file, rgba)
|
|
||||||
} else {
|
|
||||||
// Merge images vertically
|
|
||||||
rgba, err := gim.New(grids, 12, 1).Merge()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resize banner 768x64
|
||||||
|
nuimg := resize.Resize(768, 64, rgba, resize.Lanczos3)
|
||||||
|
|
||||||
// save the output to png
|
// save the output to png
|
||||||
fmt.Printf("Saving %s to %s\n", portalhex, savename)
|
fmt.Printf("Saving %s to %s\n", portalhex, savename)
|
||||||
file, err := os.Create(savename)
|
file, err := os.Create(savename)
|
||||||
err = png.Encode(file, rgba)
|
err = png.Encode(file, nuimg)
|
||||||
}
|
if err != nil {
|
||||||
// remove glyphs folder to keep it clean
|
fmt.Println(err)
|
||||||
errDir := os.RemoveAll("tmp.nmslib/glyphs")
|
|
||||||
if errDir != nil {
|
|
||||||
panic(errDir)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
go.mod
5
go.mod
@@ -2,4 +2,7 @@ module gitlab.com/bradley.richins/nmslib
|
|||||||
|
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require github.com/ozankasikci/go-image-merge v0.2.2
|
require (
|
||||||
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
|
github.com/ozankasikci/go-image-merge v0.2.2
|
||||||
|
)
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -1,2 +1,4 @@
|
|||||||
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||||
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||||
github.com/ozankasikci/go-image-merge v0.2.2 h1:K370BLLTIsamwjAeViiPntf7GiG3h9pXzDmxXCbN8/0=
|
github.com/ozankasikci/go-image-merge v0.2.2 h1:K370BLLTIsamwjAeViiPntf7GiG3h9pXzDmxXCbN8/0=
|
||||||
github.com/ozankasikci/go-image-merge v0.2.2/go.mod h1:NQ2aN0b21buFx3p+5x4dZrKuPSLh2uBukK7F30BrYTo=
|
github.com/ozankasikci/go-image-merge v0.2.2/go.mod h1:NQ2aN0b21buFx3p+5x4dZrKuPSLh2uBukK7F30BrYTo=
|
||||||
|
|||||||
140
lang.go
140
lang.go
@@ -8,72 +8,57 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
// translate - set up structure of a word iteration
|
||||||
Korvaxlang - set up structure of a word iteration
|
type translate struct {
|
||||||
*/
|
english string // english word
|
||||||
type Korvaxlang struct {
|
word string // no caps word
|
||||||
English string
|
capword string // Capitalized word
|
||||||
KorvaxWord string
|
acpword string // ALL CAPITALIZED WORD
|
||||||
KWCaps string
|
|
||||||
KWALLCAPS string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Korvax2Eng - convert known korvax words into english
|
Korvax2Eng - Translate a Korvax word to English
|
||||||
*/
|
*/
|
||||||
func Korvax2Eng(kvwrd string) string {
|
func Korvax2Eng(kvwrd string) string {
|
||||||
data, err := Asset("tmp.nmslib/korvax-lang.csv")
|
// create temp dir
|
||||||
|
tempdir, err := ioutil.TempDir("", "nmslib-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
_, err2 := os.Stat("tmp.nmslib/")
|
defer os.RemoveAll(tempdir) // Clean up temp files
|
||||||
if os.IsNotExist(err2) {
|
|
||||||
errDir := os.MkdirAll("tmp.nmslib/", 0755)
|
// extract language file from resources.go
|
||||||
if errDir != nil {
|
data, err := Asset("korvax-lang.csv")
|
||||||
panic(errDir)
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
// wirte extracted data to temp dir
|
||||||
err = ioutil.WriteFile("tmp.nmslib/korvax-lang.csv", []byte(data), 0644)
|
err = ioutil.WriteFile(tempdir+"/korvax-lang.csv", []byte(data), 0644)
|
||||||
csvFile, err := os.Open("tmp.nmslib/korvax-lang.csv")
|
csvFile, err := os.Open(tempdir + "/korvax-lang.csv")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
defer csvFile.Close()
|
defer csvFile.Close() // close language file when finished
|
||||||
CsvLines, err := csv.NewReader(csvFile).ReadAll()
|
csvlines, err := csv.NewReader(csvFile).ReadAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
for _, line := range CsvLines {
|
// loop through language data and assign to translate strut
|
||||||
klang := Korvaxlang{
|
for _, line := range csvlines {
|
||||||
English: line[0],
|
lang := translate{
|
||||||
KorvaxWord: line[1],
|
english: strings.ToLower(line[0]),
|
||||||
KWCaps: line[2],
|
word: strings.ToLower(line[1]),
|
||||||
KWALLCAPS: line[3],
|
capword: strings.ToLower(line[2]),
|
||||||
|
acpword: strings.ToLower(line[3]),
|
||||||
}
|
}
|
||||||
if kvwrd == klang.KorvaxWord {
|
// check translate struct for value
|
||||||
errDir := os.RemoveAll("tmp.nmslib")
|
if strings.ToLower(kvwrd) == lang.word {
|
||||||
if errDir != nil {
|
return lang.english
|
||||||
panic(errDir)
|
} else if strings.ToLower(kvwrd) == lang.capword {
|
||||||
|
return strings.Title(strings.ToLower(lang.english))
|
||||||
|
} else if strings.ToLower(kvwrd) == lang.acpword {
|
||||||
|
return strings.ToUpper(lang.english)
|
||||||
}
|
}
|
||||||
return klang.English
|
|
||||||
} else if kvwrd == klang.KWCaps {
|
|
||||||
errDir := os.RemoveAll("tmp.nmslib")
|
|
||||||
if errDir != nil {
|
|
||||||
panic(errDir)
|
|
||||||
}
|
|
||||||
return strings.Title(strings.ToLower(klang.English))
|
|
||||||
} else if kvwrd == klang.KWALLCAPS {
|
|
||||||
errDir := os.RemoveAll("tmp.nmslib")
|
|
||||||
if errDir != nil {
|
|
||||||
panic(errDir)
|
|
||||||
}
|
|
||||||
return strings.ToUpper(klang.English)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// remove recource folder to keep it clean
|
|
||||||
errDir := os.RemoveAll("tmp.nmslib")
|
|
||||||
if errDir != nil {
|
|
||||||
panic(errDir)
|
|
||||||
}
|
}
|
||||||
return "*\\Kzzzzzzt\\*" // word not found default
|
return "*\\Kzzzzzzt\\*" // word not found default
|
||||||
}
|
}
|
||||||
@@ -82,46 +67,49 @@ func Korvax2Eng(kvwrd string) string {
|
|||||||
Eng2Korvax - Convert (some) english words to Korvax
|
Eng2Korvax - Convert (some) english words to Korvax
|
||||||
*/
|
*/
|
||||||
func Eng2Korvax(enwrd string) string {
|
func Eng2Korvax(enwrd string) string {
|
||||||
data, err := Asset("tmp.nmslib/korvax-lang.csv")
|
// setup temp dir
|
||||||
|
tempdir, err := ioutil.TempDir("", "nmslib")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
_, err2 := os.Stat("tmp.nmslib/")
|
defer os.RemoveAll(tempdir) // clean up temp files
|
||||||
if os.IsNotExist(err2) {
|
|
||||||
errDir := os.MkdirAll("tmp.nmslib/", 0755)
|
data, err := Asset("korvax-lang.csv")
|
||||||
if errDir != nil {
|
if err != nil {
|
||||||
panic(errDir)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
err = ioutil.WriteFile(tempdir+"/korvax-lang.csv", []byte(data), 0644)
|
||||||
err = ioutil.WriteFile("tmp.nmslib/korvax-lang.csv", []byte(data), 0644)
|
csvFile, err := os.Open(tempdir + "/korvax-lang.csv")
|
||||||
csvFile, err := os.Open("tmp.nmslib/korvax-lang.csv")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
defer csvFile.Close()
|
csvlines, err := csv.NewReader(csvFile).ReadAll()
|
||||||
CsvLines, err := csv.NewReader(csvFile).ReadAll()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
for _, line := range CsvLines {
|
for _, line := range csvlines {
|
||||||
klang := Korvaxlang{
|
lang := translate{
|
||||||
English: line[0],
|
english: line[0],
|
||||||
KorvaxWord: line[1],
|
word: line[1],
|
||||||
KWCaps: line[2],
|
capword: line[2],
|
||||||
KWALLCAPS: line[3],
|
acpword: line[3],
|
||||||
}
|
}
|
||||||
if enwrd == klang.English {
|
if enwrd == lang.english {
|
||||||
errDir := os.RemoveAll("tmp.nmslib")
|
if lang.word != "" {
|
||||||
if errDir != nil {
|
return lang.word
|
||||||
panic(errDir)
|
|
||||||
}
|
|
||||||
return klang.KorvaxWord
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// remove recource folder to keep it clean
|
if enwrd == strings.Title(strings.ToLower(lang.english)) {
|
||||||
errDir := os.RemoveAll("tmp.nmslib")
|
if lang.capword != "" {
|
||||||
if errDir != nil {
|
return strings.Title(strings.ToLower(lang.capword))
|
||||||
panic(errDir)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if enwrd == strings.ToUpper(lang.english) {
|
||||||
|
if lang.acpword != "" {
|
||||||
|
return strings.ToUpper(lang.acpword)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
csvFile.Close()
|
||||||
return "*\\Kzzzzzzt\\*" // word not found default
|
return "*\\Kzzzzzzt\\*" // word not found default
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,20 @@ func TestPortal2Galactic(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("Testing P2gc(\"006afa556c30\"): got: %q, want: %q.\n", want, "042F:0079:0D55:006A")
|
fmt.Printf("Testing P2gc(\"006afa556c30\"): got: %q, want: %q.\n", want, "042F:0079:0D55:006A")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
want, err = P2gc("41EDF9554C2F")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if want != "042E:0078:0D53:01ED" {
|
||||||
|
t.Errorf("Testing P2gc(\"41EDF9554C2F\"): got %q, want: %q.\n", want, "042E:0078:0D53:01ED")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Testing P2gc(\"41EDF9554C2F\"): got: %q, want: %q.\n", want, "042E:0078:0D53:01ED")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGalactic2portal(t *testing.T) {
|
func TestGalactic2portal(t *testing.T) {
|
||||||
want, err := Gc2p("042F:0079:0D55:006A")
|
want, err := Gc2p("042F:0079:0D55:006A", 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -28,14 +38,14 @@ func TestGalactic2portal(t *testing.T) {
|
|||||||
fmt.Printf("Testing Gc2p(\"042F:0079:0D55:006A\"): got: %q, want: %q.\n", want, "106AFA556C30")
|
fmt.Printf("Testing Gc2p(\"042F:0079:0D55:006A\"): got: %q, want: %q.\n", want, "106AFA556C30")
|
||||||
}
|
}
|
||||||
|
|
||||||
want, err = Gc2p("044B:0081:0D68:0096")
|
want, err = Gc2p("042E:0078:0D53:01ED", 4)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if want != "109602569C4C" {
|
if want != "41EDF9554C2F" {
|
||||||
t.Errorf("Testing Gc2p(\"044B:0081:0D68:0096\"): got %q, want: %q.\n", want, "109602569C4C")
|
t.Errorf("Testing Gc2p(\"042E:0078:0D53:01ED\"): got %q, want: %q.\n", want, "41EDF9554C2F")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Testing Gc2p(\"044B:0081:0D68:0096\"): got: %q, want: %q.\n", want, "109602569C4C")
|
fmt.Printf("Testing Gc2p(\"042E:0078:0D53:01ED\"): got: %q, want: %q.\n", want, "41EDF9554C2F")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,11 +55,25 @@ func TestCreateBanner(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKorvax2Eng(t *testing.T) {
|
func TestKorvax2Eng(t *testing.T) {
|
||||||
want := Korvax2Eng("eapoluch")
|
want := Korvax2Eng("rodiashikhv")
|
||||||
if want != "emergency" {
|
if want != "contraband" {
|
||||||
t.Errorf("Testing Korvax2eng(\"eapoluch\"): got %q, want: %q.\n", want, "emergency")
|
t.Errorf("Testing Korvax2eng(\"rodiashikhv\"): got %q, want: %q.\n", want, "contraband")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Testing Korvax2eng(\"eapoluch\"): got %q, want: %q.\n", want, "emergency")
|
fmt.Printf("Testing Korvax2eng(\"rodiashikhv\"): got %q, want: %q.\n", want, "contraband")
|
||||||
|
}
|
||||||
|
|
||||||
|
want = Korvax2Eng("KIHTYOMOLES")
|
||||||
|
if want != "CONTRABAND" {
|
||||||
|
t.Errorf("Testing Korvax2eng(\"KIHTYOMOLES\"): got %q, want: %q.\n", want, "CONTRABAND")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Testing Korvax2eng(\"KIHTYOMOLES\"): got %q, want: %q.\n", want, "CONTRABAND")
|
||||||
|
}
|
||||||
|
|
||||||
|
want = Korvax2Eng("Zelidovoso")
|
||||||
|
if want != "Contraband" {
|
||||||
|
t.Errorf("Testing Korvax2eng(\"Zelidovoso\"): got %q, want: %q.\n", want, "Contraband")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Testing Korvax2eng(\"Zelidovoso\"): got %q, want: %q.\n", want, "Contraband")
|
||||||
}
|
}
|
||||||
|
|
||||||
want = Korvax2Eng("notaword")
|
want = Korvax2Eng("notaword")
|
||||||
@@ -61,11 +85,25 @@ func TestKorvax2Eng(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEng2Korvax(t *testing.T) {
|
func TestEng2Korvax(t *testing.T) {
|
||||||
want := Eng2Korvax("emergency")
|
want := Eng2Korvax("contraband")
|
||||||
if want != "eapoluch" {
|
if want != "rodiashikhv" {
|
||||||
t.Errorf("Testing Eng2Korvax(\"emergency\"): got %q, want: %q.\n", want, "eapoluch")
|
t.Errorf("Testing Eng2Korvax(\"contraband\"): got %q, want: %q.\n", want, "rodiashikhv")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Testing Eng2Korvax(\"emergency\"): got %q, want: %q.\n", want, "eapoluch")
|
fmt.Printf("Testing Eng2Korvax(\"contraband\"): got %q, want: %q.\n", want, "rodiashikhv")
|
||||||
|
}
|
||||||
|
|
||||||
|
want = Eng2Korvax("CONTRABAND")
|
||||||
|
if want != "KIHTYOMOLES" {
|
||||||
|
t.Errorf("Testing Eng2Korvax(\"CONTRABAND\"): got %q, want: %q.\n", want, "KIHTYOMOLES")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Testing Eng2Korvax(\"CONTRABAND\"): got %q, want: %q.\n", want, "KIHTYOMOLES")
|
||||||
|
}
|
||||||
|
|
||||||
|
want = Eng2Korvax("Contraband")
|
||||||
|
if want != "Zelidovoso" {
|
||||||
|
t.Errorf("Testing Eng2Korvax(\"Contraband\"): got %q, want: %q.\n", want, "Zelidovoso")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Testing Eng2Korvax(\"Contraband\"): got %q, want: %q.\n", want, "Zelidovoso")
|
||||||
}
|
}
|
||||||
|
|
||||||
want = Eng2Korvax("notaword")
|
want = Eng2Korvax("notaword")
|
||||||
@@ -74,5 +112,6 @@ func TestEng2Korvax(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("Testing Eng2Korvax(\"notaword\"): got %q, want: %q.\n", want, "*\\Kzzzzzzt\\*")
|
fmt.Printf("Testing Eng2Korvax(\"notaword\"): got %q, want: %q.\n", want, "*\\Kzzzzzzt\\*")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Testing: ")
|
fmt.Printf("Testing: ")
|
||||||
}
|
}
|
||||||
|
|||||||
342
resources.go
342
resources.go
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user