PHP Classes

PHP Word Completion: Suggest words that complete strings

Recommend this page to a friend!
  Info   Example   Demos   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 123 All time: 9,471 This week: 488Up
Version License PHP version Categories
wordcompletion 1.0.3MIT/X Consortium ...7PHP 5, Files and Folders, Text proces...
Description 

Author

This class can suggest words that complete strings.

It takes the name of a file that is read to extract the words to complete.

The class can take some typed letters and return an array with words that complete those letters from the text file.

Picture of castromiltone
Name: castromiltone <contact>
Classes: 1 package by
Country: Kenya Kenya

 

Example

<?php
   
require '../WordCompletion.php';
   
    if (isset(
$_POST['input_text']) and isset($_POST['source']))
    {
       
$typed = $_POST['input_text'];
       
$filename = $_POST['source'];
       
       
#ini_set('memory_limit', '-1');
       
$wc = new WordCompletion($filename);
       
$wc->doCompletion($typed);

       
header("Content-Type: Application/json");
        echo
json_encode($wc->suggestions);
    }
 
?>


Details

WordCompletions

This is a PHP Class coded using PHP 7 author: Castro Hamiltone

Purpose

The aim is to provide a sorted ( based on the percentage of the frequecny of occurrence of the suggested word in the source of words ) list of most probable completions of a word given the begining letters of the word and a source of words to be used.

Parameters

*@param $begining:- string, the begining portion of the word to be completed. e.g 'yo', 'you', or 'your' etc<br>* *@param $words_source:- string, the filename (.txt) of the text file containing the commonly used words.<br>* You can use a corpus from The Guternburg Project

Return

array:- possible completions with probability in percentages


  Files folder image Files (21)  
File Role Description
Files folder imagedemo (5 files, 1 directory)
Accessible without login Plain text file LICENSE.txt Lic. License
Accessible without login Plain text file README.md Doc. Documentation
Plain text file WordCompletion.php Class Class source
Accessible without login Plain text file words.txt Data Demo words source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:123
This week:0
All time:9,471
This week:488Up