Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Dw extends CI_Controller {
- public function index($word = 'theact')
- {
- $result = array();
- $config = pspell_config_create("en", "american");
- pspell_config_personal($config, '/var/www/test/application/controllers/includes/lib/custom.pws');
- pspell_config_mode($config, PSPELL_FAST);
- $link = pspell_new_config($config);
- pspell_add_to_personal($link, "Daniweb");
- pspell_save_wordlist($link);
- if( ! pspell_check($link, $word))
- {
- $suggestions = pspell_suggest($link, $word);
- foreach($suggestions as $suggestion)
- {
- similar_text($word, $suggestion, $percent);
- if(round($percent) > 70)
- {
- $result[] = $suggestion;
- }
- }
- }
- $data['result'] = $result;
- $this->load->view('dw/index', $data);
- }
- }
- /*
- The view:
- <pre><?php
- print_r($result);
- ?></pre>
- The pws file (custom.pws):
- personal_ws-1.1 en 9
- themouse
- calle
- capanna
- thecat
- revoir
- Daniweb
- thedog
- rndsgr
- casa
- And then the test links:
- http://localhost/dw/index
- http://localhost/dw/index/danweb
- http://localhost/dw/index/thedg
- ...
- From terminal:
- php index.php dw
- php index.php dw index clle
- php index.php dw index danweb
- php index.php dw index cas
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement