Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Astro36 committed Jun 17, 2018
1 parent 7f47d94 commit 87c9e3b
Show file tree
Hide file tree
Showing 9 changed files with 1,157,796 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ typings/
news/
temp/
words.csv
!docs/words.csv
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<section class="container">
<h1>KokoaNLP Demo</h1>
<h4>Unsupervised Learning Korean Kernel Object Analyzer</h4>
<h5 id="load-progress">Loading: 0%</h5>
</section>
</header>
<section class="container">
Expand Down
89 changes: 65 additions & 24 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,74 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */

const { Kokoa, KokoaUtil } = require('../lib');

const kokoa = new Kokoa();
const util = new KokoaUtil(kokoa);

console.log(util.words('태평양 전쟁 개전 당시 일본 해군의 전략은 외곽 방어망 곳곳에 배치된 지상비행장이 방어의 근거지가 되고 유사시 적을 방어선 가까이 끌어들이는 동안 항공기를 집결하여 격퇴하는 것이었다.'));

const elementProgress = document.getElementById('load-progress');
const elementRun = document.getElementById('run');
const elementContent = document.getElementById('content');
const elementKeywords = document.getElementById('keywords');
const elementKeysentences = document.getElementById('keysentences');
const elementWords = document.getElementById('words');

elementRun.addEventListener('click', () => {
const content = elementContent.value;
const keywords = util.keywords(content);
const keysentences = util.keysentences(content);
const words = util.words(content);
elementKeywords.innerHTML = '';
keywords.forEach((keyword) => {
const list = document.createElement('li');
list.innerHTML = keyword;
elementKeywords.appendChild(list);
});
elementKeysentences.innerHTML = '';
keysentences.forEach((keysentence) => {
const list = document.createElement('li');
list.innerHTML = keysentence;
elementKeysentences.appendChild(list);
});
elementWords.textContent = words.join('/');
});
const request = new XMLHttpRequest();
request.open('GET', './words.csv', true);
request.onerror = () => {
elementProgress.textContent = 'Load Error';
};
request.onprogress = (event) => {
elementProgress.textContent = `Loading: ${((event.loaded / event.total) * 100).toFixed(2)}%`;
};
request.onreadystatechange = () => {
if (request.readyState === 4) {
if (request.status === 200) {
// Load prebuilt data.
const originalFrequencies = [];
const originalScores = [];
const reversedFrequencies = [];
const reversedScores = [];
let isOriginal = true;
request.responseText.split('\n').forEach((value) => {
if (value === '---') {
isOriginal = false;
} else {
const [text, frequency, score] = value.split(',');
if (isOriginal) {
originalFrequencies.push([text, Number(frequency)]);
originalScores.push([text, Number(score)]);
} else {
reversedFrequencies.push([text, Number(frequency)]);
reversedScores.push([text, Number(score)]);
}
}
});

// Init KokoaNLP.
const model = {
originalFrequencies,
originalScores,
reversedFrequencies,
reversedScores,
};
const kokoa = new Kokoa(model);
const util = new KokoaUtil(kokoa);
elementRun.addEventListener('click', () => {
const content = elementContent.value;
const keywords = util.keywords(content);
const keysentences = util.keysentences(content);
const words = util.words(content);
elementKeywords.innerHTML = '';
keywords.forEach((keyword) => {
const list = document.createElement('li');
list.innerHTML = keyword;
elementKeywords.appendChild(list);
});
elementKeysentences.innerHTML = '';
keysentences.forEach((keysentence) => {
const list = document.createElement('li');
list.innerHTML = keysentence;
elementKeysentences.appendChild(list);
});
elementWords.textContent = words.join('/');
});
}
}
};
request.send(null);
2 changes: 1 addition & 1 deletion docs/demo.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="description" content="Korean Kernel Object Analyzer"> <meta name="keywords" content="Kokoa,KokoaNLP,Korean,Alphabet,Hangul,Analyzer"> <meta name="author" content="Seungjae Park"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic"> <link rel="stylesheet" href="https://cdn.rawgit.com/necolas/normalize.css/master/normalize.css"> <link rel="stylesheet" href="https://cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css"> <link rel="stylesheet" href="main.3e812b6c.css"> <title>KokoaNLP Demo</title> </head> <body> <aside> <a href="https://github.com/Astro36/Kokoa" class="github-corner" aria-label="View source on Github"> <svg width="80" height="80" viewbox="0 0 250 250" fill="#795548" color="#fff" style="position:absolute;top:0;border:0;right:0" aria-hidden="true"> <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path> <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin:130px 106px" class="octo-arm"></path> <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path> </svg> </a> </aside> <main> <header class="header"> <section class="container"> <h1>KokoaNLP Demo</h1> <h4>Unsupervised Learning Korean Kernel Object Analyzer</h4> </section> </header> <section class="container"> <h3>Input</h3> <form> <fieldset> <div class="float-right"> <input class="button" id="run" type="button" value="Run"> </div> <label for="content">Content</label> <textarea placeholder="Input" id="content" style="height:200px"></textarea> </fieldset> </form> <h3>Output</h3> <h4>Keywords</h4> <ul id="keywords"></ul> <h4>Keysentences</h4> <ul id="keysentences"></ul> <h4>Words</h4> <p id="words" style="overflow-y:scroll;max-height:200px"></p> <p>주의: 이 데모는 Chrome 67에서 테스트 되었습니다. 문제가 발생한다면 브라우저를 최신 버전으로 업데이트하십시오. <br>Internet Explore는 지원하지 않습니다.</p> </section> <footer class="footer"> <section class="container"> <p>ⓒ 2018 Seungjae Park. All rights reserved.</p> </section> </footer> </main> <script src="main.117d95c1.js"></script> </body> </html>
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="description" content="Korean Kernel Object Analyzer"> <meta name="keywords" content="Kokoa,KokoaNLP,Korean,Alphabet,Hangul,Analyzer"> <meta name="author" content="Seungjae Park"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic"> <link rel="stylesheet" href="https://cdn.rawgit.com/necolas/normalize.css/master/normalize.css"> <link rel="stylesheet" href="https://cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css"> <link rel="stylesheet" href="main.bcc068a2.css"> <title>KokoaNLP Demo</title> </head> <body> <aside> <a href="https://github.com/Astro36/Kokoa" class="github-corner" aria-label="View source on Github"> <svg width="80" height="80" viewbox="0 0 250 250" fill="#795548" color="#fff" style="position:absolute;top:0;border:0;right:0" aria-hidden="true"> <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path> <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin:130px 106px" class="octo-arm"></path> <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path> </svg> </a> </aside> <main> <header class="header"> <section class="container"> <h1>KokoaNLP Demo</h1> <h4>Unsupervised Learning Korean Kernel Object Analyzer</h4> <h5 id="load-progress">Loading: 0%</h5> </section> </header> <section class="container"> <h3>Input</h3> <form> <fieldset> <div class="float-right"> <input class="button" id="run" type="button" value="Run"> </div> <label for="content">Content</label> <textarea placeholder="Input" id="content" style="height:200px"></textarea> </fieldset> </form> <h3>Output</h3> <h4>Keywords</h4> <ul id="keywords"></ul> <h4>Keysentences</h4> <ul id="keysentences"></ul> <h4>Words</h4> <p id="words" style="overflow-y:scroll;max-height:200px"></p> <p>주의: 이 데모는 Chrome 67에서 테스트 되었습니다. 문제가 발생한다면 브라우저를 최신 버전으로 업데이트하십시오. <br>Internet Explore는 지원하지 않습니다.</p> </section> <footer class="footer"> <section class="container"> <p>ⓒ 2018 Seungjae Park. All rights reserved.</p> </section> </footer> </main> <script src="main.6cbe1a7e.js"></script> </body> </html>
Loading

0 comments on commit 87c9e3b

Please sign in to comment.