• Tidak ada hasil yang ditemukan

Deteksi Kemiripan Dokumen Teks Menggunakan Algoritma Manber

N/A
N/A
Protected

Academic year: 2017

Membagikan "Deteksi Kemiripan Dokumen Teks Menggunakan Algoritma Manber"

Copied!
5
0
0

Teks penuh

(1)

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

(2)

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'"));

(3)

}

//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 :

(4)

$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);

(5)

$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";

Referensi

Dokumen terkait

KOTA : SURABAYA LAMPIRAN : KEPUTUSAN KEPALA DINAS PENDIDIKAN KOTA SURABAYA.. NOMOR RAYON : 01

Here we describe our 2-stage algorithm for generating DTMs from DSMs. The complete work flow is presented in Figure 1. The data used for developing and testing the algorithm

SISA LEBIH YANG DITERIMA ATAU DIPEROLEH BADAN ATAU LEMBAGA NIRLABA YANG BERGERAK DALAM BIDANG PENDIDIKAN DAN/ATAU BIDANG PENELITIAN DAN PENGEMBANGAN, YANG TELAH TERDAFTAR

Specifically, terrestrial laser scanning (TLS) collects high resolution 3D point clouds allowing more accurate monitoring of erosion rates and processes, and thus, quantify the

Berikut catatan-catatan khusus yang kami buat untuk mendukung bahwa transaksi yang dilakukan dengan pihak yang mempunyai hubungan istimewa telah sesuai dengan prinsip kewajaran (

83/POKJA/ULP/VII/2015 tertanggal 6 Juli 2015 perihal Undangan Pembuktian Kualifikasi, pada Surat Tertulis Undangan Pembuktian Kualifikasi Pekerjaan Perencanaan

Saya telah diminta untuk berpartisipasi dalam penelitian ini sesuai dengan.. judul

The existence of the college as a center of the creation for various sciences are a particular challenge for the management to manage the knowledge optimally. Knowledges