edf2csv 0.7.249 → 0.7.251
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -26
- package/dist/cli.js.map +1 -1
- package/dist/convert/channels.js +1 -22
- package/dist/convert/channels.js.map +1 -1
- package/dist/convert/timing.js +6 -1
- package/dist/convert/timing.js.map +1 -1
- package/dist/format/distance.d.ts +23 -0
- package/dist/format/distance.js +42 -0
- package/dist/format/distance.js.map +1 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -26,6 +26,7 @@ import { TimeRangeError, parseTimeSpec } from './convert/time-range.js';
|
|
|
26
26
|
import { deriveRecordStarts, withTimingPromiseKept } from './convert/timing.js';
|
|
27
27
|
import { formatDiagnostics, formatInfo, infoJson, formatSummary, printable, printableLines, summaryJson, wrap } from './cli/report.js';
|
|
28
28
|
import { counted, listed } from './format/list.js';
|
|
29
|
+
import { editDistance } from './format/distance.js';
|
|
29
30
|
import { VERSION } from './version.js';
|
|
30
31
|
const USAGE = `edf2csv ${VERSION}
|
|
31
32
|
Convert EDF, EDF+ and BDF recordings to CSV
|
|
@@ -2072,32 +2073,6 @@ function usageMessage(error, argv) {
|
|
|
2072
2073
|
`flag rather than as its value.\n` +
|
|
2073
2074
|
` Write it as one argument instead: ${typeable}`);
|
|
2074
2075
|
}
|
|
2075
|
-
/**
|
|
2076
|
-
* Edit distance counting a swap of two adjacent characters as one edit, not two.
|
|
2077
|
-
*
|
|
2078
|
-
* Damerau's restricted form, which needs the row two back and so keeps three rather than the
|
|
2079
|
-
* two plain Levenshtein needs. Twenty names of under twenty characters, so the extra row costs
|
|
2080
|
-
* nothing worth measuring.
|
|
2081
|
-
*/
|
|
2082
|
-
function editDistance(a, b) {
|
|
2083
|
-
let twoBack = [];
|
|
2084
|
-
let previous = Array.from({ length: b.length + 1 }, (_unused, i) => i);
|
|
2085
|
-
for (let i = 1; i <= a.length; i++) {
|
|
2086
|
-
const current = new Array(b.length + 1).fill(0);
|
|
2087
|
-
current[0] = i;
|
|
2088
|
-
for (let j = 1; j <= b.length; j++) {
|
|
2089
|
-
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
2090
|
-
let best = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost);
|
|
2091
|
-
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
2092
|
-
best = Math.min(best, twoBack[j - 2] + 1);
|
|
2093
|
-
}
|
|
2094
|
-
current[j] = best;
|
|
2095
|
-
}
|
|
2096
|
-
twoBack = previous;
|
|
2097
|
-
previous = current;
|
|
2098
|
-
}
|
|
2099
|
-
return previous[b.length];
|
|
2100
|
-
}
|
|
2101
2076
|
/**
|
|
2102
2077
|
* The option they probably meant, or null when nothing is close enough to say.
|
|
2103
2078
|
*
|