-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokenisasi-result.php
114 lines (96 loc) · 3.47 KB
/
tokenisasi-result.php
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="en" class="h-100" id ="html">
<head>
<meta charset="utf-8" />
<title>
Pemrosesan Teks
</title>
<!--Fonts and icons-->
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
<!-- CSS Files -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body class="h-100 w-100 bg-light">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="tokenisasi.php">Tokenisasi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="stopwordsremoval.php">Stopwords Removal</a>
</li>
<li class="nav-item">
<a class="nav-link" href="stemming.php">Stemming</a>
</li>
<li class="nav-item">
<a class="nav-link" href="indexing.php">Indexing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="preprocessing.php">Preprocessing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="query.php">Query</a>
</li>
<li class="nav-item">
<a class="nav-link" href="vsm.php">Vector Space Model</a>
</li>
</ul>
</div>
</nav>
<div class="p-5">
<table class='table table-hover'>
<?php
// tidak menampilkan error dan warning pada PHP
error_reporting(0);
// mengambil data dari page sebelumnya dengan metode POST
$dokumen = $_POST['dokumen'];
// insialisasi
$tokenisasi_result = array();
// nama kolom
echo "<thead>";
for($col = 1; $col <= count($dokumen); $col++){
echo "<th class='font-weight-bold p-3 text-center text-dark'>Dokumen $col</th>";
}
echo "</thead>";
// tokenisasi
$length = 0;
for ($row = 1; $row <= count($dokumen); $row++){
$temp = $dokumen[$row];
// lowercase
$temp = strtolower($temp);
// hapus tanda baca
$temp = str_replace(',', '', $temp);
$temp = str_replace('.', '', $temp);
$temp = str_replace('!', '', $temp);
$temp = str_replace('?', '', $temp);
// memecah string menjadi array dengan regex " " (spasi)
$result = explode(" ", $temp);
$tokenisasi_result[$row] = explode(" ", $temp);
// menghitung jumlah data yang akan ditampikan
if(count($result) > $length){
$length = count($result);
}
}
// menampilkan data
for ($row = 0; $row < $length; $row++){
echo "<tr>";
for ($col = 1; $col <= count($dokumen); $col++){
try {
echo "<td class='p-3 text-center'>".strval($tokenisasi_result[$col][$row])."</td>";
}
catch (Exception $e) {
}
}
echo "</tr>";
}
echo "</tbody></table>";
?>
<a href="index.php" class="btn btn-warning" style="text-decoration:none;">Kembali ke Halaman Utama</a>
</div>
</body>
</html>