Beispiel #1
0
if (empty($qt) || $qt == 0 || !is_numeric($qt)) {
    $response = 'fail';
} else {
    $email = $_SESSION['name'];
    $name1 = $_SESSION['pname'];
    $price = $_SESSION['pprice'];
    $mysqli = new mysqli('localhost', 'root', 'password', 'transaction_store');
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit;
    }
    for ($i = 0; $i < $qt; $i++) {
        $q = $mysqli->query("select object from object_store where Email='{$email}' ");
        $r = $q->fetch_assoc();
        if ($r['object'] === NULL) {
            $m = new Markov();
            $m->add_item($price);
            $m->insert_in_cart();
            $m->make_dict();
            $m->add_state();
            $mysqli->query("update object_store set object='" . serialize($m) . "'  where Email='{$email}' ");
        } else {
            $d = unserialize($r['object']);
            $d->add_item($price);
            $d->insert_in_cart();
            $d->make_dict();
            $d->add_state();
            $mysqli->query("update object_store set object='" . serialize($d) . "'  where Email='{$email}' ");
        }
    }
    $response = 'success';
Beispiel #2
0
function composeTweet()
{
    $titles = file('data-titles.txt', FILE_IGNORE_NEW_LINES);
    $camps = file('data-camps.txt', FILE_IGNORE_NEW_LINES);
    $TWITTER_CHARACTER_LIMIT = 140;
    $markov = new Markov();
    $markov->init($titles);
    $title = $markov->generate(4);
    $markov = new Markov();
    $markov->init($camps);
    $camp = $markov->generate(4);
    $chain = "{$title} @ {$camp} (" . address() . ") #burningman #bot";
    if (strlen($chain) >= $TWITTER_CHARACTER_LIMIT) {
        // try again
        composeTweet();
    } else {
        return $chain;
    }
}
Beispiel #3
0
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="container">

<header>
<h1>TehuTehu連鎖</h1>
<p class="desc">Tehu君の名言をマルコフ連鎖で自動生成します</p>
</header>

