Skip to content

Commit

Permalink
reverse not working yet
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Jan 24, 2023
1 parent d7afe8d commit 885d92f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
13 changes: 6 additions & 7 deletions scratch.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { learn, reverse, test, compress, uncompress, classify, fingerprint, tiny, pack, unpack } from './src/index.js'
import data from '/Users/spencer/mountain/it-compromise/data/models/verbs/conditional.js'
import { learn, reverse, test, compress, uncompress } from './src/index.js'
import data from '/Users/spencer/mountain/suffix-thumb/test/data/future-simple.js'

// let pairs = Object.keys(data).map(k => [k, data[k][0]])
let pairs = Object.keys(data).map(k => [data[k][0], k])//.slice(0, 200)
let pairs = data//Object.keys(data).map(k => [data[k][0], k])//.slice(0, 200)
// pairs = [
// ['sottomettere', 'sottometterei'],
// ['teletrasmettere', 'teletrasetterei'],
// // ['tramettere', 'trametterei'],
// // ['trasmettere', 'trasmetterei']
// ]

// console.log(compress(learn(pairs)))
let res = tiny(pairs)
let res = learn(pairs)
console.log(res)
console.log('\n\n')
let small = pack(res)
let small = compress(res)
console.log(small)
let again = unpack(small)
let again = uncompress(small)
test(pairs, again)

// { ei: 'e' },
Expand Down
21 changes: 11 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import convert from './convert/index.js'
import compress from './compress/index.js'
import uncompress from './compress/uncompress.js'
import convert from './tiny/convert.js'
// import compress from './compress/index.js'
// import uncompress from './compress/uncompress.js'
import reverse from './reverse/index.js'
// import test from './test/index.js'
import learn from './learn/index.js'
// import old from './learn/index.js'
import validate from './validate/index.js'
import classify from './classify/index.js'
import fingerprint from './fingerprint/index.js'
import tiny from './tiny/index.js'
// import classify from './classify/index.js'
// import fingerprint from './fingerprint/index.js'

import learn from './tiny/index.js'
import compress from './pack/pack.js'
import uncompress from './pack/unpack.js'
import test from './tiny/test.js'
import pack from './pack/pack.js'
import unpack from './pack/unpack.js'


export { learn, convert, compress, uncompress, reverse, validate, test, classify, fingerprint, tiny, pack, unpack }
export { learn, convert, compress, uncompress, reverse, validate, test }
4 changes: 3 additions & 1 deletion src/pack/unpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ const expand = function (key = '', val = '') {
return full
}

const unpack = function (str) {
const unpack = function (str = '') {
let out = { rules: [], exceptions: {} }
let [rules, exceptions] = str.split('==')
// unpack rules
rules = rules || ''
rules.split(',').forEach(txt => {
let [a, b] = txt.split(':')
let len = a.length
Expand All @@ -30,6 +31,7 @@ const unpack = function (str) {
}

// unpack exceptions
exceptions = exceptions || ''
exceptions.split(',').forEach(txt => {
let [a, b] = txt.split(':')
out.exceptions[a] = expand(a, b)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('find best rule', function (t) {
['endeavouring', 'endeavour']
]
let model = learn(arr)
t.equal(model.rules.g.length, 1, 'one-rule')
t.equal(model.rules[3].ing, '', 'one-rule')
t.equal(Object.keys(model.exceptions).length, 0, 'no-exceptions')
t.end()
})

0 comments on commit 885d92f

Please sign in to comment.