apt-get install libfann*
# wget http://pecl.php.net/get/fann # tar xvfz fann # cd fann-0.1.1 # phpize # ./configure # make
fann.c:393: error: 'zif_fannOO___set' undeclared (first use in this function)
sudo cp -R ./modules/* /usr/lib/php5/20090626+lfs/
extension=fann.so
php -m | grep fann
<?php /* * . 256 - , , * , . * 128 - . . * 3 . 3 , * 1.0 - connection_rate - * 0.7 - learning_rate - http://www.basegroup.ru/glossary/definitions/learning_rate/ * */ $ann = fann_create(array(256, 128, 3), 1.0, 0.7); /* * - , - . * 3 . . * , , , * (array(1, 0, 0) // Outputs). * generate_frequencies - . * * 3 * - - * - - * - * * en.txt, fr.txt, pl.txt - 10000 * */ fann_train($ann, array( array( generate_frequencies(file_get_contents("en.txt")), // Inputs array(1, 0, 0) // Outputs ), array( generate_frequencies(file_get_contents("fr.txt")), // Inputs array(0, 1, 0) // Outputs ), array( generate_frequencies(file_get_contents("pl.txt")), // Inputs array(0, 0, 1) // Outputs ), ), 100000, 0.00001, 1000 ); /* * . * */ fann_save($ann,"classify.txt"); /* * * */ function generate_frequencies($text){ // $text = preg_replace("/[^\p{L}]/iu", "", strtolower($text)); // $total = strlen($text); $data = count_chars($text); // array_walk($data, function (&$item, $key, $total){ $item = round($item/$total, 3); }, $total); return array_values($data); } ?>
<?php /* * . . * */ $ann = fann_create("classify.txt"); /* * 3 * * */ $output = fann_run($ann, generate_frequencies("ANN are slowly adjusted so as to produce the same output as in the examples. The hope is that when the ANN is shown a new X-ray images containing healthy tissues")); var_dump($output); $output = fann_run($ann, generate_frequencies("Voyons, Monsieur, absolument pas, les camions d'aujourd'hui ne se traînent pas, bien au contraire. Il leur arrive même de pousser les voitures. Non, croyez moi, ce qu'il vous faut, c'est un camion ! - Vous croyez ? Si vous le dites. Est-ce que je pourrais l'avoir en rouge ? - Bien entendu cher Monsieur,vos désirs sont des ordres, vous l'aurez dans quinze jours clé en main. Et la maison sera heureuse de vous offrir le porte-clé. Si vous payez comptant. Cela va sans dire, ajouta Monsieur Filou. - Ah, si ce ")); var_dump($output); $output = fann_run($ann, generate_frequencies("tworząc dzieło literackie, pracuje na języku. To właśnie język stanowi tworzywo, dzięki któremu powstaje tekst. Język literacki ( lub inaczej artystyczny) powstaje poprzez wybór odpowiednich środków i przy wykorzystaniu odpowiednich zabiegów technicznych. Kompozycja - jest to układ elementów treściowych i formalnych dzieła dokonanych według określonych zasad konstrukcyjnych. Kształtowanie tworzywa dzieła literackiego jest procesem skomplikowanym i przebiegającym na wielu poziomach. Składa się na nie:")); var_dump($output); ?>
generate_frequencies ( "tworząc dzieło literackie, pracuje na języku. To właśnie język stanowi tworzywo, dzięki któremu powstaje tekst. Język literacki (lub inaczej artystyczny) powstaje poprzez wybór odpowiednich środków i przy wykorzystaniu odpowiednich zabiegów technicznych. <?php /* * . . * */ $ann = fann_create("classify.txt"); /* * 3 * * */ $output = fann_run($ann, generate_frequencies("ANN are slowly adjusted so as to produce the same output as in the examples. The hope is that when the ANN is shown a new X-ray images containing healthy tissues")); var_dump($output); $output = fann_run($ann, generate_frequencies("Voyons, Monsieur, absolument pas, les camions d'aujourd'hui ne se traînent pas, bien au contraire. Il leur arrive même de pousser les voitures. Non, croyez moi, ce qu'il vous faut, c'est un camion ! - Vous croyez ? Si vous le dites. Est-ce que je pourrais l'avoir en rouge ? - Bien entendu cher Monsieur,vos désirs sont des ordres, vous l'aurez dans quinze jours clé en main. Et la maison sera heureuse de vous offrir le porte-clé. Si vous payez comptant. Cela va sans dire, ajouta Monsieur Filou. - Ah, si ce ")); var_dump($output); $output = fann_run($ann, generate_frequencies("tworząc dzieło literackie, pracuje na języku. To właśnie język stanowi tworzywo, dzięki któremu powstaje tekst. Język literacki ( lub inaczej artystyczny) powstaje poprzez wybór odpowiednich środków i przy wykorzystaniu odpowiednich zabiegów technicznych. Kompozycja - jest to układ elementów treściowych i formalnych dzieła dokonanych według określonych zasad konstrukcyjnych. Kształtowanie tworzywa dzieła literackiego jest procesem skomplikowanym i przebiegającym na wielu poziomach. Składa się na nie:")); var_dump($output); ?>
array(3) { [0]=> float(0.98745632171631) [1]=> float(0.0094089629128575) [2]=> float(0) }
array(3) { [0]=> float(0) [1]=> float(0.99334162473679) [2]=> float(0) }
array(3) { [0]=> float(0.015697015449405) [1]=> float(0) [2]=> float(1) }
Source: https://habr.com/ru/post/158729/
All Articles