<main>
<?php 
require_once 'markov.php';
require 'mecabp.php';
require 'data.php';
$summarizer = new Markov();
$words = array();
$stary = explode("\n", $string);
$stary = array_map('trim', $stary);
$stary = array_filter($stary, 'strlen');
shuffle($stary);
$string = implode("", $stary);
$mecab = new Mecabp();
$ary = $mecab->parse($string);
for ($i = 0; $i < count($ary); $i++) {
    $str = $ary[$i]["word"];
    array_push($words, $str);
}
array_push($words, "EOS");
?>
 public function test3()
 {
     $m = new Markov();
     $m->add_item(6000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(30000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(5000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(20000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(5000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(5000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(50000);
     $m->insert_in_cart();
     $m->add_state();
     $m->add_item(20000);
     $m->insert_in_cart();
     $m->add_state(1);
     $m->calculate_constants();
     $m->calculate_prob_state();
     $this->assertEquals('high', $m->test_gauss());
 }
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<?php 
set_time_limit(0);
include 'Markov.Class.php';
$Markov = new Markov(4, ' ', 'memorise');
// var_dump($Markov->generateInitial());
$englishQuestions = ["Choose a novel in which loyalty or bravery or trust plays an important part. Show how the writer explores the idea in a way which adds to your understanding of the central concern(s) of the text.", "Choose a novel in which the vulnerability of a central character is apparent at one or more than one key point in the text. Explain the situation(s) in which the character’s vulnerability emerges and discuss the importance of the vulnerability to your understanding of character and/or theme in the text as a whole.", "Choose a novel in which a character makes a decision which you consider unexpected or unwise or unworthy. Explain the circumstances surrounding the decision and discuss its importance to your understanding of character and theme in the novel as a whole.", "Choose a novel or short story in which ideas and/or characters and/or incidents appear to be designed to shock the reader. Explain what you find shocking about the text and discuss to what extent this enhances your understanding of the text as a whole.", "Choose a novel in which envy or malice or cruelty plays a significant part. Explain how the writer makes you aware of this aspect of the text and discuss how the writer’s exploration of it enhances your understanding of the text as a whole.", "Choose a novel in which a character is influenced by a particular location or setting. Explain how the character is influenced by the location or setting and discuss how this enhances your understanding of the text as a whole.", "Choose a novel or short story in which there is an act of kindness or of compassion. Explain briefly the nature of the act and discuss its importance to your understanding of the text as a whole.", "Choose a novel in which the death of a character clarifies an important theme in the text.Show how this theme is explored in the novel as a whole and discuss how the death of the character clarifies the theme.", "Choose two short stories in which a central character feels threatened or vulnerable. Compare how this situation is presented in each story and discuss which story is more effective in arousing your sympathy for the central character.", "Choose a novel or short story which explores loss or futility or failure. Discuss how the writer explores one of these ideas in a way you find effective.", "Choose a novel in which a main character refuses to accept advice or to conform to expectations. Explain the circumstances of the refusal and discuss its importance to your understanding of the character in the novel as a whole.", "Choose a novel in which a particular mood is dominant. Explain how the novelist creates this mood and discuss how it contributes to your appreciation of the novel as a whole.", "Choose a novel or short story in which there is a character who is not only realistic as a person but who has symbolic significance in the text as a whole. Show how the writer makes you aware of both aspects of the character.", "Choose a novel or short story which features a relationship between two characters which is confrontational or corrosive. Describe how the relationship is portrayed and discuss to what extent the nature of the relationship influences your understanding of the text as a whole.", "Choose a novel in which the novelist makes use of more than one location. Discuss how the use of different locations allows the novelist to develop the central concern(s) of the text.", "Choose a novel in which a character experiences a moment of revelation. Describe briefly what is revealed and discuss its significance to your understanding of character and/or theme.", "Choose a novel in which a character seeks to escape from the constraints of his or her environment or situation. Explain why the character feels the need to escape and show how his or her response to the situation illuminates a central concern of the text.", "Choose two short stories whose openings are crafted to seize the reader’s attention. Explain in detail how the impact of the openings is created and go on to evaluate which of the stories develops more successfully from its opening.", "Choose a novel in which friendship or love is put to the test. Explain briefly how this situation arises and go on to discuss how the outcome of the test leads you to a greater understanding of the central concern(s) of the text.", "Choose a novel in which a central character is flawed but remains an admirable figure. Show how the writer makes you aware of these aspects of personality and discuss how this feature of characterisation enhances your appreciation of the text as a whole.", "Choose a novel or short story in which the writer explores feelings of rejection or isolation or alienation. Explain how the writer makes you aware of these feelings and go on to show how this exploration enhances your appreciation of the text as a whole.", "Choose a novel in which the narrative point of view is a significant feature in your appreciation of the text. Show how the writer’s use of this feature enhances your understanding of the central concern(s) of the text.", "Choose two short stories in which setting plays an important role in developing your understanding of character and/or theme. Which story, in your opinion, is more effective in developing your understanding? Justify your choice by reference to the setting of both stories."];
// Order 1
// $Markov->order = 4;
// Learn
foreach ($englishQuestions as $question) {
    $Markov->learn($question);
}
$i = 0;
$generated = [];
$array = ['Choose a novel or short story in which there is an act of kindness or of compassion. Explain briefly the nature of the act and discuss its importance to your understanding of the character in the novel as a whole.'];
while ($i < 1000) {
    $asked = $Markov->ask();
    if (!in_array($asked, $englishQuestions) && !in_array($asked, $generated)) {
        array_push($generated, $asked);
        echo "<div style='width: 50%;'>" . $asked . "</div><br>";
    }
    $i++;
}
// Choose a novel in which the narrative point of view is a significant feature in your appreciation of the text. Show how the writer’s use of this feature enhances your understanding of the text as a whole. Show how the writer makes you aware of both aspects of the character.
Beispiel #6
0
ここへ来たのは初夏の頃で、鉄の格子の窓から病院の庭の小さい池に紅《あか》い睡蓮の花が咲いているのが見えましたが、それから三つき経ち、庭にコスモスが咲きはじめ、思いがけなく故郷の長兄が、ヒラメを連れて自分を引き取りにやって来て、父が先月末に胃潰瘍《いかいよう》でなくなったこと、自分たちはもうお前の過去は問わぬ、
生活の心配もかけないつもり、何もしなくていい、その代り、いろいろ未練もあるだろうがすぐに東京から離れて、田舎で療養生活をはじめてくれ、お前が東京でしでかした事の後仕末は、だいたい渋田がやってくれた筈だから、それは気にしないでいい、とれいの生真面目な緊張したような口調で言うのでした。
故郷の山河が眼前に見えるような気がして来て、自分は幽かにうなずきました。
まさに癈人。
父が死んだ事を知ってから、自分はいよいよ腑抜《ふぬ》けたようになりました。父が、もういない、自分の胸中から一刻も離れなかったあの懐しくおそろしい存在が、もういない、自分の苦悩の壺がからっぽになったような気がしました。自分の苦悩の壺がやけに重かったのも、あの父のせいだったのではなかろうかとさえ思われました。
まるで、張合いが抜けました。苦悩する能力をさえ失いました。
それから三年と少し経ち、自分はその間にそのテツという老女中に数度へんな犯され方をして、時たま夫婦喧嘩《げんか》みたいな事をはじめ、胸の病気のほうは一進一退、痩せたりふとったり、血痰《けったん》が出たり、きのう、テツにカルモチンを買っておいで、と言って、
村の薬屋にお使いにやったら、いつもの箱と違う形の箱のカルモチンを買って来て、べつに自分も気にとめず、寝る前に十錠のんでも一向に眠くならないので、おかしいなと思っているうちに、おなかの具合がへんになり急いで便所へ行ったら猛烈な下痢で、しかも、それから引続き三度も便所にかよったのでした。不審に堪えず、薬の箱をよく見ると、それはヘノモチンという下剤でした。
自分は仰向けに寝て、おなかに湯たんぽを載せながら、テツにこごとを言ってやろうと思いました。
いまは自分には、幸福も不幸もありません。
ただ、一さいは過ぎて行きます。
自分がいままで阿鼻叫喚で生きて来た所謂「人間」の世界に於いて、たった一つ、真理らしく思われたのは、それだけでした。
ただ、一さいは過ぎて行きます。
自分はことし、二十七になります。白髪がめっきりふえたので、たいていの人から、四十以上に見られます。
' . PHP_EOL;
$summarizer = new Markov();
$words = array();
$fn = "./" . hash("sha1", $string);
if (file_exists($fn)) {
    $words = unserialize(file_get_contents($fn));
} else {
    $mecab = new Mecabp();
    $ary = $mecab->parse($string);
    for ($i = 0; $i < count($ary); $i++) {
        $str = $ary[$i]["word"];
        if ($ary[$i]["kind"] == "名詞") {
            $str = "<span style='font-weight:bold; font-size:20px;'>" . $str . "</span>";
        }
        array_push($words, $str);
    }
    array_push($words, "EOS");
Beispiel #7
0
<?php 
error_reporting(-1);
ini_set('display_errors', true);
require 'Markov.php';
echo "<em>" . "Tests" . "</em>";
echo "<br><br>";
echo "<em>" . "Test1" . "</em>";
echo "<br>";
$m = new Markov();
$m->add_item(6000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(15000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(21000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(3000);
$m->insert_in_cart();
$m->add_state();
$m->add_item(25000);
$m->insert_in_cart();
$m->add_state(1);
$m->view_state();
$m->parse_dict();
$m->calculate_constants();
$m->display_constants();
$m->calculate_prob_state();
$m->test_gauss();
Beispiel #8
0
<?php 
error_reporting(-1);
ini_set('display_errors', true);
require 'Markov.php';
echo "<em>" . "Tests" . "</em>";
echo "<br><br>";
echo "<em>" . "Test1" . "</em>";
echo "<br>";
$m = new Markov();
$m->add_item(6000);
$m->add_state();
$m->add_item(15000);
$m->add_state();
$m->add_item(21000);
$m->add_state();
$m->add_item(3000);
$m->add_state();
$m->add_item(25000);
$m->add_state(1);
$m->view_state();
$m->calculate_constants();
$m->display_constants();
$m->calculate_prob_state();
$m->test_gauss();
/*$t=serialize($m);

$mysqli=new mysqli('localhost','root','password','transaction_store');
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();