Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3588826556 | ||
|
|
98d812c904 | ||
|
|
86bc493ead | ||
|
|
3cfae880ee | ||
|
|
b41f25646d | ||
|
|
94f9b4e15c | ||
|
|
6d3a57d31c | ||
|
|
ab420a0a44 | ||
|
|
a0d9dbd269 | ||
|
|
60de0ebb46 | ||
|
|
a370e0f33d | ||
|
|
5faa96d8a7 | ||
|
|
c8f6d51ba1 | ||
|
|
2397ec9aee | ||
|
|
21360acadf | ||
|
|
4aded9c17f | ||
|
|
8945530dbf | ||
|
|
73fa913292 | ||
|
|
47db5b0767 | ||
|
|
4aef1e390a | ||
|
|
284313eacc | ||
|
|
faf72d1f7a | ||
|
|
7c5d4b5ce8 | ||
|
|
ad42c6bb04 | ||
|
|
5ca88596ff | ||
|
|
53d85d958b | ||
|
|
ea51873fe3 | ||
|
|
90d743286f | ||
|
|
bc0c364dcc | ||
|
|
43496932ef | ||
|
|
d6bfa643a9 | ||
|
|
877517b923 | ||
|
|
ccbd68aee8 | ||
|
|
5077876106 | ||
|
|
9682494ce1 | ||
|
|
87bec565f1 | ||
|
|
a7069dce7e | ||
|
|
bc4e334ecd | ||
|
|
9358727075 | ||
|
|
3449ae3bf3 | ||
|
|
023eab03b2 | ||
|
|
5f4414df03 | ||
|
|
57a1d729dd | ||
|
|
67db2e32ef | ||
|
|
2bb7ca6ccd | ||
|
|
2610d98ae1 | ||
|
|
32d533ff61 | ||
|
|
ac68a20697 | ||
|
|
0b90141dcd | ||
|
|
5bc5711f09 | ||
|
|
00411f015c | ||
|
|
ab9799b273 | ||
|
|
d8dbc66b27 | ||
|
|
08ed8866d0 | ||
|
|
620d0ef9de | ||
|
|
312d38ac6d | ||
|
|
4aec0e4e9a | ||
|
|
4f1002ee2d | ||
|
|
f291891139 | ||
|
|
230cefb85d | ||
|
|
84df8142c6 | ||
|
|
38e45c4f60 | ||
|
|
221f4e59e1 | ||
|
|
8ccafd5c0c | ||
|
|
59fcf3e2f0 | ||
|
|
59cc61105a | ||
|
|
ea438a7f40 | ||
|
|
1cb2bac407 | ||
|
|
5d2da18255 | ||
|
|
76fb306965 | ||
|
|
897327dc50 | ||
|
|
35bb9977cc |
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
assets/
|
||||
.vscode/
|
||||
notes.txt
|
||||
Test.png
|
||||
test.png
|
||||
11
.gitlab-ci.yml
Normal file
11
.gitlab-ci.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
stages:
|
||||
- test
|
||||
|
||||
test:
|
||||
stage: test
|
||||
image: golang:1.16.3
|
||||
script:
|
||||
- go test
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
BIN
NMH-BlueDream.png
Normal file
BIN
NMH-BlueDream.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 307 KiB |
232
README.md
Normal file
232
README.md
Normal file
@@ -0,0 +1,232 @@
|
||||
# NMSlib
|
||||
|
||||
[](COPYING)
|
||||
[](https://godoc.org/gitlab.com/Raum0x2A/nmslib)
|
||||
[](https://gitlab.com/Raum0x2A/nmslib)
|
||||
[](https://gitlab.com/Raum0x2A/nmslib/-/tree/develop)
|
||||
[](https://gitlab.com/Raum0x2A/nmslib/-/releases/v1.0.1)
|
||||
|
||||
NMSlib is a GoLang package for dealing with converting Galactic coordinates to Portal codes and vice versa.
|
||||
|
||||
NMSlib also translates in game languages (Korvax, Gek Vy'Keen and Atlas) to english, and create portal banners.
|
||||
|
||||
## Installation
|
||||
|
||||
To install this module use `go get`
|
||||
|
||||
|
||||
```golang
|
||||
go get -u gitlab.com/Raum0x2A/nmslib
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Example:
|
||||
|
||||
```golang
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitlab.com/Raum0x2A/nmslib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
portalcode := "21F2F8EDB94D"
|
||||
galacticCoords, err := nmslib.P2gc(portalcode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("Input:\t%s\nOutput:\t%s\n", portalcode, galacticCoords)
|
||||
|
||||
g2p, err := nmslib.Gc2p("014C:0077:06DA:01F2", 2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("Input:\t014C:0077:06DA:01F2\nOutput:\t%s\n", g2p)
|
||||
|
||||
_ := nmslib.CreateBanner(portalcode, "./NMH-BlueDream.png", 0)
|
||||
_ := nmslib.CreateBanner(nmslib.RndPortal(), "./Random.png", 0)
|
||||
|
||||
fmt.Println(nmslib.Translate{Lang: "korvax"}.ToEng("KIHTYOMOLES"))
|
||||
korvax := nmslib.Translate{"english"}
|
||||
fmt.Println(korvax.ToKorvax("Contraband"))
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Creating a Glyph banner
|
||||
|
||||
This function takes 3 parameters and reurns an error
|
||||
|
||||
* portalcode: 12 char hex string of portal location
|
||||
* savename: Save location and name
|
||||
* layout:
|
||||
* 00 or 0 is horizontal in light mode
|
||||
* 01 or 1 is horizontal in dark mode
|
||||
* 11 is vertical in dark mode
|
||||
* 10 is vertical in light mode
|
||||
|
||||
|
||||
**Example:**
|
||||
|
||||
Horizontal Layout for the NMH Capital planet [Blue Dream (aka Omins XI)](https://nomanssky.fandom.com/wiki/Omins_XI) in the [Notric-Lis XIII](https://nomanssky.fandom.com/wiki/Notric-Lis_XIII) system in the [Lahanhar Conflux](https://nomanssky.fandom.com/wiki/Lahanhar_Conflux) region
|
||||
|
||||
```golang
|
||||
err := nmslib.CreateBanner("21F2F8EDB94D", "NMH-BlueDream.png", 0)
|
||||
if err !=nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
Vertical layout for a random address
|
||||
|
||||
```golang
|
||||
err := nmslib.CreateBanner(nmslib.RndPortal(), "ranportal.png", 11)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
_Note: Image shown in readme.md's vertical example have been scaled down in gimp for easier viewing on gitlab._
|
||||
|
||||
_Original ranportal.png: 256x3072px_
|
||||
|
||||
|
||||
### Converting Portal code to Galactic address
|
||||
|
||||
This function only takes 1 parameter and returns a string and error
|
||||
|
||||
* portalcode: 12 char hex string of portal glyphs
|
||||
|
||||
**Example:**
|
||||
|
||||
```golang
|
||||
ga, _ := nmslib.P2gc("21F2F8EDB94D")
|
||||
fmt.Println(ga)
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
``014C:0077:06DA:01F2``
|
||||
|
||||
### Converting Galactic coordinates to Portal codes
|
||||
|
||||
This function only takes 2 parameters and returns a string and error
|
||||
|
||||
* galacticaddress: 16 char 4 block hex address
|
||||
* Planet ID [1-6]
|
||||
|
||||
**Example:**
|
||||
|
||||
```golang
|
||||
pc, _ := nmslib.Gc2p("014C:0077:06DA:01F2", 2)
|
||||
fmt.Println(pc)
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
``21F2F8EDB94D``
|
||||
|
||||
## Translate Words
|
||||
|
||||
Supported languages
|
||||
|
||||
- Korvax
|
||||
- Gek
|
||||
- Vy'keen
|
||||
- Atlas
|
||||
|
||||
### Translate Atlas to English
|
||||
|
||||
This function takes only 1 parameter and returns a string
|
||||
|
||||
* Word: Any known Atlas word (ex. Paka)
|
||||
|
||||
_note: Translating to english will **always** result in the lowercase equivilent word_
|
||||
|
||||
**Example:**
|
||||
|
||||
```golang
|
||||
fmt.Println(nmslib.Translate{Lang: "atlas"}.ToEng("Paka"))
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
``awake``
|
||||
|
||||
### Translate English to Korvax
|
||||
|
||||
This function takes only 1 parameter and returns a string
|
||||
|
||||
* engword: English word to attempt conversion
|
||||
|
||||
**Example:**
|
||||
|
||||
```golang
|
||||
korvax := nmslib.Translate{"english"}
|
||||
fmt.Println(korvax.ToKorvax("Contraband"))
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
``Zelidovoso``
|
||||
|
||||
|
||||
### Language commands
|
||||
|
||||
- ``Translate{Lang: ``string``}.ToEng(``string``)``
|
||||
- ``Translate{Lang: ``string``}.ToKorvax(``string``)``
|
||||
- ``Translate{Lang: ``string``}.ToGek(``string``)``
|
||||
- ``Translate{Lang: ``string``}.ToVykeen(``string``)``
|
||||
- ``Translate{Lang: ``string``}.ToAtlat(``string``)``
|
||||
|
||||
#### Possible Lang string options
|
||||
|
||||
- ``"english"``
|
||||
- ``"korvax"``
|
||||
- ``"gek"``
|
||||
- ``"vykeen"``
|
||||
- ``"atlas"``
|
||||
|
||||
|
||||
|
||||
## Random Portal address
|
||||
|
||||
Generate random portal codes
|
||||
- Atlas Station
|
||||
- Black Hole
|
||||
- Random address
|
||||
|
||||
All random address created will default to the planet index 1 to help ensure there the address is valid
|
||||
|
||||
**Example:**
|
||||
|
||||
```golang
|
||||
fmt.Println(nmslib.RndPortal())
|
||||
fmt.Println(nmslib.RndPortal())
|
||||
fmt.Println(nmslib.RndAtlas())
|
||||
fmt.Println(nmslib.RndBH())
|
||||
```
|
||||
|
||||
**Output examples:**
|
||||
|
||||
``10EFABDEA373``
|
||||
|
||||
``11EAB355FC8E``
|
||||
|
||||
``107AC0E190D1``
|
||||
|
||||
``10796D57AE15``
|
||||
|
||||
<hr>
|
||||
|
||||
## A Proud member of NMH Hub
|
||||
|
||||
### [](https://nomanssky.fandom.com/wiki/No_Man%27s_High_Hub) [](https://discord.gg/mhRxf29hns)
|
||||
73
convert.go
73
convert.go
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
Xainesworld Video: https://www.youtube.com/watch?v=xmZbkTahw4w
|
||||
Fandom Wiki: https://nomanssky.fandom.com/wiki/Portal_address
|
||||
*/
|
||||
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
@@ -7,21 +12,11 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
The maths are all thanks to:
|
||||
Xainesworld
|
||||
- YT Channel - https://www.youtube.com/channel/UCzTB8EBVJWkzJi2sQjdBv9g
|
||||
- Video: https://www.youtube.com/watch?v=xmZbkTahw4w
|
||||
- Website: https://www.xainesworld.com/
|
||||
*/
|
||||
|
||||
/*
|
||||
P2gc - Portal code to galactic coordinates
|
||||
Requires 1 var and returns 1 var string
|
||||
var p string
|
||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
Return var string
|
||||
Galactic address (ex. 042F:0079:0D55:006A)
|
||||
Requires 1 var and returns 1 var string and an error
|
||||
var p string: Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
Returns var string: Galactic address (ex. 042F:0079:0D55:006A)
|
||||
*/
|
||||
func P2gc(p string) (gc string, err error) {
|
||||
if len(p) == 12 { // Test if length of provided string is 12 chars long
|
||||
@@ -30,19 +25,19 @@ func P2gc(p string) (gc string, err error) {
|
||||
var coord [4]int64
|
||||
coord[1], err = strconv.ParseInt(p[4:6], 16, 16) // Y coordinate
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [4:6]")
|
||||
}
|
||||
coord[2], err = strconv.ParseInt(p[6:9], 16, 16) // Z cooridnate
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [6:9]")
|
||||
}
|
||||
coord[3], err = strconv.ParseInt(p[9:12], 16, 16) // X coordinate
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [9:12]")
|
||||
}
|
||||
coord[0], err = strconv.ParseInt(p[1:4], 16, 16) // SSI (Star System Identifier)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [1:4]")
|
||||
}
|
||||
|
||||
// apply shifts to Handle the shape/boundaries of the galaxy
|
||||
@@ -63,29 +58,30 @@ func P2gc(p string) (gc string, err error) {
|
||||
gc = fmt.Sprintf("%04X:%04X:%04X:%04X", coord[3], coord[1], coord[2], coord[0])
|
||||
|
||||
} else { // if len(p) != 12 return an error
|
||||
return "", errors.New("A 12char HEX string is required. example: 006afa556c30")
|
||||
return "", errors.New("a 12char HEX string is required. example: 006afa556c30")
|
||||
}
|
||||
return // return formated string
|
||||
}
|
||||
|
||||
/*
|
||||
Gc2p - Galactic coordinates to portal code
|
||||
Requires 1 string and returns a string and error
|
||||
var gc string
|
||||
Galactic address (ex. 042F:0079:0D55:006A)
|
||||
Return var string
|
||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
Requires 1 string and 1 int returns a string and error
|
||||
var gc string: Galactic address (ex. 042F:0079:0D55:006A)
|
||||
var p int: Planet ID [1-6]
|
||||
Returns portalcode string: Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
*/
|
||||
func Gc2p(gc string) (portalcode string, err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
/*TODO: add option for Planet choice (1-6)*/
|
||||
func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||
// split and store string
|
||||
// coords[0] == X; coords[1] == Y coords[2] == Z;
|
||||
// coords[3] == SSI coords[4] == P
|
||||
coords := strings.Split(gc+":1", ":")
|
||||
if len(gc) != 19 {
|
||||
return "", errors.New("galatic code is the wrong length")
|
||||
}
|
||||
if p > 6 {
|
||||
p = 1
|
||||
}
|
||||
nustring := fmt.Sprintf("%s:%d", gc, p)
|
||||
coords := strings.Split(nustring, ":")
|
||||
for n := 0; n < len(coords); n++ {
|
||||
portalcode = portalcode + coords[n]
|
||||
}
|
||||
@@ -93,26 +89,30 @@ func Gc2p(gc string) (portalcode string, err error) {
|
||||
var hexCoords [5]int64
|
||||
hexCoords[0], err = strconv.ParseInt(coords[4], 16, 16) // P
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [4]")
|
||||
}
|
||||
hexCoords[1], err = strconv.ParseInt(coords[3], 16, 16) // SSI
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [3]")
|
||||
}
|
||||
hexCoords[2], err = strconv.ParseInt(coords[1], 16, 16) // Y
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [1]")
|
||||
}
|
||||
hexCoords[3], err = strconv.ParseInt(coords[2], 16, 16) // Z
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [2]")
|
||||
}
|
||||
hexCoords[4], err = strconv.ParseInt(coords[0], 16, 16) // X
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [0]")
|
||||
}
|
||||
|
||||
// Apply shifts to Handle the shape/boundaries of the galaxy
|
||||
/*Note:
|
||||
[P][SSS][YY][ZZZ][XXX] len == 12
|
||||
* SSS == SSI
|
||||
*/
|
||||
hexCoords[2] = hexCoords[2] + 0x81 // Y ->> shift
|
||||
hexCoords[3] = hexCoords[3] + 0x801 // Z ->> shift
|
||||
hexCoords[4] = hexCoords[4] + 0x801 // X ->> shift
|
||||
@@ -124,6 +124,7 @@ func Gc2p(gc string) (portalcode string, err error) {
|
||||
}
|
||||
|
||||
// Assemble padded values as a string
|
||||
|
||||
portalcode = fmt.Sprintf("%00X%03X", hexCoords[0], hexCoords[1])
|
||||
for n := 2; n < len(hexCoords); n++ {
|
||||
if n == 2 {
|
||||
@@ -132,5 +133,5 @@ func Gc2p(gc string) (portalcode string, err error) {
|
||||
portalcode = portalcode + fmt.Sprintf("%03X", hexCoords[n])
|
||||
}
|
||||
}
|
||||
return portalcode, err // return formated string and error
|
||||
return // return formated string and error
|
||||
}
|
||||
|
||||
155
glyphbanner.go
155
glyphbanner.go
@@ -1,91 +1,128 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/png"
|
||||
"image"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
gim "github.com/ozankasikci/go-image-merge"
|
||||
"github.com/fogleman/gg"
|
||||
)
|
||||
|
||||
/*CreateBanner - Output PNG of Portal Glyphs
|
||||
Requires 3 vars and returns 0 var, Outputs a PNG file
|
||||
var portalex string
|
||||
Portal Glyph hex string
|
||||
var savename string
|
||||
Output name of PNG file
|
||||
var vopt int
|
||||
1 enables vertical banner
|
||||
0 enables horizontal banner
|
||||
Requires 3 vars and returns 1 err, Outputs a PNG file
|
||||
var portalex string: Portal Glyph hex string
|
||||
var savename string: Output name of PNG file
|
||||
var opt int
|
||||
00 sets horizontal banner in light mode [ 00 || 0 ]
|
||||
01 sets horizontal banner in dark mode [ 01 || 1 ]
|
||||
10 sets vertical banner in light mode
|
||||
11 sets vertical banner in dark mode
|
||||
|
||||
* note first of the 2 bits sets the layout, the second bit sets the glyph color
|
||||
*/
|
||||
func CreateBanner(portalhex string, savename string, vopt int) {
|
||||
var err error
|
||||
func CreateBanner(portalhex string, savename string, opt int) (err error) {
|
||||
out, err := GenRawBanner(portalhex, opt)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
gg.SavePNG(savename+".png", out)
|
||||
//gg.SaveJPG(savename+".jpg", out, 50)
|
||||
return
|
||||
}
|
||||
|
||||
/*GenRawBanner - Returns image.Image of genorated image
|
||||
Requires 2 vars and returns image.Image (raw image data) and an error
|
||||
var portalex string: Portal Glyph hex string
|
||||
var opt int
|
||||
00 sets horizontal banner in light mode [ 00 || 0 ]
|
||||
01 sets horizontal banner in dark mode [ 01 || 1 ]
|
||||
10 sets vertical banner in light mode
|
||||
11 sets vertical banner in dark mode
|
||||
|
||||
* note first of the 2 bits sets the layout, the second bit sets the glyph color
|
||||
*/
|
||||
func GenRawBanner(portalhex string, layout int) (portalbanner image.Image, err error) {
|
||||
var GlyphHex [12]int64
|
||||
var glyphImg [12]string
|
||||
var mode string
|
||||
var imgArray [12]image.Image
|
||||
|
||||
//Set light or dark mode glyphs
|
||||
if layout == 00 || layout == 10 {
|
||||
mode = "light"
|
||||
} else if layout == 01 || layout == 11 {
|
||||
mode = "dark"
|
||||
} else {
|
||||
// if layout is an invalid option (ie. not a 2 bit binary number default to classic mode/layout
|
||||
layout = 0
|
||||
mode = "light"
|
||||
}
|
||||
|
||||
// verify len of portalhex
|
||||
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 and add it to an array of int64
|
||||
for i := 0; i < len(portalhex); i++ {
|
||||
GlyphHex[i], err = strconv.ParseInt(portalhex[i:int(i+1)], 16, 16)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, errors.New("string provided is not hexadecimal ([0-9][A-F])")
|
||||
}
|
||||
}
|
||||
// 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++ {
|
||||
glyphImg[j] = fmt.Sprintf("glyphs/GLYPH-%X.png", GlyphHex[j])
|
||||
glyphImg[j] = fmt.Sprintf("assets/glyphs/%s/PORTALSYMBOL.%X.png", mode, GlyphHex[j])
|
||||
}
|
||||
// pull images need from glyph.go and saved them to ./glyphs/
|
||||
|
||||
// pull images need from assets.go and saved them to the temp directory
|
||||
for k := 0; k < len(glyphImg); k++ {
|
||||
data, err := Asset(glyphImg[k])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, errors.New("can not load images from assets: " + glyphImg[k])
|
||||
}
|
||||
_, err2 := os.Stat("glyphs")
|
||||
if os.IsNotExist(err2) {
|
||||
errDir := os.MkdirAll("glyphs", 0755)
|
||||
if errDir != nil {
|
||||
panic(errDir)
|
||||
}
|
||||
err = ioutil.WriteFile(NmsTemp+"/"+glyphImg[k], []byte(data), 0644)
|
||||
if err != nil {
|
||||
return nil, errors.New("can not write file to temp directory")
|
||||
}
|
||||
err = ioutil.WriteFile(glyphImg[k], []byte(data), 0644)
|
||||
}
|
||||
}
|
||||
// load images for processing using github.com/ozankasikci/go-image-merge
|
||||
grids := []*gim.Grid{
|
||||
{ImageFilePath: glyphImg[0]}, {ImageFilePath: glyphImg[1]},
|
||||
{ImageFilePath: glyphImg[2]}, {ImageFilePath: glyphImg[3]},
|
||||
{ImageFilePath: glyphImg[4]}, {ImageFilePath: glyphImg[5]},
|
||||
{ImageFilePath: glyphImg[6]}, {ImageFilePath: glyphImg[7]},
|
||||
{ImageFilePath: glyphImg[8]}, {ImageFilePath: glyphImg[9]},
|
||||
{ImageFilePath: glyphImg[10]}, {ImageFilePath: glyphImg[11]},
|
||||
}
|
||||
if vopt == 1 {
|
||||
// Merge images horizontally
|
||||
rgba, err := gim.New(grids, 1, 12).Merge()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
//Load/open images needed
|
||||
for iter := 0; iter < 12; iter++ {
|
||||
imgArray[iter], err = gg.LoadPNG(NmsTemp + "/" + glyphImg[iter])
|
||||
if err != nil {
|
||||
return nil, errors.New("can not read glyph " + glyphImg[iter])
|
||||
}
|
||||
}
|
||||
|
||||
//begin concatenating images
|
||||
// get image size of first glyph, all glyphs have the same X && Y dimension so we only need to measure one.
|
||||
imgDim := imgArray[0].Bounds().Size()
|
||||
|
||||
//Set Layout
|
||||
//classic horizontal layout
|
||||
if layout == 01 || layout == 00 {
|
||||
imgWidth := imgDim.X * 12
|
||||
imgHeight := imgDim.Y
|
||||
concat := gg.NewContext(imgWidth, imgHeight)
|
||||
for a := 0; a < 12; a++ {
|
||||
concat.DrawImage(imgArray[a], imgDim.X*a, 0)
|
||||
}
|
||||
return concat.Image(), nil
|
||||
}
|
||||
|
||||
//Vertical layout
|
||||
if layout == 10 || layout == 11 {
|
||||
imgWidth := imgDim.X
|
||||
imgHeight := imgDim.Y * 12
|
||||
concat := gg.NewContext(imgWidth, imgHeight)
|
||||
for a := 0; a < 12; a++ {
|
||||
concat.DrawImage(imgArray[a], 0, imgDim.Y*a)
|
||||
}
|
||||
return concat.Image(), nil
|
||||
}
|
||||
// save the output to png
|
||||
fmt.Printf("Saving %s to %s in vertical format\n", portalhex, savename)
|
||||
file, err := os.Create(savename)
|
||||
err = png.Encode(file, rgba)
|
||||
} else {
|
||||
// Merge images vertically
|
||||
rgba, err := gim.New(grids, 12, 1).Merge()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// save the output to png
|
||||
fmt.Printf("Saving %s to %s\n", portalhex, savename)
|
||||
file, err := os.Create(savename)
|
||||
err = png.Encode(file, rgba)
|
||||
}
|
||||
// remove glyphs folder to keep it clean
|
||||
errDir := os.RemoveAll("glyphs")
|
||||
if errDir != nil {
|
||||
panic(errDir)
|
||||
return nil, errors.New("portalcode must be exactly 12 chars")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
10
go.mod
10
go.mod
@@ -1,5 +1,9 @@
|
||||
module gitlab.com/bradley.richins/nmslib
|
||||
module gitlab.com/Raum0x2A/nmslib
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/ozankasikci/go-image-merge v0.2.2
|
||||
require (
|
||||
github.com/fogleman/gg v1.3.1-0.20210131172831-af4cd580789b
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e // indirect
|
||||
)
|
||||
|
||||
9
go.sum
9
go.sum
@@ -1,2 +1,7 @@
|
||||
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/fogleman/gg v1.3.1-0.20210131172831-af4cd580789b h1:gqOBIAmkc/ZxXzFrM4wTub7tD0xYaOsaOQ5wOA74lJQ=
|
||||
github.com/fogleman/gg v1.3.1-0.20210131172831-af4cd580789b/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e h1:PzJMNfFQx+QO9hrC1GwZ4BoPGeNGhfeQEgcQFArEjPk=
|
||||
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
71
init.go
Normal file
71
init.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
/*NmsTemp - Global string variable
|
||||
Location of instance temporary directory
|
||||
Dir Structure:
|
||||
- NmsTemp
|
||||
-
|
||||
*/
|
||||
var NmsTemp string
|
||||
|
||||
/*Initialize temporary directory
|
||||
create a temp dir and save location to `NmsTemp` string
|
||||
*/
|
||||
func init() {
|
||||
// create temp dir
|
||||
temploc, err := ioutil.TempDir("", "nmslib-")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
NmsTemp = temploc
|
||||
|
||||
//Create directory structure
|
||||
err = os.Mkdir(NmsTemp+"/assets", 0755)
|
||||
if err != nil {
|
||||
panic(errors.New("failed to create temporary folder"))
|
||||
}
|
||||
err = os.Mkdir(NmsTemp+"/assets/lang", 0755)
|
||||
if err != nil {
|
||||
panic(errors.New("failed to create temporary folder"))
|
||||
}
|
||||
err = os.Mkdir(NmsTemp+"/assets/glyphs", 0755)
|
||||
if err != nil {
|
||||
panic(errors.New("failed to create temporary folder"))
|
||||
}
|
||||
err = os.Mkdir(NmsTemp+"/assets/glyphs/dark", 0755)
|
||||
if err != nil {
|
||||
panic(errors.New("failed to create temporary folder"))
|
||||
}
|
||||
err = os.Mkdir(NmsTemp+"/assets/glyphs/light", 0755)
|
||||
if err != nil {
|
||||
panic(errors.New("failed to create temporary folder"))
|
||||
}
|
||||
|
||||
//Write language files to temp directory
|
||||
fileloc := [4]string{"atlas-lang.csv", "gek-lang.csv", "korvax-lang.csv", "vykeen-lang.csv"}
|
||||
for x := 0; x < 4; x++ {
|
||||
data, err := Asset("assets/lang/" + fileloc[x])
|
||||
if err != nil {
|
||||
panic(errors.New("can not load: " + fileloc[x]))
|
||||
}
|
||||
err = ioutil.WriteFile(NmsTemp+"/assets/lang/"+fileloc[x], []byte(data), 0644)
|
||||
if err != nil {
|
||||
panic(errors.New("can not write " + fileloc[x] + " to temp dir"))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*CleanUp removes temporary directory an it's contents
|
||||
this is intended to be called in a defer statement in func main
|
||||
takes no input
|
||||
*/
|
||||
func CleanUp() {
|
||||
os.RemoveAll(NmsTemp)
|
||||
}
|
||||
11
init_test.go
Normal file
11
init_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
fmt.Printf("\nTesting init:\n")
|
||||
fmt.Printf("Temporary directory: %s\n\n", NmsTemp)
|
||||
}
|
||||
679
korvax-lang.csv
679
korvax-lang.csv
@@ -1,679 +0,0 @@
|
||||
rare,vaiut,Hik,
|
||||
warning,durenise,Ashkar,
|
||||
korvax,itelis,Bokhodim,
|
||||
convergence,nozavolochen,Tetyevolgove,
|
||||
toxic,vozd,Yundal,Teyug
|
||||
calm,vanog,Ekt,
|
||||
traveller,kostalymusk,Zazhelekal,
|
||||
probability,mavirsakhta,Urzhegodovu,
|
||||
please,stvovat,Vochiuh,
|
||||
high,len,Biazy,Rutyu
|
||||
time,viati,Avash,
|
||||
scared,ebakim,Oobsk,
|
||||
virus,layevk,Ognit,
|
||||
echoes,turyin,Inach,
|
||||
data,aishi,Ovu,Odgo
|
||||
power,borod,Hepet,
|
||||
disruption,giseppusiat,Romeshcuhinsk,
|
||||
stalled,balaish,Anuderbi,
|
||||
silicate,domostok,Georgiyev,
|
||||
impossible,ushkalinsky,Helissentam,
|
||||
low,edn,Zuhch,
|
||||
intelligence,inkangbaserta,Midovurasuk,
|
||||
lifeform,fitsawar,Snezhash,
|
||||
common,kosarac,Kalyuc,Eft
|
||||
vy'keen,udyono,Ubimusc,
|
||||
entity,kevich,Vikinoo,Katrogor
|
||||
orbital,kazaniem,Vilskolo,Ayskyv
|
||||
experiment,zohcherdesk,Oriasamynu,
|
||||
past,ayv,Vaye,
|
||||
dead,kolsh,Atc,
|
||||
clarify,ugurusan,Nirogoc,
|
||||
fascinating,leznakoideob,Tuchimaiutsky,
|
||||
atlas,tologri,Imaiu,Abli
|
||||
station,livnye,Yemansk,
|
||||
oxides,tagoda,Prudnye,
|
||||
bless,angels,Unit,
|
||||
interruption,kiyshomanotes,Husovetskiyev,
|
||||
imminently,zaviatnikha,Ervomoste,
|
||||
awakes,trezhir,Krasav,
|
||||
technology,kislobninog,Tegraychiny,
|
||||
yourself,ransiys,Oktyabi,
|
||||
isotope,elburg,Kirenik,
|
||||
overcharges,nouraktichev,Samarimovik,
|
||||
units,truni,Gukoye,
|
||||
language,tuapsemu,Iudachy,
|
||||
brain,ubanov,Hinog,
|
||||
tissue,ibayev,Nemant,
|
||||
research,napatoust,Mobarkad,
|
||||
failure,irnyevs,Yersky,
|
||||
criminal,gotovnoye,Osnodons,Nikurils
|
||||
starships,koyashmaniar,Udinovozyo,Linichik
|
||||
back,hesh,Tov,
|
||||
future,ougleb,Zeyvai,
|
||||
pure,kadn,Esh,
|
||||
sentinel,ugulmato,Peyskyvi,Akovskyv
|
||||
scan,omin,Ibaye,Odubo
|
||||
greed,vezdar,Yurbat,
|
||||
unavailable,ikargoffri,Yobrazdnikolo,
|
||||
motor,aetsk,Iiskiy,
|
||||
fire,utsiv,Hovis,
|
||||
discuss,gansiysk,Alzama,
|
||||
overheat,gobekin,Pogaetsk,
|
||||
contact,gochinoo,Ovdoro,
|
||||
retreat,uriyeve,Sodelik,
|
||||
required,nokamskyv,Osloborzy,
|
||||
alert,zania,Yakuta,
|
||||
core,aso,Osl,
|
||||
artificial,kihopyevetsi,Kinovorogo,
|
||||
insert,puchay,Noriali,
|
||||
bathe,kroymsk,Movsky,
|
||||
or,liz,Som,
|
||||
bad,has,Iud,
|
||||
vessel,skovrov,Niselts,
|
||||
share,bilets,Kutays,
|
||||
topic,glazov,Arossi,
|
||||
reset,nudet,Terga,
|
||||
primary,gester,Bavlek,
|
||||
silicates,miosskaia,Rodnikhimb,
|
||||
excess,epovozm,Helyeli,
|
||||
holy,riki,Tul,
|
||||
respect,zehasha,Nineykhat,
|
||||
excitement,hutarabaltay,Nilokhvin,
|
||||
worship,ladaniv,Rukakov,Asnovsky
|
||||
oxide,uyev,Avet,
|
||||
weaponry,ebskalt,Gudermes,
|
||||
remove,epano,Kanskiy,
|
||||
repair,uvorki,Vigali,
|
||||
resources,lonereche,Lamskyviu,
|
||||
secondary,kelepikiyev,Yemakhdenpo,
|
||||
donate,biysk,Ingra,
|
||||
specialists,dachyegoryk,Blizkimryus,
|
||||
beware,amady,Ipking,
|
||||
destiny,epikiner,Nezhne,
|
||||
escape,izeli,Roreche,
|
||||
eheu,mog,Retsk,
|
||||
existence,somonoslav,Histrogo,
|
||||
examination,kahaylovke,Tutayskommu,
|
||||
ayee,ter,Rubc,
|
||||
apologies,gradnayank,Opolenkur,
|
||||
electron,rameshevs,Osilkul,
|
||||
white,nani,Glazo,
|
||||
loss,akh,Fomi,
|
||||
upload,zoria,Ralskoi,Dreapo
|
||||
ahem,epet,Tous,
|
||||
unknown,ognitog,Metyevka,
|
||||
advance,kopinestv,Gityars,
|
||||
discharge,tovnoslu,Isoglebez,
|
||||
reconstruction,arechnostarii,Futekumskyviump,
|
||||
help,yichie,Skr,
|
||||
gek,akov,Huru,
|
||||
healing,uyevsky,Zulunin,
|
||||
reject,ikungr,Topot,
|
||||
formula,oglegoda,Yukopinog,
|
||||
relevant,yozhensk,Bavlyaqua,
|
||||
allow,ektro,Duly,
|
||||
geological,rimiinakorja,Prudniymita,
|
||||
valuable,ubovkin,Georgiyev,
|
||||
mission,urzhiva,Edelin,
|
||||
begins,emvab,Pikines,
|
||||
ship,pomo,Erchi,
|
||||
becomes,oblasovs,Oboria,
|
||||
filter,tisovsky,Vudinog,
|
||||
leave,monogor,Ortivn,
|
||||
reward,pessk,Evkari,
|
||||
slavery,darnau,Yakovoma,
|
||||
avoid,negors,Vinos,
|
||||
additional,oduboevui,Raktotolya,
|
||||
enthusiast,tivnyevsk,Aymazykaluy,
|
||||
absorb,iudac,Horusang,
|
||||
joyful,hachyeg,Rinush,
|
||||
embrace,deyskyvi,Odemyach,
|
||||
disconnection,ovetsialnyokha,Ayevskovkazh,
|
||||
dislike,zoyormonc,Dorornye,
|
||||
wait,etomu,Kur,
|
||||
disaster,tuyndala,Akinoslo,
|
||||
reboot,gutayga,Zehegu,
|
||||
pain,etamb,Iavl,
|
||||
sleep,kiro,Kubaks,
|
||||
quarantine,yucharabaz,Noozyibkov,
|
||||
detection,zahskyviumv,Manogorone,
|
||||
hole,bogut,Lilero,
|
||||
negotiation,rusakoidammag,Gityabinkang,
|
||||
wakes,aymaz,Nosl,
|
||||
creation,rakinovk,Ozzhevoi,
|
||||
element,zorial,Elgoron,
|
||||
immediately,mezenskyvin,Uapsheboksit,Zadakyuncam
|
||||
loop,yuc,Vano,
|
||||
forbidden,yonkiesbro,Padnayan,
|
||||
soon,meysk,Abins,
|
||||
probable,plimskyv,Grivoshes,
|
||||
control,nozhenyo,Kuznetsi,
|
||||
uncommon,kuvartkal,Nolitama,
|
||||
trade,vigradu,Adsk,
|
||||
signal,iniche,Yungri,
|
||||
hello,evoy,Ariins,
|
||||
blueprint,hovaldanov,Beytishenn,
|
||||
experiments,kasayevkargun,Hinyevskyvi,
|
||||
ending,omlya,Dudino,
|
||||
corrupted,lolashtar,Sutokinom,
|
||||
synthetic,shoyarov,Obekinestu,
|
||||
create,inich,Zeyanse,
|
||||
timeline,ekandal,Teprazdni,
|
||||
poison,dishacha,Nazyv,
|
||||
improbable,yeyskyvium,Imashacher,
|
||||
monolith,reutokaya,Utninsk,
|
||||
youth,livaiu,Kayzyav,
|
||||
galaxy,ondro,Ukrasu,
|
||||
centre,lovan,Zodalnec,
|
||||
reality,godskovo,Tuyrnyevo,
|
||||
speech,vogratsk,Gotoran,
|
||||
casing,tubimu,Holisk,
|
||||
insignificant,iiakhnevichu,Idetskyvinuus,
|
||||
busy,ruiu,For,
|
||||
admires,turazn,Anrogor,
|
||||
friend,yattira,Yatish,
|
||||
permanent,pestneves,Ozzhetsi,
|
||||
speaks,hekovrop,Izans,
|
||||
species,lamsky,Zavolod,
|
||||
benevolence,efremkhonyev,Yarnyaginin,
|
||||
creatures,ichinskyvi,Doukovskyv,
|
||||
isolated,pitkyak,Lamyzihets,
|
||||
attack,bashcaha,Sokopey,
|
||||
researcher,gubkinogors,Ofitsuancu,
|
||||
travels,ezensk,Honyevol,
|
||||
new,oeto,Arus,
|
||||
concentrate,vagraduzhumi,Ozhiyevskyv,
|
||||
operational,uynakoskjar,Usumanzhelya,
|
||||
red,sno,Groz,Vuk
|
||||
neural,ereseng,Sperv,
|
||||
morning,ektrov,Ovostavl,
|
||||
dangerous,yebkovsegem,Doukoyan,
|
||||
good,muchad,Ograt,
|
||||
orb,ray,Kur,
|
||||
technological,ognitskazhevo,Lukulebakaian,Hudogorsmanov
|
||||
darkness,utsialn,Helebska,
|
||||
danger,fitsii,Sudzhi,
|
||||
waters,kitiman,Tensk,
|
||||
temporal,agnitsan,Sukholm,
|
||||
hmm,nik,Naym,
|
||||
level,otdy,Zimeino,
|
||||
praise,arenshec,Sulino,Payevsk
|
||||
child,burgun,Kargo,
|
||||
findings,duiutskaz,Vaskyuvium,
|
||||
file,sosyla,Desno,
|
||||
blob,loyt,Pra,
|
||||
education,inkangbial,Hiliskovsk,
|
||||
automated,oitelebe,Orykohaba,
|
||||
restoration,zuhmandarent,Uppugnatus,
|
||||
your,petu,Yevs,
|
||||
wants,apsh,Erzha,
|
||||
constantly,uapseusius,Hetskaiushn,
|
||||
relearn,tepushc,Ukovsky,
|
||||
transmission,bonyevkazhel,Zainskogoli,
|
||||
network,tulakoid,Sotsky,
|
||||
catalogue,rukhaluymsky,Arganiae,
|
||||
recharge,desnoura,Grozove,
|
||||
decrease,gachyovod,Agodarnau,
|
||||
invisible,ebskaluett,Enburgunca,Madygeys
|
||||
adores,gobekin,Velsk,
|
||||
great,nodalny,Pikako,
|
||||
not,zay,Gac,
|
||||
pay,irz,Illo,
|
||||
ignore,dushc,Roloysva,
|
||||
blockage,irbiturtr,Doygeysk,
|
||||
over,oevus,Voale,
|
||||
better,rubinsky,Sayan,
|
||||
failed,eurazl,Hinach,
|
||||
move,lin,Ogn,
|
||||
traveller's,devoikhoviche,Rafimorsky,
|
||||
goods,sosnoz,Yatk,
|
||||
face,ikov,Tuap,
|
||||
endangered,ryunguryu,Rovodylurus,
|
||||
awaits,oukoyan,Druzha,
|
||||
sales,virsk,Dulia,
|
||||
restore,zadracepa,Daskovopa,
|
||||
information,telnoslanud,Arzamarime,
|
||||
accidentally,onstanasheb,Ulebskabent,
|
||||
federation,hilovkarapu,Eapoluninsk,
|
||||
hazard,esial,Bolesno,
|
||||
save,shichi,Eva,
|
||||
elements,nazyvaye,Vaypolocha,
|
||||
provide,ershovos,Mezens,
|
||||
operator,edynald,Oiteleno,
|
||||
strata,bogonet,Lepiki,
|
||||
join,per,Baychi,
|
||||
remains,kitotor,Payevsk,
|
||||
drone,kesper,Epet,
|
||||
only,yalsko,Ipets,
|
||||
capacitor,veycuhnyev,Kakhnyev,
|
||||
sends,lileys,Demenn,
|
||||
discover,barnyev,Dogotovis,
|
||||
vy'keen,udyono,Ubimusc,
|
||||
feel,iys,Dika,
|
||||
interrupted,iiskiyevsky,Yakhnyevskyv,
|
||||
fault,afimo,Pozzhe,
|
||||
seek,yirnye,Ach,
|
||||
me,vok,Bez,
|
||||
recall,roleemo,Kireng,
|
||||
reciprocal,lashimkin,Yeniiakha,
|
||||
shell,huvisto,Shim,
|
||||
watching,demyonnom,Bolgodoz,
|
||||
welcome,itvaarde,Duvezdare,
|
||||
process,uzlovshi,Giseysky,
|
||||
peace,ulma,Leznav,
|
||||
overpowered,ibiraetsim,Ozlovayevsky,
|
||||
today,enbur,Tilast,
|
||||
vital,inka,Bestno,
|
||||
words,azyvay,Zohyego,
|
||||
away,ums,Donays,
|
||||
average,ervomart,Hernusin,
|
||||
permissions,elnostomuksh,Agiruneate,
|
||||
planetary,bedyniskap,Miyzherep,
|
||||
request,ennits,Yebnoyen,
|
||||
fun,tepr,Liyuy,
|
||||
in,tuni,Mal,
|
||||
circuit,onstara,Poveshe,
|
||||
next,gods,Emer,
|
||||
give,vue,Ners,
|
||||
work,akh,Len,
|
||||
impure,okmin,Adzhevs,
|
||||
question,kandalast,Istrezhy,
|
||||
recorded,olzoves,Tetyusin,
|
||||
entrance,uganrogo,Ivilsky,
|
||||
goodbye,lomayishn,Myzyva,
|
||||
subvert,avliaiut,Meglinogo,
|
||||
production,amyzyvayev,Pallasoves,
|
||||
teach,amcha,Peysahm,
|
||||
dialect,charye,Tayndalm,
|
||||
combine,zunykehady,Yokmin,
|
||||
commendable,uppunicoigno,Biyskiyevkar,
|
||||
command,leyskyv,Sestovs,
|
||||
overseer,hilovskyv,Enshacho,
|
||||
biological,ludatayrnya,Delabulak,
|
||||
stone,yamazyv,Teka,
|
||||
mined,tinsar,Alyn,
|
||||
maximum,iutskyv,Lonyarn,
|
||||
stabilise,poshaets,Tuskuyviumh,
|
||||
sample,gansiys,Gezhach,
|
||||
violence,tushkanau,Oyarskyv,
|
||||
procedure,zelovodst,Engileyn,
|
||||
starship,luymsikyvi,Davliaiu,Mublemyonk
|
||||
electronic,haetsivosh,Fokinosloze,
|
||||
apply,godoi,Piki,
|
||||
discussions,drovskyvinta,Nokurinburgu,
|
||||
touch,ozzhev,Hanyevk,
|
||||
light,niemei,Oitel,
|
||||
here,edin,Emnik,
|
||||
interface,pogaetsiis,Apulaanhu,
|
||||
excellent,aplyoginooz,Losukyvinnu,
|
||||
order,emyo,Bezhn,
|
||||
through,shmanag,Evelinsk,
|
||||
escaped,sozavo,Yuzhasav,
|
||||
studies,gadzhen,Oscowini,
|
||||
feed,oluc,Usmot,
|
||||
follow,namenta,Ginski,
|
||||
initialize,revkaryans,Irenskompl,
|
||||
appropriate,rubcheguta,Okminusinst,
|
||||
with,zenam,Nivat,
|
||||
overload,amyzylsor,Olkovyelki,
|
||||
protection,alumyzyakh,Yoborzyakha,
|
||||
central,torzya,Ubkinosl,
|
||||
atmospheric,yeleznikovk,Onnikaltiys,Spiyskovods
|
||||
remain,erpukh,Tesevozy,
|
||||
drill,ladomo,Resman,
|
||||
know,ady,Opr,
|
||||
terminal,merobayev,Enburgu,
|
||||
success,radnic,Vikovr,
|
||||
behold,lazovay,Vitins,
|
||||
available,ladogdanko,Afimovskyv,
|
||||
facility,yesotska,Ibayevoi,
|
||||
approaches,tetyukhladu,Yishnymitt,
|
||||
cannot,neudint,Luziames,
|
||||
activity,lechatura,Zodokistup,
|
||||
databank,voybrazd,Zihelektr,
|
||||
certain,naulum,Rasnyocta,
|
||||
toxins,olniaet,Yekalt,
|
||||
log,chu,Kem,
|
||||
fabled,evdarg,Konayan,
|
||||
corrosive,chashiesi,Rouralskoi,
|
||||
journey,hidutogq,Kulebsk,Nochin
|
||||
resist,roshary,Fiksyo,
|
||||
tech,neka,Zat,
|
||||
energy,naibol,Meshets,
|
||||
show,rin,Ionov,
|
||||
commences,roshoyarvie,Ovdorona,
|
||||
await,etrop,Ovkara,
|
||||
highly,styugo,Eninsk,Amillov
|
||||
back-up,yinsta,Obskarve,
|
||||
returning,yabysihtagin,Odorodubo,
|
||||
medial,lerov,Katyvik,
|
||||
extracting,myachinskyv,Opyevoyeniz,
|
||||
contraband,rodiashikhv,Zelidovoso,Kihtyomoles
|
||||
shine,nenyk,Ritovn,
|
||||
uploading,imbaykala,Orodskoye,
|
||||
detected,atchinog,Loneralsk,
|
||||
system,odorov,Oginin,
|
||||
unexpected,gulyarnau,Meplimskyvin,
|
||||
expenditure,mirnoznoykha,Shovskyvium,
|
||||
gift,lac,Yabiry,
|
||||
engaged,moletsk,Lukhny,
|
||||
finish,opkin,Turlovk,
|
||||
think,shoya,Zinogo,
|
||||
delivery,pionovk,Dazernoeme,
|
||||
disengaged,zerzhukovok,Yegodstavino,
|
||||
knowledge,vikhopyevo,Noymittac,
|
||||
entities,zuberech,Yanoyeru,
|
||||
this,ibol,Adaky,
|
||||
non-intelligent,sevelskyvinume,Ipatigorbashcuhud,
|
||||
product,beycahnogo,Stvere,
|
||||
contribution,elburgansiysk,Vunymitenemola,
|
||||
tools,eski,Eveto,
|
||||
progress,oglegkorg,Seskaiang,
|
||||
alone,eural,Irovo,
|
||||
use,oul,Dopis,
|
||||
board,bukhoy,Antoyre,
|
||||
at,ilo,Ais,
|
||||
states,lairtzy,Bavlovs,
|
||||
will,push,Sht,
|
||||
all,ukh,Ufi,
|
||||
unlock,trane,Kinskit,
|
||||
of,nii,Slo,
|
||||
for,sut,Lono,
|
||||
and,suma,Mun,
|
||||
choose,eurash,Omarits,
|
||||
are,lak,Rus,
|
||||
to,gep,Mech,
|
||||
on,nok,Erd,
|
||||
you,ludo,Tin,
|
||||
is,ine,Dob,
|
||||
the,olkh,Ene,
|
||||
our,tinan,Rio,
|
||||
stars,ismanz,Kubak,
|
||||
a,ond,Tiso,
|
||||
i,ges,Vod,
|
||||
do,nag,Ort,
|
||||
see,itk,Selt,
|
||||
longrange,isilnyevsk,Yalugani,
|
||||
multitool,uglinooz,Zonikovke,
|
||||
careful,poyatii,Voboya,
|
||||
desk,retyuz,Ipk,
|
||||
we,yuz,Yase,
|
||||
examine,azanski,Eltsovka,
|
||||
using,devoi,Anud,
|
||||
what,bashich,Gradn,
|
||||
alarmed,fitskiti,Kihvald,
|
||||
happening,lagodoij,Tigorskyvi,
|
||||
open,paye,Ond,
|
||||
their,iushki,Yekam,
|
||||
be,yems,Apo,
|
||||
sorry,form,Rabaka,
|
||||
hopes,vomestu,Maiu,
|
||||
divergent,topoluche,Kohrustyugo,
|
||||
material,udutong,Eyskyvi,
|
||||
where,asavi,Litusyn,
|
||||
everywhere,efremiuraza,Koyanskyvin,
|
||||
aiee,leziam,Relya,
|
||||
around,benyev,Imaiu,
|
||||
found,davli,Krem,
|
||||
plants,poshate,Mestno,
|
||||
irrelevance,gotyabinokac,Popavliaiuts,
|
||||
accommodate,egezhgorone,Fimoviatniko,
|
||||
biggest,gutaysh,Tomark,
|
||||
secret,liyarvid,Yungri,
|
||||
design,kuhrom,Iushval,
|
||||
strange,irisogle,Exandy,
|
||||
different,utsiiatni,Nugeleizh,
|
||||
superior,kehtubinsk,Mavinskyv,
|
||||
highest,brasavil,Dobryac,
|
||||
things,zovantu,Holun,
|
||||
effective,panovoku,Imorskyvin,
|
||||
long,syk,Kuyby,
|
||||
suit,amb,Nets,
|
||||
no,bod,Rily,
|
||||
metal,satkar,Ginsk,
|
||||
mortal,luygins,Nanyigyi,
|
||||
unite,anga,Etaru,
|
||||
rampant,barnya,Broneten,
|
||||
comes,ovdor,Merovs,
|
||||
concerned,reapoluchi,Reposskazh,
|
||||
one,lem,Avlo,
|
||||
perhaps,vegorsky,Zolovoyen,
|
||||
expected,hegornoe,Negepasho,
|
||||
asks,liynk,Engoy,
|
||||
am,hum,Gad,
|
||||
lifeforms,rozanykhar,Furmavia,
|
||||
my,mech,Rado,
|
||||
resonance,herkaslibe,Insarypov,
|
||||
report,elgov,Ratilleu,
|
||||
still,sutok,Oblast,
|
||||
it,vir,Zor,
|
||||
holoterminus,sycahnovoyet,Rochyolkovom,
|
||||
from,nil,Eseny,
|
||||
seeing,emansk,Abink,
|
||||
find,otele,Douko,
|
||||
puzzle,timya,Relyel,
|
||||
there,bodarn,Ales,
|
||||
again,myzah,Rukhac,
|
||||
go,gar,Yizy,
|
||||
interesting,vuktyabrasko,Lozhenskiy,
|
||||
been,ubi,Aly,
|
||||
as,yud,Kaha,
|
||||
may,but,Yitn,
|
||||
encounters,rudskoideco,Ivnosokopy,
|
||||
knows,ryanov,Ruka,
|
||||
already,boksitog,Lotnoyet,
|
||||
eleven,voyer,Orskogo,
|
||||
rebirth,usinni,Dachin,
|
||||
compensation,apredovuralsk,Zoriastaixu,
|
||||
video,eyevoz,Torod,
|
||||
private,ezhnyev,Shnymi,
|
||||
discoveries,yermeshkov,Udzhevronako,
|
||||
promised,ubchekans,Nizheguta,
|
||||
minor,akinog,Kine,
|
||||
three,lidovo,Havins,
|
||||
well,ach,Vaybi,
|
||||
polo,amy,Lebu,
|
||||
brings,nodeli,Insarye,
|
||||
did,ubi,Vurov,
|
||||
such,eli,Gep,
|
||||
disconnected,engoyetainicc,Tizaniatnin,
|
||||
earn,nevet,Kezh,
|
||||
must,lore,Gatsi,
|
||||
present,eudint,Ubtsovsk,
|
||||
two,esti,Yung,
|
||||
connection,zovoaltiysk,Boyandrov,
|
||||
hear,mogon,Hus,
|
||||
organic,akanaul,Meinoozy,Tedoykhalya
|
||||
beautiful,ligarimovs,Pavlevigor,
|
||||
sixteen,tebeyt,Akayev,
|
||||
learned,nerogoro,Uguryevs,
|
||||
shall,zeleu,Yonos,
|
||||
us,vob,Biyc,
|
||||
mind,flagi,Elgo,
|
||||
hard,butur,Nicheg,
|
||||
these,zeliz,Yokha,
|
||||
fine,ayg,Oyan,
|
||||
worlds,tunevi,Manikho,
|
||||
generation,amillerob,Nodrovskyvi,
|
||||
requests,hidenpokh,Ichestre,
|
||||
tiny,zer,Mashe,
|
||||
assemble,ilskogae,Kuchigrya,
|
||||
everything,zereslibro,Lermonche,
|
||||
fan,deyk,Iks,
|
||||
four,loyur,Tiny,
|
||||
aids,zadu,Zel,
|
||||
logs,pes,Nasi,
|
||||
yet,yup,Oen,
|
||||
yes,pozz,Dono,
|
||||
they,erc,Zuye,
|
||||
allocated,ryimskyviu,Oustyugora,
|
||||
continue,piyskit,Vezhnosl,
|
||||
moment,torzhig,Piyatsk,
|
||||
fade,dey,Ripin,
|
||||
assist,ziyvayan,Hovsk,
|
||||
saw,olot,Osn,
|
||||
adjust,slyudya,Naymitas,
|
||||
service,gaetsim,Vosteiro,
|
||||
pleasure,rostarsky,Zanskom,
|
||||
upon,usm,Zohsk,
|
||||
faster,yeskoid,Niykhac,
|
||||
trapped,kitimanz,Poluchis,
|
||||
nonexistence,yorskovokhay,Zimanovomari,
|
||||
warping,talnyev,Odnyauza,
|
||||
broadcasts,yesseltsy,Hudozhaian,
|
||||
value,iyevol,Enza,
|
||||
voice,obuzh,Bulans,
|
||||
charging,runinok,Udzhantam,
|
||||
rewarding,renyevoi,Napadnovik,
|
||||
heartbeat,yabrsukyvi,Emovista,
|
||||
disappointing,zavodskommun,Vuyksanovskyvin,
|
||||
score,uver,Yevo,
|
||||
nanites,ugulmato,Layanskiti,
|
||||
most,tana,Yupol,
|
||||
reduced,rilovking,Plastr,
|
||||
succeeds,suselyoshe,Ezovets,
|
||||
warped,ishieme,Rakess,
|
||||
draw,ogu,Yosh,
|
||||
series,sosno,Kezhely,
|
||||
unit,abe,Ekums,
|
||||
enjoy,ekana,Aktot,
|
||||
drama,tobo,Semyon,
|
||||
missions,ebnyevka,Uberben,
|
||||
while,roko,Daniiu,
|
||||
anything,etlogriv,Nadeyshma,
|
||||
both,vukt,Ibo,
|
||||
nada,pev,Haylo,
|
||||
after,vikoel,Govoul,
|
||||
was,tima,Vay,
|
||||
terminate,pudomaysh,Ogrivoikh,
|
||||
task,rac,Sinn,
|
||||
before,iinsky,Bansk,
|
||||
between,ikhardo,Umanovok,
|
||||
truth,atniko,Udets,
|
||||
flesh,ernu,Dost,
|
||||
breached,esyegors,Doymkarpi,
|
||||
harvest,munart,Buinskit,
|
||||
eyes,dika,Zale,
|
||||
disagree,honyevs,Erskyvin,
|
||||
suspicious,soglegkou,Mikhanskyvi,
|
||||
nature,ukovsev,Udyonn,
|
||||
favourites,zarenyovs,Tinskyviu,
|
||||
had,luk,Vic,
|
||||
let,ogn,Puga,
|
||||
origin,bezhna,Megisem,
|
||||
way,dano,Ryokh,
|
||||
suppose,virskovs,Idetelny,
|
||||
real,loymsik,Urz,
|
||||
transfer,medynosba,Yeyskog,
|
||||
enough,mertaur,Urovn,
|
||||
complete,hudenpokro,Naulari,
|
||||
shed,ishcoh,Buko,
|
||||
try,nadz,Hakov,
|
||||
rewards,ruskyuviu,Netsivil,
|
||||
test,brs,Mar,
|
||||
offer,bess,Adimir,
|
||||
an,dud,Zob,
|
||||
why,ubk,Nutey,
|
||||
very,rolo,Pay,
|
||||
attention,azinokamsk,Imechorant,
|
||||
persist,atovor,Virsan,
|
||||
sounds,minyan,Ainstal,
|
||||
forgiven,tadtrund,Asliberal,
|
||||
job,form,Kotic,
|
||||
have,lamy,Yeys,
|
||||
prepared,ukoyenaea,Ripinstav,
|
||||
gate,ugin,Ichi,
|
||||
aid,zeme,Enk,
|
||||
ago,mec,Eto,
|
||||
end,avas,Aoz,
|
||||
universe,raktorab,Etlogor,
|
||||
performing,yuzhasavia,Churilovke,
|
||||
possessions,abrsekyvina,Yubnoyerdis,
|
||||
imagined,lezname,Kanashets,
|
||||
controlled,oguchaylov,Slovantur,
|
||||
portable,odvigatc,Uketyvkaz,
|
||||
keep,etl,Zov,
|
||||
beaten,uitel,Ralner,
|
||||
six,atel,Evro,
|
||||
learn,achi,Zepetu,
|
||||
logged,palla,Yanovo,
|
||||
instantiation,sudzhachitama,Hedurechevskyv,
|
||||
would,mirn,Ayma,
|
||||
build,sumanz,Evsky,
|
||||
distortion,arachyegon,Pogotovia,
|
||||
passes,vomins,Odpork,
|
||||
exocraft,nuguryuka,Yosayando,
|
||||
breach,runinsk,Luykin,
|
||||
its,yon,Lug,
|
||||
doors,fitsia,Deymkar,
|
||||
each,ray,Menog,
|
||||
reestablish,ryinstevovo,Enyevkarosl,
|
||||
look,yuch,Vet,
|
||||
abyss,limyzya,Sensh,
|
||||
congratulations,ozmodemerouglego,Ibolskovorkhot,
|
||||
now,luy,Maiu,
|
||||
waited,teryu,Lilets,
|
||||
beckons,gepast,Etomut,
|
||||
nothing,nerogobe,Zedokis,
|
||||
looks,tiam,Siysk,
|
||||
skilled,bezhdo,Deneudin,
|
||||
costume,kuyshest,Omariins,
|
||||
message,rabanov,Izilyu,
|
||||
water,aktotm,Udutog,
|
||||
about,eksin,Enpoka,
|
||||
largest,modeys,Anninok,
|
||||
visible,akzhets,Avolovsk,
|
||||
wrong,furm,Sasovo,
|
||||
life,liny,Keme,
|
||||
package,viremovse,Zimeinog,
|
||||
statistics,vorogorodia,Tanovnosti,
|
||||
enter,esoz,Hodin,
|
||||
so,hola,Yul,
|
||||
absence,ommuna,Illovoy,
|
||||
like,hilku,Nudal,
|
||||
but,ads,Zehn,
|
||||
anomaly,nuyovsh,Odinov,
|
||||
pleased,tionoslu,Plimors,
|
||||
warn,siselb,Mos,
|
||||
smiles,itkyart,Nesaraya,
|
||||
other,evdar,Ranoet,
|
||||
victory,kazhdogo,Nikakhal,
|
||||
percent,zensky,Lokhoy,
|
||||
start,algo,Dubn,
|
||||
settle,novsky,Sushc,
|
||||
has,nur,Laga,
|
||||
stronger,hatsialn,Verkess,
|
||||
closer,hutins,Nosohchev,
|
||||
earning,rimontoro,Inacheny,
|
||||
carapace,dazhevsko,Islozhosk,
|
||||
warp,tovsh,Zabak,
|
||||
twelve,dudino,Yukalyn,
|
||||
check,rozo,Sivirs,
|
||||
immediate,edinkarsal,Aplyovos,
|
||||
world,evdar,Aplyov,
|
||||
transmitter,unguruslaval,Puysohkinoozyb,
|
||||
once,mak,Usla,
|
||||
more,arii,Mich,
|
||||
five,nisiy,Hen,
|
||||
projection,amskyvium,Brazmanga,
|
||||
analysis,uboevushc,Imenskyvi,
|
||||
even,onno,Teyn,
|
||||
business,kusanqab,Zekimovis,
|
||||
them,loyar,Rorek,
|
||||
best,odvi,Kotr,
|
||||
notes,mari,Amura,
|
||||
communion,gulkevino,Ryluskyvin,
|
||||
how,ezn,Gop,
|
||||
ten,mest,Zaba,
|
||||
containment,iyevskyvin,Udozhelyeaex,
|
||||
purify,ransi,Voikhay,
|
||||
take,zilyu,Ogni,
|
||||
much,anko,Mash,
|
||||
answer,havinsk,Alugan,
|
||||
unpleasing,unechovori,Ozeleuzen,
|
||||
say,zuyor,Otla,
|
||||
ancestor,emanzheg,Eynoyet,
|
||||
sees,gar,Rishc,
|
||||
pattern,ogutay,Yushnyev,
|
||||
emergency,eapoluch,Alinichel,
|
||||
|
175
lang.go
175
lang.go
@@ -2,75 +2,140 @@ package nmslib
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
Korvaxlang - set up structure of a word iteration
|
||||
/*Translate Game languages and english
|
||||
Translate.Lang sets source language for translations
|
||||
options are:
|
||||
korvax
|
||||
gek
|
||||
vykeen
|
||||
atlas
|
||||
english
|
||||
*/
|
||||
type Korvaxlang struct {
|
||||
English string
|
||||
KorvaxWord string
|
||||
KWCaps string
|
||||
KWALLCAPS string
|
||||
type Translate struct {
|
||||
Lang string
|
||||
}
|
||||
|
||||
/*
|
||||
Korvax2Eng - convert known korvax words into english
|
||||
/*Translate source language to english
|
||||
Translate any NMS language (ie. Korvax) to english
|
||||
*/
|
||||
func Korvax2Eng(kvwrd string) string {
|
||||
csvFile, err := os.Open("korvax-lang.csv")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer csvFile.Close()
|
||||
CsvLines, err := csv.NewReader(csvFile).ReadAll()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
for _, line := range CsvLines {
|
||||
klang := Korvaxlang{
|
||||
English: line[0],
|
||||
KorvaxWord: line[1],
|
||||
KWCaps: line[2],
|
||||
KWALLCAPS: line[3],
|
||||
}
|
||||
if kvwrd == klang.KorvaxWord {
|
||||
return klang.English
|
||||
} else if kvwrd == klang.KWCaps {
|
||||
return strings.Title(strings.ToLower(klang.English))
|
||||
} else if kvwrd == klang.KWALLCAPS {
|
||||
return strings.ToUpper(klang.English)
|
||||
}
|
||||
}
|
||||
return "*\\Kzzzzzzt\\*" // word not found default
|
||||
func (t Translate) ToEng(word string) (translation string) {
|
||||
//return translate2english(word, langFile(t.Lang))
|
||||
return Translator(word, t.Lang, "english")
|
||||
}
|
||||
|
||||
/*
|
||||
Eng2Korvax - Convert (some) english words to Korvax
|
||||
/*Translate source language to Korvax
|
||||
Translate any NMS language or english (ie. Gek) to Korvax
|
||||
*/
|
||||
func Eng2Korvax(enwrd string) string {
|
||||
csvFile, err := os.Open("korvax-lang.csv")
|
||||
func (t Translate) ToKorvax(word string) (translation string) {
|
||||
return Translator(word, t.Lang, "korvax")
|
||||
}
|
||||
|
||||
/*Translate source language to Vy'Keen
|
||||
Translate any NMS language or english (ie. Atlas) to Vy'Keen
|
||||
*/
|
||||
func (t Translate) ToVykeen(word string) (translation string) {
|
||||
return Translator(word, t.Lang, "vykeen")
|
||||
}
|
||||
|
||||
/*Translate source language to Gek
|
||||
Translate any NMS language or english (ie. Vy'Keen) to Gek
|
||||
*/
|
||||
func (t Translate) ToGek(word string) (translation string) {
|
||||
return Translator(word, t.Lang, "Gek")
|
||||
}
|
||||
|
||||
/*Translate source language to Atlas
|
||||
Translate any NMS language or english (ie. Korvax) to Atlas
|
||||
*/
|
||||
func (t Translate) ToAtlas(word string) (translation string) {
|
||||
return Translator(word, t.Lang, "atlas")
|
||||
}
|
||||
|
||||
// read language files
|
||||
func langFile(lang string) [][]string {
|
||||
filepath := NmsTemp + "/assets/lang/" + lang + "-lang.csv"
|
||||
csvFile, err := os.Open(filepath)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
panic(err)
|
||||
}
|
||||
defer csvFile.Close()
|
||||
CsvLines, err := csv.NewReader(csvFile).ReadAll()
|
||||
|
||||
lines, err := csv.NewReader(csvFile).ReadAll()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
panic(err)
|
||||
}
|
||||
for _, line := range CsvLines {
|
||||
klang := Korvaxlang{
|
||||
English: line[0],
|
||||
KorvaxWord: line[1],
|
||||
KWCaps: line[2],
|
||||
KWALLCAPS: line[3],
|
||||
}
|
||||
if enwrd == klang.English {
|
||||
return klang.KorvaxWord
|
||||
}
|
||||
}
|
||||
return "*\\Kzzzzzzt\\*" // word not found default
|
||||
return lines
|
||||
}
|
||||
|
||||
/*Translate any in game language to another including english (ie. Korvax to Gek)
|
||||
Translating from english to a game language will alway default to all lower case for now
|
||||
*/
|
||||
func Translator(word string, source string, target string) string {
|
||||
var sourcekey [4]string
|
||||
var targetkey [4]string
|
||||
var dmy string
|
||||
var rt string
|
||||
|
||||
rt = "*\\Kzzzzzzt\\*"
|
||||
|
||||
if source == "english" {
|
||||
dmy = target
|
||||
} else {
|
||||
dmy = source
|
||||
}
|
||||
for _, line := range langFile(dmy) {
|
||||
for _, trans := range line {
|
||||
if trans == word {
|
||||
sourcekey[0] = line[0]
|
||||
sourcekey[1] = line[1]
|
||||
sourcekey[2] = line[2]
|
||||
sourcekey[3] = line[3]
|
||||
}
|
||||
}
|
||||
if target != "english" {
|
||||
for _, line := range langFile(target) {
|
||||
if strings.EqualFold(line[0], sourcekey[0]) {
|
||||
targetkey[0] = line[0]
|
||||
targetkey[1] = line[1]
|
||||
targetkey[2] = line[2]
|
||||
targetkey[3] = line[3]
|
||||
}
|
||||
}
|
||||
if strings.EqualFold(word, sourcekey[0]) {
|
||||
if targetkey[0] != "" {
|
||||
rt = targetkey[0]
|
||||
}
|
||||
} else if strings.EqualFold(word, sourcekey[1]) {
|
||||
if targetkey[1] != "" {
|
||||
rt = targetkey[1]
|
||||
}
|
||||
} else if strings.EqualFold(word, sourcekey[2]) {
|
||||
if targetkey[2] != "" {
|
||||
rt = targetkey[2]
|
||||
}
|
||||
} else if strings.EqualFold(word, sourcekey[3]) {
|
||||
if targetkey[3] != "" {
|
||||
rt = targetkey[3]
|
||||
}
|
||||
}
|
||||
if source == "english" {
|
||||
rt = targetkey[1]
|
||||
}
|
||||
} else {
|
||||
if strings.EqualFold(word, sourcekey[0]) {
|
||||
rt = sourcekey[0]
|
||||
} else if strings.EqualFold(word, sourcekey[1]) {
|
||||
rt = strings.ToLower(sourcekey[0])
|
||||
} else if strings.EqualFold(word, sourcekey[2]) {
|
||||
rt = strings.Title(sourcekey[0])
|
||||
} else if strings.EqualFold(word, sourcekey[3]) {
|
||||
rt = strings.ToUpper(sourcekey[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
return rt
|
||||
}
|
||||
|
||||
30
nmslib-convert_test.go
Normal file
30
nmslib-convert_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPortal2Galactic(t *testing.T) {
|
||||
want, err := P2gc("21F2F8EDB94D")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if want != "014C:0077:06DA:01F2" {
|
||||
t.Errorf("Testing P2gc(\"21F2F8EDB94D\"): got %q, want: 014C:0077:06DA:01F2.\n", want)
|
||||
} else {
|
||||
fmt.Printf("Testing P2gc(\"21F2F8EDB94D\"): got: %q, want: 014C:0077:06DA:01F2.\n", want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGalactic2portal(t *testing.T) {
|
||||
want, err := Gc2p("014C:0077:06DA:01F2", 2)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if want != "21F2F8EDB94D" {
|
||||
t.Errorf("Testing Gc2p(\"014C:0077:06DA:01F2\"): got %q, want: 21F2F8EDB94D.\n", want)
|
||||
} else {
|
||||
fmt.Printf("Testing Gc2p(\"014C:0077:06DA:01F2\"): got: %q, want: 21F2F8EDB94D.\n", want)
|
||||
}
|
||||
}
|
||||
21
nmslib-glyphbanner_test.go
Normal file
21
nmslib-glyphbanner_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreateBanner(t *testing.T) {
|
||||
fmt.Printf("\nTesting CreateBanner: ")
|
||||
|
||||
rp := "21F2F8EDB94D"
|
||||
//rp := RndPortal()
|
||||
fileout := "./test"
|
||||
|
||||
err := CreateBanner(rp, fileout, 0)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Portal address `%s` rendered as `%s`\n", rp, fileout)
|
||||
}
|
||||
21
nmslib-rpcg_test.go
Normal file
21
nmslib-rpcg_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRndPortal(t *testing.T) {
|
||||
fmt.Printf("\nRandom Portal Code: ")
|
||||
fmt.Println(RndPortal())
|
||||
}
|
||||
|
||||
func TestRndAtlas(t *testing.T) {
|
||||
fmt.Printf("semi-Random Atlas Code: ")
|
||||
fmt.Println(RndAtlas())
|
||||
}
|
||||
|
||||
func TestRndBH(t *testing.T) {
|
||||
fmt.Printf("semi-Random black hole Code: ")
|
||||
fmt.Println(RndBH())
|
||||
}
|
||||
36
nmslib-translate_test.go
Normal file
36
nmslib-translate_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTranslate(t *testing.T) {
|
||||
kor2eng := Translate{Lang: "korvax"}
|
||||
if kor2eng.ToEng("Alinichel") != "Emergency" {
|
||||
t.Errorf("\nTesting Translate{Lang: \"korvax\"}.ToEng(\"Alinichel\"): got %q, want: %q.\n", kor2eng.ToEng("Alinichel"), "Emergency")
|
||||
} else {
|
||||
fmt.Printf("\nTesting Translate{Lang: \"korvax\"}.ToEng(\"Alinichel\"): got %q, want: %q.\n", kor2eng.ToEng("Alinichel"), "Emergency")
|
||||
}
|
||||
|
||||
vyk2eng := Translate{"vykeen"}
|
||||
if vyk2eng.ToEng("Aqo") != "Foes" {
|
||||
t.Errorf("Testing Translate{Lang: \"vykeen\"}.ToEng(\"Aqo\"): got %q, want: %q.\n", vyk2eng.ToEng("Aqo"), "Foes")
|
||||
} else {
|
||||
fmt.Printf("Testing Translate{Lang: \"vykeen\"}.ToEng(\"Aqo\"): got %q, want: %q.\n", vyk2eng.ToEng("Aqo"), "Foes")
|
||||
}
|
||||
|
||||
engWord := Translate{"english"}
|
||||
if engWord.ToKorvax("learn") != "achi" {
|
||||
t.Errorf("Testing Translate{Lang: \"english\"}.ToKor(\"learn\"): got %q, want: %q.\n", engWord.ToKorvax("learn"), "achi")
|
||||
} else {
|
||||
fmt.Printf("Testing Translate{Lang: \"english\"}.ToKor(\"learn\"): got %q, want: %q.\n", engWord.ToKorvax("learn"), "achi")
|
||||
}
|
||||
|
||||
fmt.Println("Blind Test: " + Translate{"gek"}.ToAtlas("baturk")) // word does not exist in Atlas lang
|
||||
fmt.Println("Blind Test: " + Translate{"gek"}.ToAtlas("Tor")) // word exists
|
||||
|
||||
fmt.Println("Running CleanUp()")
|
||||
CleanUp()
|
||||
fmt.Printf("\nTesting complete.\nStatus: ")
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPortal2Galactic(t *testing.T) {
|
||||
want, err := P2gc("006afa556c30")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if want != "042F:0079:0D55:006A" {
|
||||
t.Errorf("Testing P2gc(\"006afa556c30\"): got %q, want: %q.\n", want, "042F:0079:0D55:006A")
|
||||
} else {
|
||||
fmt.Printf("Testing P2gc(\"006afa556c30\"): got: %q, want: %q.\n", want, "042F:0079:0D55:006A")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGalactic2portal(t *testing.T) {
|
||||
want, err := Gc2p("042F:0079:0D55:006A")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if want != "106AFA556C30" {
|
||||
t.Errorf("Testing Gc2p(\"042F:0079:0D55:006A\"): got %q, want: %q.\n", want, "106AFA556C30")
|
||||
} else {
|
||||
fmt.Printf("Testing Gc2p(\"042F:0079:0D55:006A\"): got: %q, want: %q.\n", want, "106AFA556C30")
|
||||
}
|
||||
|
||||
want, err = Gc2p("044B:0081:0D68:0096")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if want != "109602569C4C" {
|
||||
t.Errorf("Testing Gc2p(\"044B:0081:0D68:0096\"): got %q, want: %q.\n", want, "109602569C4C")
|
||||
} else {
|
||||
fmt.Printf("Testing Gc2p(\"044B:0081:0D68:0096\"): got: %q, want: %q.\n", want, "109602569C4C")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateBanner(t *testing.T) {
|
||||
fmt.Printf("Testing CreateBanner: ")
|
||||
CreateBanner("006afa556c30", "/tmp/Test.png", 0)
|
||||
}
|
||||
|
||||
func TestKorvax2Eng(t *testing.T) {
|
||||
want := Korvax2Eng("eapoluch")
|
||||
if want != "emergency" {
|
||||
t.Errorf("Testing Korvax2eng(\"eapoluch\"): got %q, want: %q.\n", want, "emergency")
|
||||
} else {
|
||||
fmt.Printf("Testing Korvax2eng(\"eapoluch\"): got %q, want: %q.\n", want, "emergency")
|
||||
}
|
||||
|
||||
want = Korvax2Eng("notaword")
|
||||
if want != "*\\Kzzzzzzt\\*" {
|
||||
t.Errorf("Testing Korvax2eng(\"notaword\"): got %q, want: %q.\n", want, "*\\Kzzzzzzt\\*")
|
||||
} else {
|
||||
fmt.Printf("Testing Korvax2eng(\"notaword\"): got %q, want: %q.\n", want, "*\\Kzzzzzzt\\*")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEng2Korvax(t *testing.T) {
|
||||
want := Eng2Korvax("emergency")
|
||||
if want != "eapoluch" {
|
||||
t.Errorf("Testing Eng2Korvax(\"emergency\"): got %q, want: %q.\n", want, "eapoluch")
|
||||
} else {
|
||||
fmt.Printf("Testing Eng2Korvax(\"emergency\"): got %q, want: %q.\n", want, "eapoluch")
|
||||
}
|
||||
|
||||
want = Eng2Korvax("notaword")
|
||||
if want != "*\\Kzzzzzzt\\*" {
|
||||
t.Errorf("Testing Eng2Korvax(\"notaword\"): got %q, want: %q.\n", want, "*\\Kzzzzzzt\\*")
|
||||
} else {
|
||||
fmt.Printf("Testing Eng2Korvax(\"notaword\"): got %q, want: %q.\n", want, "*\\Kzzzzzzt\\*")
|
||||
}
|
||||
fmt.Printf("Testing: ")
|
||||
}
|
||||
BIN
ranportal_scaled.png
Normal file
BIN
ranportal_scaled.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
92
rpcg.go
Normal file
92
rpcg.go
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
[P][SSS][YY][ZZZ][XXX] – (P = Planet Index / S = Star System Index / Y = Height / Z = Width / X = Length)
|
||||
|
||||
`Solar System Index
|
||||
A Solar System Index is assigned to each star system in a region. It always begins at SolarSystemIndex=001
|
||||
and counts up by one for every star system. The number of star systems in a region is variable so the
|
||||
maximum value of the Solar System Index is also variable, though the two correspond directly. To date there
|
||||
is no discovered value that is higher than SolarSystemIndex=243 (Mamundi-Kate in the Baadossm Anomaly of
|
||||
Euclid galaxy), meaning that 579 is the maximum number of star systems yet discovered in a region. Based
|
||||
on the evidence that every region has a SolarSystemIndex=079 and SolarSystemIndex=07A (with the former
|
||||
always having a Black Hole and the latter always having an Atlas Station), it is known that every region has
|
||||
at least 122 star systems. SolarSystemIndex=000 always leads to the region's first system, just like
|
||||
PlanetIndex=0 always leads to the first portal of a system due to the error proximity mechanic.`
|
||||
Source https://nomanssky.fandom.com/wiki/Portal_address#Solar_System_Index
|
||||
|
||||
*/
|
||||
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
RndPortal - Random Portalcode generator
|
||||
Requires no input required and returns a string
|
||||
*/
|
||||
|
||||
func RndPortal() (final string) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
min := 0x1
|
||||
ymax := 0xFF
|
||||
xzmax := 0xFFF
|
||||
ssimax := 0x242 // set this low to lower chances of an invalid address
|
||||
|
||||
x := rand.Intn(xzmax-min+1) + min
|
||||
z := rand.Intn(xzmax-min+1) + min
|
||||
y := rand.Intn(ymax-min+1) + min
|
||||
ssi := rand.Intn(ssimax-min+1) + min
|
||||
|
||||
final = fmt.Sprintf("%00X%03X%02X%03X%03X", 1, ssi, y, z, x)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*RndAtlas genorates a semi-random atlas code
|
||||
Requires no input and returns a string
|
||||
|
||||
This is not a true random atlas genorator. Insted this will create a Planet id of 1, Solar System Index of 0x07A and random Y, Z, X
|
||||
SSI 0x07A always has an Atlas Interface.
|
||||
|
||||
REF: https://nomanssky.fandom.com/wiki/Portal_address#Solar_System_Index https://nomanssky.fandom.com/wiki/Star_system#Classification
|
||||
*/
|
||||
func RndAtlas() (final string) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
min := 0x1
|
||||
ymax := 0xFF
|
||||
xzmax := 0xFFF
|
||||
|
||||
x := rand.Intn(xzmax-min+1) + min
|
||||
z := rand.Intn(xzmax-min+1) + min
|
||||
y := rand.Intn(ymax-min+1) + min
|
||||
|
||||
final = fmt.Sprintf("%00X%03X%02X%03X%03X", 1, 0x07A, y, z, x)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*RndBH genorates a semi-random atlas code
|
||||
Requires no input required and returns a string
|
||||
|
||||
This is not a true random atlas genorator. Insted this will create a Planet id of 1, Solar System Index of 0x079 and random Y, Z, X
|
||||
SSI 0x079 always has a black hole.
|
||||
|
||||
REF: https://nomanssky.fandom.com/wiki/Portal_address#Solar_System_Index https://nomanssky.fandom.com/wiki/Star_system#Classification
|
||||
*/
|
||||
func RndBH() (final string) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
min := 0x1
|
||||
ymax := 0xFF
|
||||
xzmax := 0xFFF
|
||||
|
||||
x := rand.Intn(xzmax-min+1) + min
|
||||
z := rand.Intn(xzmax-min+1) + min
|
||||
y := rand.Intn(ymax-min+1) + min
|
||||
|
||||
final = fmt.Sprintf("%00X%03X%02X%03X%03X", 1, 0x079, y, z, x)
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user