add docs/ symlink

This commit is contained in:
Moos 2019-05-31 05:33:26 -07:00
parent 55319a6a15
commit 5a625ff49d
3 changed files with 137 additions and 0 deletions

53
docs/cdn/index.html Normal file
View File

@ -0,0 +1,53 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="script-src https: http: 'unsafe-inline' 'unsafe-eval'">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" />
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/javascript.min.js"></script>
<!-- cdn source -->
<script src="https://unpkg.com/wordpos@2.0.0-beta/dist/wordpos.min.js"></script>
<script>
let wordpos = window.wordpos = new WordPOS({
// preload: true,
dictPath: 'https://unpkg.com/wordpos@2.0.0-beta/dict',
profile: true,
// stopwords: false
});
</script>
<script src="../main.js" name="main"></script>
<style>
pre {
padding: 2em;
display: block;
}
</style>
</head>
<body>
<h1>CDN WordPOS sample</h1>
Open console to see results.
<pre><code> </code></pre>
<script>
var el = document.querySelector('code');
if (fetch) {
fetch('../main.js')
.then(res => res.text())
.then(txt => {
el.innerText = txt;
window.hljs && hljs.initHighlightingOnLoad();
});
} else {
el.innerHTML = 'Open <a href="../main.js">main.js</a>.';
}
</script>
</body>
</html>

32
docs/main.js Normal file
View File

@ -0,0 +1,32 @@
let assertLikely = (r) => {
console.assert(r.def === 'with considerable certainty');
console.assert(r.pos === 'r');
console.assert(r.synsetOffset === '00139421');
};
console.group('Likely');
wordpos.isAdverb('likely').then(res => console.assert(res));
wordpos.isAdverb('likely', (res, ...profile) => console.log('callback with profile', res, profile));
wordpos.getAdverbs('this is is lately a likely tricky business this is')
.then(res => {
let expect = {lately: 1, likely: 1};
console.log('getAdverbs:', res);
console.assert(res[0] in expect); // NOTE: order is NOT gauranteed!
console.assert(res[1] in expect);
});
wordpos.lookupAdverb('likely')
.then(res => {
console.log('lookupAdverb:', res[0]);
assertLikely(res[0]);
});
// wordpos.lookup('likely').then(res, console.log('lookup ===', res))
wordpos.seek('00139421', 'r')
.then(res => {
console.log('seek:', res);
assertLikely(res);
});
setTimeout(() => console.groupEnd('Likely'), 1000);

View File

@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="script-src https: http: 'unsafe-inline' 'unsafe-eval'">
<title>Wordpos in the browser</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" />
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/javascript.min.js"></script>
<script src="/dist/wordpos.min.js"></script>
<script>
let wordpos = window.wordpos = new WordPOS({
// preload: true,
dictPath: '/samples/self-hosted/dict',
profile: true,
// stopwords: false
});
</script>
<script src="../main.js" name="main"></script>
<style>
pre {
padding: 2em;
display: block;
}
</style>
</head>
<body>
<h1>Self-hosted WordPOS sample</h1>
Open console to see results.
<pre><code> </code></pre>
<script>
var el = document.querySelector('code');
if (fetch) {
fetch('../main.js')
.then(res => res.text())
.then(txt => {
el.innerText = txt;
window.hljs && hljs.initHighlightingOnLoad();
});
} else {
el.innerHTML = 'Open <a href="../main.js">main.js</a>.';
}
</script>
</body>
</html>