Rename this_algorithm to xpin
This commit is contained in:
parent
931835904e
commit
06506def20
40
Cargo.lock
generated
40
Cargo.lock
generated
@ -1317,25 +1317,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "this_algorithm"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"csv",
|
|
||||||
"s2",
|
|
||||||
"serde",
|
|
||||||
"thiserror",
|
|
||||||
"words",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "this_algorithm-wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"this_algorithm",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.38"
|
version = "1.0.38"
|
||||||
@ -1666,8 +1647,8 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"rocket",
|
"rocket",
|
||||||
"serde",
|
"serde",
|
||||||
"this_algorithm",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"xpin",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1827,6 +1808,25 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xpin"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"csv",
|
||||||
|
"s2",
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
"words",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xpin-wasm"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
"xpin",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yansi"
|
name = "yansi"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "this_algorithm"
|
name = "xpin"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
members = [
|
members = [
|
||||||
".",
|
".",
|
||||||
"./words",
|
"./words",
|
||||||
"./this_algorithm-wasm/",
|
"./xpin-wasm/",
|
||||||
"./web",
|
"./web",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
:rouge-style: molokai
|
:rouge-style: molokai
|
||||||
:sectlinks:
|
:sectlinks:
|
||||||
|
|
||||||
= this_algorithm
|
= xpin
|
||||||
|
@ -16,9 +16,9 @@ If you want to see the steps to get to this definition, go to link:DESIGN.html[D
|
|||||||
|
|
||||||
== Data format
|
== Data format
|
||||||
|
|
||||||
[source,title='this_algorithm and S2 CellID Format']
|
[source,title='xpin and S2 CellID Format']
|
||||||
----
|
----
|
||||||
=== this_algorithm Format ===
|
=== xpin Format ===
|
||||||
WORD2 (13 bits) : vvvvvvvvvvvvv
|
WORD2 (13 bits) : vvvvvvvvvvvvv
|
||||||
WORD1 (13 bits) : | |vvv vvvvvvvvvv
|
WORD1 (13 bits) : | |vvv vvvvvvvvvv
|
||||||
WORD0 (13 bits) : | | |vvvvvv vvvvvvv
|
WORD0 (13 bits) : | | |vvvvvv vvvvvvv
|
||||||
|
@ -64,7 +64,7 @@ For a detailed comparison, go link:https://wiki.openstreetmap.org/wiki/What3word
|
|||||||
[%header,cols="h,,,,"]
|
[%header,cols="h,,,,"]
|
||||||
|===
|
|===
|
||||||
|
|
|
|
||||||
|this_algorithm
|
|xpin
|
||||||
|link:https://what3words.com/[what3words^]
|
|link:https://what3words.com/[what3words^]
|
||||||
|link:https://xaddress.org/[Xaddress^]
|
|link:https://xaddress.org/[Xaddress^]
|
||||||
|link:https://maps.google.com/pluscodes/[Plus Codes^]/link:https://en.wikipedia.org/wiki/Open_Location_Code[Open Location Codes^]
|
|link:https://maps.google.com/pluscodes/[Plus Codes^]/link:https://en.wikipedia.org/wiki/Open_Location_Code[Open Location Codes^]
|
||||||
@ -84,8 +84,8 @@ m|849VCWC8+R9
|
|||||||
|Memorizable
|
|Memorizable
|
||||||
footnote:[This is subjective, of course. I am defining this to mean similar enough to an address, which I consider memorizable]
|
footnote:[This is subjective, of course. I am defining this to mean similar enough to an address, which I consider memorizable]
|
||||||
|Yes
|
|Yes
|
||||||
|Yes (is shorter than this_algorithm)
|
|Yes (is shorter than xpin)
|
||||||
|Yes (is shorter than this_algorithm)
|
|Yes (is shorter than xpin)
|
||||||
|No
|
|No
|
||||||
|
|
||||||
|Small wordlist
|
|Small wordlist
|
||||||
@ -516,13 +516,13 @@ Considerations when designing a wordlist:
|
|||||||
. Bad words/negative words (`DEATH` should probably be excluded)
|
. Bad words/negative words (`DEATH` should probably be excluded)
|
||||||
. Different languages (if the algorithm could ever made non-English)
|
. Different languages (if the algorithm could ever made non-English)
|
||||||
|
|
||||||
this_algorithm has a relatively small wordlist of length ~8192, so it is feasable to map all plural/singlar and homonym words to the same value, to prevent confusion.
|
xpin has a relatively small wordlist of length ~8192, so it is feasable to map all plural/singlar and homonym words to the same value, to prevent confusion.
|
||||||
|
|
||||||
NOTE: this_algorithm will disallow complex words, map homonyms and singular/plural words to the same value, and allow repition.
|
NOTE: xpin will disallow complex words, map homonyms and singular/plural words to the same value, and allow repition.
|
||||||
|
|
||||||
==== Wordlist
|
==== Wordlist
|
||||||
|
|
||||||
this_algorithm used link:https://github.com/hackerb9/gwordlist[hackerb9/gwordlist^] for the wordlist and associated frequencies.
|
xpin used link:https://github.com/hackerb9/gwordlist[hackerb9/gwordlist^] for the wordlist and associated frequencies.
|
||||||
Only the first few thousand words from `frequency-all.txt.gz` were used.
|
Only the first few thousand words from `frequency-all.txt.gz` were used.
|
||||||
|
|
||||||
==== Lemmatization
|
==== Lemmatization
|
||||||
@ -634,7 +634,7 @@ Sample source code:
|
|||||||
|
|
||||||
[source,rust]
|
[source,rust]
|
||||||
----
|
----
|
||||||
// Translating lat, lon to this_algorithm
|
// Translating lat, lon to xpin
|
||||||
|
|
||||||
impl<'a> From<&'a Point> for CellID {
|
impl<'a> From<&'a Point> for CellID {
|
||||||
fn from(p: &'a Point) -> Self {
|
fn from(p: &'a Point) -> Self {
|
||||||
@ -776,7 +776,7 @@ All interfaces *must* use minimum resources (network, CPU, RAM), so they can run
|
|||||||
|
|
||||||
.Some Ideas for Interfaces
|
.Some Ideas for Interfaces
|
||||||
. Command line
|
. Command line
|
||||||
** `this_algorithm -e -90,180` \=> `\...`
|
** `xpin -e -90,180` \=> `\...`
|
||||||
** Useful for developers, test data generation, etc.
|
** Useful for developers, test data generation, etc.
|
||||||
** Easiest to write
|
** Easiest to write
|
||||||
|
|
||||||
@ -790,7 +790,7 @@ All interfaces *must* use minimum resources (network, CPU, RAM), so they can run
|
|||||||
. Offline PWA
|
. Offline PWA
|
||||||
** Useful for smartphones
|
** Useful for smartphones
|
||||||
** Should work offline if possible, but also interface with Google Maps/JAWG/OSM if there is internet connectivity
|
** Should work offline if possible, but also interface with Google Maps/JAWG/OSM if there is internet connectivity
|
||||||
** Allows users to translate any link (Google Maps/OSM/Apple Maps) to this_algorithm as a share target
|
** Allows users to translate any link (Google Maps/OSM/Apple Maps) to xpin as a share target
|
||||||
|
|
||||||
. OSMAnd/Other existing mapping applications
|
. OSMAnd/Other existing mapping applications
|
||||||
* Requires input from these applications
|
* Requires input from these applications
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
|
|
||||||
== Description
|
== Description
|
||||||
|
|
||||||
The wordlist for this_algorithm begins with the wordlist from link:https://github.com/ps-kostikov/english-word-frequency/[ps-kostikov/english-word-frequency^] (link:https://github.com/ps-kostikov/english-word-frequency/blob/master/data/frequency_list.txt[data/frequency_list.txt^])
|
The wordlist for xpin begins with the wordlist from link:https://github.com/ps-kostikov/english-word-frequency/[ps-kostikov/english-word-frequency^] (link:https://github.com/ps-kostikov/english-word-frequency/blob/master/data/frequency_list.txt[data/frequency_list.txt^])
|
||||||
|
|
||||||
But this list is not sufficient.
|
But this list is not sufficient.
|
||||||
It contains profane, negative, or words otherwise unfit for this algorithm.
|
It contains profane, negative, or words otherwise unfit for this algorithm.
|
||||||
Because the wordlist required for this_algorithm is relatively small (8194), we can reduce this 53,000 word list substantially.
|
Because the wordlist required for xpin is relatively small (8194), we can reduce this 53,000 word list substantially.
|
||||||
|
|
||||||
== Processing
|
== Processing
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
:rouge-style: molokai
|
:rouge-style: molokai
|
||||||
:sectlinks:
|
:sectlinks:
|
||||||
|
|
||||||
= this_algorithm
|
= xpin
|
||||||
|
|
||||||
== Pages
|
== Pages
|
||||||
|
|
||||||
|
2
justfile
2
justfile
@ -12,7 +12,7 @@ rust-build:
|
|||||||
cargo build --all
|
cargo build --all
|
||||||
|
|
||||||
build-wasm:
|
build-wasm:
|
||||||
wasm-pack build --target web this_algorithm-wasm
|
wasm-pack build --target web xpin-wasm
|
||||||
|
|
||||||
js-build: build-wasm
|
js-build: build-wasm
|
||||||
yarn --cwd ./web-frontend/ build
|
yarn --cwd ./web-frontend/ build
|
||||||
|
@ -67,7 +67,7 @@ pub enum Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::doc_markdown)]
|
#[allow(clippy::doc_markdown)]
|
||||||
/// An encoded this_algorithm address
|
/// An encoded xpin address
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Address<'a> {
|
pub struct Address<'a> {
|
||||||
number: Number,
|
number: Number,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use common::test_events;
|
use common::test_events;
|
||||||
use s2::cellid::CellID;
|
use s2::cellid::CellID;
|
||||||
use this_algorithm::Error;
|
use xpin::Error;
|
||||||
use this_algorithm::{Address, CELLID_LEVEL};
|
use xpin::{Address, CELLID_LEVEL};
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod common;
|
mod common;
|
||||||
use common::approx_geodetic_difference_m;
|
use common::approx_geodetic_difference_m;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// use std::str::FromStr;
|
// use std::str::FromStr;
|
||||||
// use this_algorithm::Address;
|
// use xpin::Address;
|
||||||
mod common;
|
mod common;
|
||||||
// #[test]
|
// #[test]
|
||||||
// fn test_v0() {
|
// fn test_v0() {
|
||||||
|
@ -32,12 +32,12 @@
|
|||||||
Home
|
Home
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="/encode"
|
href="./encode"
|
||||||
class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
|
class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
|
||||||
>
|
>
|
||||||
Encode
|
Encode
|
||||||
</a>
|
</a>
|
||||||
<a href="/decode" class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white">
|
<a href="./decode" class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white">
|
||||||
Decode
|
Decode
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { WasmStatus } from '$lib/common.js';
|
import { WasmStatus } from '$lib/common.js';
|
||||||
import init, { address_from_lat_lon } from 'this_algorithm-wasm';
|
import init, { address_from_lat_lon } from 'xpin-wasm';
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
|
@ -4,5 +4,5 @@ import { defineConfig } from 'vite';
|
|||||||
import { VitePWA } from 'vite-plugin-pwa';
|
import { VitePWA } from 'vite-plugin-pwa';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [sveltekit(), wasmPack('../this_algorithm-wasm/'), VitePWA()]
|
plugins: [sveltekit(), wasmPack('../xpin-wasm/'), VitePWA()]
|
||||||
});
|
});
|
||||||
|
@ -8,5 +8,5 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = {version="0.5.0-rc.2", features=["json"]}
|
rocket = {version="0.5.0-rc.2", features=["json"]}
|
||||||
tokio = {version="1"}
|
tokio = {version="1"}
|
||||||
this_algorithm={path=".."}
|
xpin={path=".."}
|
||||||
serde = {version="1", features=["derive"]}
|
serde = {version="1", features=["derive"]}
|
||||||
|
@ -2,7 +2,7 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
use rocket::{get, routes, serde::json::Json, Responder};
|
use rocket::{get, routes, serde::json::Json, Responder};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use this_algorithm::Address;
|
use xpin::Address;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
@ -65,14 +65,14 @@ enum ApiError {
|
|||||||
InvalidRequest(&'static str),
|
InvalidRequest(&'static str),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&this_algorithm::Error> for ApiError {
|
impl From<&xpin::Error> for ApiError {
|
||||||
fn from(e: &this_algorithm::Error) -> Self {
|
fn from(e: &xpin::Error) -> Self {
|
||||||
Self::AlgorithmError(e.to_string())
|
Self::AlgorithmError(e.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<this_algorithm::Error> for ApiError {
|
impl From<xpin::Error> for ApiError {
|
||||||
fn from(e: this_algorithm::Error) -> Self {
|
fn from(e: xpin::Error) -> Self {
|
||||||
Self::from(&e)
|
Self::from(&e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "this_algorithm-wasm"
|
name = "xpin-wasm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@ -10,4 +10,4 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
this_algorithm = {path=".."}
|
xpin = {path=".."}
|
@ -1,9 +1,9 @@
|
|||||||
// import init, { log_to_address, greet } from "./pkg/this_algorithm_wasm.js";
|
// import init, { log_to_address, greet } from "./pkg/xpin_wasm.js";
|
||||||
// init().then(() => {
|
// init().then(() => {
|
||||||
// console.log(greet());
|
// console.log(greet());
|
||||||
// });
|
// });
|
||||||
|
|
||||||
import init, { address_from_lat_lon, address_to_lat_lon } from "./pkg/this_algorithm_wasm.js";
|
import init, { address_from_lat_lon, address_to_lat_lon } from "./pkg/xpin_wasm.js";
|
||||||
init().then(() => {
|
init().then(() => {
|
||||||
let updateEncode = () => {
|
let updateEncode = () => {
|
||||||
if (!encodeAddressLat.value || !encodeAddressLon.value) {
|
if (!encodeAddressLat.value || !encodeAddressLon.value) {
|
@ -10,16 +10,16 @@ use wasm_bindgen::prelude::*;
|
|||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn address_from_lat_lon(lat: f64, lon: f64) -> Result<String, String> {
|
pub fn address_from_lat_lon(lat: f64, lon: f64) -> Result<String, String> {
|
||||||
this_algorithm::Address::from_lat_lon(lat, lon)
|
xpin::Address::from_lat_lon(lat, lon)
|
||||||
.map(|a| a.to_string())
|
.map(|a| a.to_string())
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn address_to_lat_lon(addr_str: &str) -> Result<Vec<f64>, String> {
|
pub fn address_to_lat_lon(addr_str: &str) -> Result<Vec<f64>, String> {
|
||||||
this_algorithm::Address::from_str(addr_str)
|
xpin::Address::from_str(addr_str)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
.map(this_algorithm::Address::as_lat_lon)
|
.map(xpin::Address::as_lat_lon)
|
||||||
.map(|(lat, lon)| vec![lat, lon])
|
.map(|(lat, lon)| vec![lat, lon])
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user