-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
64 lines (64 loc) · 1.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<title>Text Analyzer - A online and web-based tool to analyze the words of an input string</title>
</head>
<body>
<center>
<h1>Text Analyzer</h1>
<h2>A online and web-based tool to analyze the words of an input string.</h2>
</center>
<br>
<b>Input:</b><br>
<textarea id="input" rows="15" cols="100"></textarea>
<br>
<b>Min Limit:</b><br>
<input id="minLimit" type="number" name="minLimit" value="5">
<br><br>
<button onclick="parse();">Parse</button>
<hr>
<table id="table" border="1"></table>
<script type="text/javascript">
let input=document.querySelector("#input");
let table=document.querySelector("#table");
let minLimit=document.querySelector("#minLimit");
function isInteger(data){
data = data +"e1";
var clean = parseInt(data,10) / data ;
return (data==0 ||clean && (data%1) === 0);
}
function parse() {
// \'
let string=input.value.replace(/[0-9]+:[0-9]+:[0-9]+(,[0-9]+|)/, "");
let words=string.split(/\s*(?:;|$|\s|\(|\)|>|<|—>|”|“|\"|\:|›|\.|\\|\/|,|\[|\]|–|=>|●|\||\?|=|-|\^)\s*/);
let minLimitValue=parseInt(minLimit.value);
// for(const word of words) {}
table.innerHTML="";
words=words.reduce((json,val)=>({...json,[val]:(json[val]|0)+1}),{});
// console.log(filters);
// console.log(typeof filters);
// for(const property in words) {
// if(words[property] >= minLimitValue) {
// table.innerHTML+="<tr><td>"+property+"</td><td>"+words[property]+"</td></tr>";
// }
// }
var sortables = [];
for(var x in words){
sortables.push([x, words[x]]);
}
sortables.sort(function(a, b) {
return b[1] - a[1];
});
console.log(sortables);
for(const sortable of sortables) {
console.log(sortable);
if(sortable[0] != "" && sortable[1] >= minLimitValue) {
if(!isInteger(sortable[0])) {
table.innerHTML+="<tr><td>"+sortable[0]+"</td><td>"+sortable[1]+"</td></tr>";
}
}
}
}
</script>
</body>
</html>