Add support for background tokenizing
This commit is contained in:
parent
971b96c132
commit
1683f3e90f
6 changed files with 196 additions and 9 deletions
39
experiments/tokenizer.html
Normal file
39
experiments/tokenizer.html
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>BackgroundTokenizer</title>
|
||||
<meta name="author" content="Fabian Jakobs">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<textarea id="text"></textarea>
|
||||
<input type="button" value="tokenize" id="go">
|
||||
|
||||
<script src="../BackgroundTokenizer.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var button = document.getElementById("go");
|
||||
var text = document.getElementById("text");
|
||||
|
||||
button.onclick = function()
|
||||
{
|
||||
var onComplete = function() {
|
||||
console.log("complete");
|
||||
};
|
||||
|
||||
var onUpdate = function(firstLine, lastLine) {
|
||||
console.log("update", firstLine, lastLine);
|
||||
};
|
||||
|
||||
var tokenizer = new BackgroundTokenizer(onUpdate, onComplete);
|
||||
tokenizer.setLines(text.value.split(/[\n\r]/));
|
||||
tokenizer.start();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue