-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathngram.html
More file actions
71 lines (59 loc) · 1.6 KB
/
ngram.html
File metadata and controls
71 lines (59 loc) · 1.6 KB
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
65
66
67
68
69
70
71
<html>
<head>
<input type="file" id="fileinput" />
<script type="text/javascript">
function readSingleFile(evt) {
var f = evt.target.files[0];
if (f) {
//alert(" file1");
var r = new FileReader();
r.onload = function(e) {
var contents = e.target.result;
var ct = r.result.toLowerCase();
var words = ct.split(' ');
//alert("file2");
var feature = prompt('Enter text here');
//alert(inputVal);
var arr1=[];
for(i=0;i<words.length;i++)
{
if(words[i]==feature)
{ if(words[i+1]!=' ' && words[i+2]!=' '){
arr1.push(words[i]+' '+words[i+1]+' '+words[i+2]);}
if(words[i-2]!=' ' && words[i-1]!=' '){
arr1.push(words[i-2]+' '+words[i-1]+' '+words[i]);}
}
}
len = arr1.length;
if(arr1.length>0)
{
for ( n = 0; n < len; n++) {
document.getElementById("demo").innerHTML += (n+1).toString()+')'+' '+arr1[n]+"<br>";
}
}
else
{
alert("No feature present as per your input");
}
}
r.readAsText(f);
}
else {
alert("Failed to load file");
}
//document.getElementById("demo").innerHTML = arr1[0];
}
document.getElementById('fileinput').addEventListener('change', readSingleFile, false);
</script>
</head>
<body>
<center><h1>Welcome to Feature extraction</h1>
<p>1) Load the file</p>
<p>2) Enter the feature that needs to extracted in promt window</p> </center>
<div id="res">
Output
</div>
<p>Extracted feature</p>
<p id="demo">....<br></p>
</body>
</html>