LAMPIRAN: KODE PROGRAM
1.
index.php
<html>
<title>Tampilan Awal Sistem</title> <table border = "0" width ="100%"> <tr>
<th valign = "top">
<!--Baca File PDF-->
<form action = "pdf.php" method="post" enctype="multipart/form-data" target="iframe1">
<center> PDF Uji :
<input type="file" class="form-control" id="inputFile" name="inputFile" placeholder="File">
<button type="submit" class="btn btn-default">Submit</button> <div class="container">
<iframe id="iframe1" name="iframe1"></iframe> </div>
</center> </form> </th> </tr>
<!--Cetak PDF Dari Iframe Ke Textarea--> <tr>
<form action = "hasil.php" method = "post"> <td valign = "top">
<button type = "button"
onclick="getIframeContent1('iframe1')">Cetak Teks PDF Uji</button><br><br>
<div class="container">
<textarea id="textarea1" name="textarea1"
onfocus="clearContents(this);" title= "Textarea Harus Diisi" required = "required">Input Teks Uji Secara Manual</textarea> </div>
</td> </tr>
<!—Tombol Proses Pendeteksian--> </table>
</html>
2.
pdf.php
<?php
header('Content-Type: text/html; charset=UTF-8');
include 'vendor/autoload.php';
$message = ''; $texts = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') { try {
$content = '';
if (isset($_FILES['inputFile']) && $_FILES['inputFile']['type'] == 'application/pdf') {
$content = file_get_contents($_FILES['inputFile']['tmp_name']); }
if ($content) {
$parser = new \Smalot\PdfParser\Parser(); $pdf = $parser->parseContent($content); $pages = $pdf->getPages();
foreach ($pages as $page) { $texts[] = $page->getText(); }
} else {
throw new Exception('Unable to retrieve content. Check if it is really a pdf file.');
}
} catch(Exception $e) { $message = $e->getMessage(); }
} ?>
<!--Membaca Isi PDF--> <html>
<?php if ($message): ?> <?php echo $message; ?> <?php endif; ?>
<?php if ($texts) : ?>
<?php foreach ($texts as $pos => $text) : ?> <?php echo $text; ?>
<?php endforeach; ?> <?php endif; ?> </html>
3.
stemming.php
<?php
include "koneksi.php";
//Cek Kata Dasar Dalam Database function cari($kata){
$hasil = mysql_num_rows(mysql_query("SELECT katadasar FROM tb_katadasar WHERE katadasar='$kata'"));
}
//1. Hapus Partikel : -kah, -lah, -tah, -pun function hapuspartikel($kata){
if(cari($kata) == 0){
if(substr($kata, -3) == 'kah' || substr($kata, -3) == 'lah' || substr($kata, -3) == 'pun' || substr($kata, -3) == 'tah'){ $kata1 = substr($kata, 0, -3);
$ak1 = hapusakhiran(hapusawalan2(hapusawalan1(hapuspp($kata1)))); if(cari($ak1) != 0){
$kata = $kata1; }
else{ $kata; } } else{ $kata; } } else{ $kata; }
return $kata; }
//2. Hapus Kata Ganti Orang : -ku, -mu, -nya
//3. Hapus Awalan1 :
//4. Hapus Awalan2 :
//5. Hapus Akhiran : -i, -kan, -an
?>
4.
hasil.php
<html>
<title>Tampilan Hasil Sistem</title>
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_STRICT)); include_once 'stemming.php';
include 'koneksi.php';
//Waktu Mulai Eksekusi $mtime = microtime();
$mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime;
//Nilai N-Gram Dan Modulo $k = $_POST['n-gram']; $mdl = 1;
//Proses Teks Uji :
$txt1a = strtolower($txt1);
$txta = preg_replace('#[^a-zA-Z0-9 ]#', ' ', $txt1a);
//1a. Stemming
$d1 = explode(" ", $txta); $counta = count($d1);
for($ij=0;$ij<$counta;$ij++){
//2a. Sinonim
$st4 = explode(" ", $st3); $countb = count($st4); for($i=0;$i<$countb;$i++){
$a = mysql_query("select * from tb_katasinonim where sinonim = '$st4[$i]'");
$b = mysql_fetch_array($a); if($b){
$r = $b[katasinonim]; }
else{
$r = $st4[$i]; }
$r3 = $r3.$r." ";
//Menghapus string yang hanya memiliki panjang < 4 if(strlen($r) > 3){
$r3a = $r3a.$r." "; }
$r3b = $r3a; }
//Algoritma Manber
//3a. Hapus Whitespace
$r1 = preg_replace("/[^A-Za-z0-9]/", '', $r3b);
//4a. N-Gram
$x = strlen($r1); for($j=0;$j<$x;$j++){ $z = substr($r1,0+$j,$k);
$p111 = $p111.$p1." "; }
}
//6a. Fingerprint $o = $x - ($k - 1); for($h=0;$h<$o;$h++){ $mod1 = $p11[$h] % $mdl; if($mod1 == 0){
$array1 = $p11[$h]." "; $array12 = $array12.$array1; $array11[] = $array1;
$co1 = $co1 + 1; }
}
for ($ii = 0; $ii < $len; $ii++) { $arr1 = $array11[$ii]." ";
$arr11 = $arr11.$arr1; $arr111[] = $arr1; }
//7. Persamaan Jaccard Coefficient $hasil = round($xx / ($xyz) * 100 , 2);
//Waktu Eksekusi Sistem $mtime = microtime();
$mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime;
$totaltime = round($endtime - $starttime , 3);
echo "<br><br>Waktu Proses Pendeteksian ".$totaltime." detik";