Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>E-Learning | Tambah Data Operator</title>
- <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
- <!-- bootstrap 3.0.2 -->
- <link href="http://localhost/e-learning/c-panel/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
- <!-- font Awesome -->
- <link href="http://localhost/e-learning/c-panel/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
- <!-- Ionicons -->
- <link href="http://localhost/e-learning/c-panel/css/ionicons.min.css" rel="stylesheet" type="text/css" />
- <!-- Theme style -->
- <link href="http://localhost/e-learning/c-panel/css/AdminLTE.css" rel="stylesheet" type="text/css" />
- <link href="http://localhost/e-learning/c-panel/css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" />
- </head>
- <body class="skin-blue">
- <!-- header logo: style can be found in header.less -->
- <?php
- $droot = $_SERVER['DOCUMENT_ROOT'];
- include $droot.'/e-learning/c-panel/include/header.php';
- include $droot.'/e-learning/c-panel/include/ind-date.php';
- $msg = "";
- $hashOrigi = '';
- $hashDeff = '';
- if(isset($_POST['btn_simpan']))
- {
- $origi = preg_replace("/[^a-zA-Z 0-9]+/", "", str_replace(" ", "", strtolower($_POST['txt_in_original'])));
- $deff = preg_replace("/[^a-zA-Z 0-9]+/", "", str_replace(" ", "", strtolower($_POST['txt_in_deffrent'])));
- $gram = $_POST['cmb_gram'];
- $bsis = $_POST['cmb_basis'];
- $win = $_POST['cmb_window'];
- #k-gram
- $k_gram_origi = k_gram($origi, $gram);
- $k_gram_deff = k_gram($deff, $gram);
- #rolling-hash
- $rlhOrigi = hashing($origi, $gram, $bsis);
- $rlhDeff = hashing($deff, $gram, $bsis);
- #window
- $windOrigi = window($rlhOrigi, $win);
- $windDeff = window($rlhDeff, $win);
- }
- #K-gram
- function k_gram($text, $gram)
- {
- $char = "";
- $i = 0;
- $strlen = strlen($text);
- while($i <= $strlen - $gram)
- {
- $char .= substr($text, $i, $gram).' ';
- $i++;
- }
- return $char;
- }
- #rolling Hash
- function rHash($text, $basis)
- {
- $hash_value = 0;
- $prev_hash = 0;
- $c_awal = 0;
- $length = strlen($text)- 1;
- if($prev_hash == 0)
- {
- for($i = 0; $i <= $length; $i++)
- {
- $ascii = ord(substr($text, $i, 1));
- $hash_value += $ascii * pow($basis, $length - $i);
- }
- }else
- {
- $hash_value = $prev_hash - $c_awal * pow($basis, $length);
- $hash_value *= $basis;
- $hash_value += substr($text, $i, 1);
- }
- $c_awal = ord(substr($text, 0, 1));
- $prev_hash = $hash_value;
- return $hash_value." ";
- }
- function hashing($text, $gram, $basis)
- {
- $i = 0;
- $rolling_has = "";
- $strlen = strlen($text);
- while($i <= $strlen - $gram)
- {
- $char = substr($text, $i,$gram);
- $rolling_has .= rHash($char, $basis);
- $i++;
- }
- return $rolling_has;
- }
- #window
- function window($text, $window){
- $wind = "";
- $data=explode(' ',$text);
- $m=count($data) - $window -1;
- for($i = 0; $i <= $m; $i++)
- {
- $s=array();
- for($j = 0; $j < $window; $j++)
- $s[] = $data[$i+$j];
- $wind .= "{".implode(' ',$s)."}<br>";
- }
- return $wind;
- }
- function fingerprint($text, $window){
- $temp = [];
- $data = [];
- $pieces = explode(" ", $text);
- $m = count($pieces) - $window;
- for ($i=0; $i <= $m; $i++) {
- $s = array();
- for($j = 0; $j < $window -1; $j++)
- $s[]=$pieces[$i+$j];
- // if (count($s) > 0) {
- // $min_hash = min($s);
- // $min_index = $i;
- // echo "[".$min_hash.",".$min_index."]";
- // }
- }
- foreach ($s as $key => $value) {
- $explode = explode(',', $value);
- $current = current($explode);
- $end = end($explode);
- $temp[$current][] = $end;
- }
- foreach ($temp as $key => $value) {
- $data[] = $key . ',' . end($value);
- }
- echo '<pre>' . print_r($data, true) . '</pre>';
- }
- ?>
- <div class="wrapper row-offcanvas row-offcanvas-left">
- <!-- Left side column. contains the logo and sidebar -->
- <!-- Right side column. Contains the navbar and content of the page -->
- <aside class="right-side">
- <!-- Content Header (Page header) -->
- <section class="content-header">
- <h1>
- Pilihan Ganda
- <small>Tambah Data</small>
- </h1>
- <ol class="breadcrumb">
- <li><a href="http://localhost/e-learning/c-panel/index.php"><i class="fa fa-dashboard"></i> E-Learning</a></li>
- <li><a href="#">Manajemen Soal</a></li>
- <li class="active">Tambah Data Pilihan Ganda</li>
- </ol>
- </section>
- <!-- Main content -->
- <section class="content">
- <div class="row">
- <form action="" method="post" enctype="multipart/form-data">
- <div class="col-md-10">
- <div class="box box-primary">
- <div class="box-header">
- <h3 class="box-title">Standart Text</h3>
- </div>
- <div class="box-body">
- <table width="100%">
- <tr>
- <td>
- <label>Original Text</label>
- <textarea name="txt_in_original" class="textarea" placeholder="Original Text" style="width: 100%; height: 100px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"><?php echo isset($_POST['txt_in_original']) ? $_POST['txt_in_original'] : "";?></textarea>
- </td>
- <td>
- <label>Defferent Text</label>
- <textarea name="txt_in_deffrent" class="textarea" placeholder="Defferent Text" style="width: 100%; height: 100px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"><?php echo isset($_POST['txt_in_deffrent']) ? $_POST['txt_in_deffrent'] : "";?></textarea>
- </td>
- </tr>
- </table>
- </div>
- <div class="box-header">
- <h3 class="box-title">K-gram</h3>
- </div>
- <div class="box-body">
- <table border="0" width="100%" style="table-layout:fixed;">
- <tr>
- <td>
- <div class="callout callout-info">
- <h4>Original Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- echo $k_gram_origi;
- }
- ?>
- </div>
- </td>
- <td>
- <div class="callout callout-info">
- <h4>Defferent Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- echo $k_gram_deff;
- }
- ?>
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div class="box-header">
- <h3 class="box-title">Hashing</h3>
- </div>
- <div class="box-body">
- <table width="100%" style="table-layout:fixed;">
- <tr>
- <td>
- <div class="callout callout-info">
- <h4>Original Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- echo $rlhOrigi;
- #hashing($origi, $gram, $bsis);
- }
- ?>
- </div>
- </td>
- <td>
- <div class="callout callout-info">
- <h4>Original Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- echo $rlhDeff;
- #hashing($deff, $gram, $bsis);
- }
- ?>
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div class="box-header">
- <h3 class="box-title">Window</h3>
- </div>
- <div class="box-body">
- <table width="100%" style="table-layout:fixed;">
- <tr>
- <td>
- <div class="callout callout-info">
- <h4>Original Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- echo $windOrigi;
- #window($rlhOrigi, $win);
- }
- ?>
- </div>
- </td>
- <td>
- <div class="callout callout-info">
- <h4>Original Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- echo $windDeff;
- #window($rlhDeff, $win);
- }
- ?>
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div class="box-header">
- <h3 class="box-title">Fingerprint</h3>
- </div>
- <div class="box-body">
- <table width="100%" style="table-layout:fixed;">
- <tr>
- <td>
- <div class="callout callout-info">
- <h4>Original Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- #echo $windOrigi;
- fingerprint($rlhOrigi, $win);
- $temp = [];
- $data = [];
- #echo count($windOrigi);
- }
- ?>
- </div>
- </td>
- <td>
- <div class="callout callout-info">
- <h4>Original Text</h4>
- <?php
- if(isset($_POST['btn_simpan']))
- {
- #echo $windDeff;
- fingerprint($rlhDeff, $win);
- }
- ?>
- </div>
- </td>
- </tr>
- </table>
- </div>
- </div>
- </div>
- <div class="col-md-2">
- <div class="box box-primary">
- <div class="box-header">
- <h3 class="box-title">Option</h3>
- </div>
- <div class="form-group">
- <label>Basis</label>
- <select class="form-control" name="cmb_basis">
- <option value="<?php echo isset($_POST['cmb_basis']) ? $_POST['cmb_basis'] : '0';?>" ><?php echo isset($_POST['cmb_basis']) ? $_POST['cmb_basis'] : "0";?></option>
- <?php
- for($i=1;$i<=100;$i++)
- {
- ?>
- <option value="<?php echo $i; ?>"> <?php echo $i; ?></option>
- <?php
- }
- ?>
- </select>
- </div>
- <div class="form-group">
- <label>Gram</label>
- <select class="form-control" name="cmb_gram">
- <option value="<?php echo isset($_POST['cmb_gram']) ? $_POST['cmb_gram'] : '0';?>"><?php echo isset($_POST['cmb_gram']) ? $_POST['cmb_gram'] : "0";?></option>
- <?php
- for($i=1;$i<=100;$i++)
- {
- ?>
- <option value="<?php echo $i; ?>"> <?php echo $i; ?></option>
- <?php
- }
- ?>
- </select>
- </div>
- <div class="form-group">
- <label>Window</label>
- <select class="form-control" name="cmb_window">
- <option value="<?php echo isset($_POST['cmb_window']) ? $_POST['cmb_window'] : '0';?>"><?php echo isset($_POST['cmb_window']) ? $_POST['cmb_window'] : "0";?></option>
- <?php
- for($i=1;$i<=100;$i++)
- {
- ?>
- <option value="<?php echo $i; ?>"> <?php echo $i; ?></option>
- <?php
- }
- ?>
- </select>
- </div>
- <div class="box-footer">
- <button type="submit" name="btn_simpan" class="btn btn-primary" data-toggle='tooltip' data-placement='auto' title='Simpan'><i class="fa fa-save"></i></button>
- <button type="submit" name="btn_reset" class="btn btn-primary" data-toggle='tooltip' data-placement='auto' title='Reset'><i class="fa fa-refresh"></i></button>
- </div>
- </div>
- </div>
- <div class="col-md-2">
- <div class="box box-primary">
- <div class="box-header">
- <h3 class="box-title">Result</h3>
- </div>
- </div>
- </div>
- </form>
- </div>
- </section>
- </aside><!-- /.right-side -->
- </div><!-- ./wrapper -->
- <!-- jQuery 2.0.2 -->
- <script src="http://localhost/e-learning/c-panel/js/jquery.min.js"></script>
- <!-- Bootstrap -->
- <script src="http://localhost/e-learning/c-panel/js/bootstrap.min.js" type="text/javascript"></script>
- <!-- AdminLTE App -->
- <script src="http://localhost/e-learning/c-panel/js/AdminLTE/app.js" type="text/javascript"></script>
- <script src="http://localhost/e-learning/c-panel/js/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
- <script src="http://localhost/e-learning/c-panel/js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement