Rename this_algorithm to xpin

This commit is contained in:
Austen Adler 2023-03-02 18:55:40 -05:00
parent 931835904e
commit 06506def20
20 changed files with 59 additions and 59 deletions

40
Cargo.lock generated
View File

@ -1317,25 +1317,6 @@ dependencies = [
"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]]
name = "thiserror"
version = "1.0.38"
@ -1666,8 +1647,8 @@ version = "0.1.0"
dependencies = [
"rocket",
"serde",
"this_algorithm",
"tokio",
"xpin",
]
[[package]]
@ -1827,6 +1808,25 @@ dependencies = [
"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]]
name = "yansi"
version = "0.5.1"

View File

@ -1,5 +1,5 @@
[package]
name = "this_algorithm"
name = "xpin"
version = "0.1.0"
edition = "2021"
@ -7,7 +7,7 @@ edition = "2021"
members = [
".",
"./words",
"./this_algorithm-wasm/",
"./xpin-wasm/",
"./web",
]

View File

@ -6,4 +6,4 @@
:rouge-style: molokai
:sectlinks:
= this_algorithm
= xpin

View File

@ -16,9 +16,9 @@ If you want to see the steps to get to this definition, go to link:DESIGN.html[D
== 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
WORD1 (13 bits) : | |vvv vvvvvvvvvv
WORD0 (13 bits) : | | |vvvvvv vvvvvvv

View File

@ -64,7 +64,7 @@ For a detailed comparison, go link:https://wiki.openstreetmap.org/wiki/What3word
[%header,cols="h,,,,"]
|===
|
|this_algorithm
|xpin
|link:https://what3words.com/[what3words^]
|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^]
@ -84,8 +84,8 @@ m|849VCWC8+R9
|Memorizable
footnote:[This is subjective, of course. I am defining this to mean similar enough to an address, which I consider memorizable]
|Yes
|Yes (is shorter than this_algorithm)
|Yes (is shorter than this_algorithm)
|Yes (is shorter than xpin)
|Yes (is shorter than xpin)
|No
|Small wordlist
@ -516,13 +516,13 @@ Considerations when designing a wordlist:
. Bad words/negative words (`DEATH` should probably be excluded)
. 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
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.
==== Lemmatization
@ -634,7 +634,7 @@ Sample source code:
[source,rust]
----
// Translating lat, lon to this_algorithm
// Translating lat, lon to xpin
impl<'a> From<&'a Point> for CellID {
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
. Command line
** `this_algorithm -e -90,180` \=> `\...`
** `xpin -e -90,180` \=> `\...`
** Useful for developers, test data generation, etc.
** Easiest to write
@ -790,7 +790,7 @@ All interfaces *must* use minimum resources (network, CPU, RAM), so they can run
. Offline PWA
** Useful for smartphones
** 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
* Requires input from these applications

View File

@ -11,11 +11,11 @@
== 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.
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

View File

@ -6,7 +6,7 @@
:rouge-style: molokai
:sectlinks:
= this_algorithm
= xpin
== Pages

View File

@ -12,7 +12,7 @@ rust-build:
cargo build --all
build-wasm:
wasm-pack build --target web this_algorithm-wasm
wasm-pack build --target web xpin-wasm
js-build: build-wasm
yarn --cwd ./web-frontend/ build

View File

@ -67,7 +67,7 @@ pub enum Error {
}
#[allow(clippy::doc_markdown)]
/// An encoded this_algorithm address
/// An encoded xpin address
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Address<'a> {
number: Number,

View File

@ -1,7 +1,7 @@
use common::test_events;
use s2::cellid::CellID;
use this_algorithm::Error;
use this_algorithm::{Address, CELLID_LEVEL};
use xpin::Error;
use xpin::{Address, CELLID_LEVEL};
#[macro_use]
mod common;
use common::approx_geodetic_difference_m;

View File

@ -1,5 +1,5 @@
// use std::str::FromStr;
// use this_algorithm::Address;
// use xpin::Address;
mod common;
// #[test]
// fn test_v0() {

View File

@ -32,12 +32,12 @@
Home
</a>
<a
href="/encode"
href="./encode"
class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4"
>
Encode
</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
</a>
</div>

View File

@ -1,6 +1,6 @@
<script>
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 { browser } from '$app/environment';

View File

@ -4,5 +4,5 @@ import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
export default defineConfig({
plugins: [sveltekit(), wasmPack('../this_algorithm-wasm/'), VitePWA()]
plugins: [sveltekit(), wasmPack('../xpin-wasm/'), VitePWA()]
});

View File

@ -8,5 +8,5 @@ edition = "2021"
[dependencies]
rocket = {version="0.5.0-rc.2", features=["json"]}
tokio = {version="1"}
this_algorithm={path=".."}
xpin={path=".."}
serde = {version="1", features=["derive"]}

View File

@ -2,7 +2,7 @@ use std::str::FromStr;
use rocket::{get, routes, serde::json::Json, Responder};
use serde::{Deserialize, Serialize};
use this_algorithm::Address;
use xpin::Address;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@ -65,14 +65,14 @@ enum ApiError {
InvalidRequest(&'static str),
}
impl From<&this_algorithm::Error> for ApiError {
fn from(e: &this_algorithm::Error) -> Self {
impl From<&xpin::Error> for ApiError {
fn from(e: &xpin::Error) -> Self {
Self::AlgorithmError(e.to_string())
}
}
impl From<this_algorithm::Error> for ApiError {
fn from(e: this_algorithm::Error) -> Self {
impl From<xpin::Error> for ApiError {
fn from(e: xpin::Error) -> Self {
Self::from(&e)
}
}

View File

@ -1,5 +1,5 @@
[package]
name = "this_algorithm-wasm"
name = "xpin-wasm"
version = "0.1.0"
edition = "2021"
@ -10,4 +10,4 @@ crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2"
this_algorithm = {path=".."}
xpin = {path=".."}

View File

@ -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(() => {
// 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(() => {
let updateEncode = () => {
if (!encodeAddressLat.value || !encodeAddressLon.value) {

View File

@ -10,16 +10,16 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen]
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_err(|e| e.to_string())
}
#[wasm_bindgen]
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()
.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])
}