Spaces:
Running
Running
Download lib/util.js from lkmill/edan20-assignment3: direct link, hf CLI and curl.
- Browser
- Download file 447 Bytes
-
https://huggingface.co/spaces/lkmill/edan20-assignment3/resolve/main/lib/util.js
- Command line
-
hf download hf://spaces/lkmill/edan20-assignment3/lib/util.js
-
curl -L -o util.js https://huggingface.co/spaces/lkmill/edan20-assignment3/resolve/main/lib/util.js
447 Bytes
| /** | |
| * corpus_raw = f.read().strip() | |
| * corpus = '▁' + re.sub(r'\s+', '▁', corpus_raw) | |
| * | |
| * @param {string} corpus | |
| */ | |
| export function preprocess(corpus) { | |
| return '▁' + corpus.trim().replaceAll(/\s+/g, '▁') | |
| } | |
| /** | |
| * def initial_vocabulary(corpus_l): | |
| * return sorted(set(corpus_l)) | |
| * | |
| * @param {string} corpus | |
| * @returns {string[]} | |
| */ | |
| export function getInitialVocabulary(corpus) { | |
| return Array.from(new Set(corpus)).sort() | |
| } | |