PHP Classes

Free Text Search: Search for data taking common words typed by users

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 173 All time: 8,802 This week: 47Up
Version License PHP version Categories
free-text-search 1.0.0Custom (specified...5PHP 5, Searching, Parsers
Description 

Author

This package can search for data taking common words typed by users.

It takes as parameters a string with common English words types or spoken by the users.

The package sends HTTP requests to the Daft.ie API with the words entered by the users to search for the data he wants.

Innovation Award
PHP Programming Innovation award nominee
June 2019
Number 3
Many people solve their problems by asking questions that express the difficulty they are having to find a solution.

Usually they use natural language in the idiom that they use to define the problem by asking a question.

This package can perform searches for solutions to problems that people may have using the Daft.ie API

This package can search for data taking common words typed by users.

It takes as parameters a string with common English words types or spoken by the users.

The package sends HTTP requests to the Daft.ie API with the words entered by the users to search for the data he wants like for instance finding locations for sale or rent in a given city.

Manuel Lemos
Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 49 packages by
Country: United Kingdom
Innovation award
Innovation award
Nominee: 18x

Winner: 3x

Example

<?php
/**
 * @author Pierre-Henry Soria <pierrehenrysoria@gmail.com>
 * @copyright (c) 2015, Pierre-Henry Soria. All Rights Reserved.
 * @license CC-BY - http://creativecommons.org/licenses/by/3.0/
 * @link http://hizup.uk
 */

// Hey there! Be careful, the script requires PHP 5.4 or higher ;-)
namespace FreeTextSearch;
use
FreeTextSearch\Engine as E;

/* Check if the current PHP version us compatible with the script */
if (version_compare(PHP_VERSION, '5.4.0', '<'))
    exit(
'Whoops! Your PHP version is ' . PHP_VERSION . '. The script requires PHP 5.4 or higher.');

try
{
    require
__DIR__ . '/Engine/Loader.php';
   
E\Loader::getInstance()->init(); // Loads necessary classes

   
$aParams = ['ctrl' => (!empty($_GET['p']) ? $_GET['p'] : 'main'), 'act' => (!empty($_GET['a']) ? $_GET['a'] : 'index')]; // I use the new PHP 5.4 short array syntax
   
E\Router::run($aParams);
}
catch (\
Exception $oE)
{
    echo
$oE->getMessage();
}


Details

Simple Free Text Property Search

Description

Free Text Search Engine for the Irish Estate Properties using the Daft.ie API.

The Engine translates what the user are looking for and transforms the input string into a string requests and then will send that request to the Daft.ie API.

The script also offers the voice speech recognition thanks HTML5 & JavaScript speech-input.

In this script, I use:

  • PSR0 to PSR4 coding standards
  • Formatted/documented code
  • DRY (Don't Repeat Yourself) principle
  • OOP code (including PHP Interfaces & Traits (PHP 5.4 specification)
  • spl_autoload_register (which is very useful with PHP namespaces)
  • View/Controller pattern
  • Singleton pattern (even if not necessary...)
  • PHP alternative syntax for the template (which makes the visibility easier)
  • Class member access on instantiation (PHP >= 5.4)
  • Short Array syntax (PHP >= 5.4)
  • Using SOAPClient

Search Query Examples

  • 2 or 3 bed to rent between 1000 and 2000
  • 3 bedrooms to buy in Dublin
  • 2 or 3 beds apartment to rent in Cork around 400 and 600 euro
  • 4 bedroom house to let in Galway for 1000 around 900 and 14000 per month

Specification

  • Search Type (Rental/Sale)
  • Price (Min-Max)
  • Bedroom (Min-Max)
  • Property Types (house, apartment, site)
  • House Types (terraced, semi-detached, detached, end-of-terrace, townhouse)
  • Retrieve Areas from the API
  • Retrieve Counties from the API
  • Each search term has its own Class and is getting back by the "Parser" class and included by spl_autoload_register() SPL function
  • HTML5 speech-input search
  • Displayed the property results thanks to Daft's API

Other Coding Convention

In addition of using the PSR and PHP Pear, I use my own for the naming of the variables

Here are the variable prefixes: * a = Array * i = Integer * f = Float, Double * b = Boolean * s = String * o = Object * m = Mixed * r = Resource * c = 1 Character (I used only sometime that, as char is not a PHP valid type)

Following the "letter type lower case, the variable name is in UpperCamelCase (e.g., $aMyVariable)

Server Requirements of the Web App

Application Server PHP 5.4.0 or higher.

PHP Extension SOAPClient

Other Requirements

About Me

I'm Pierre-Henry Soria, IT developer and passionate about e-businesses and marketing.

Where to contact me?

You can by email at pierrehenrysoria [[AT]] gmail [[D0T]] com

License

The script is under Creative Commons Attribution 3.0 license or later; See the LICENSE.txt file.


Screenshots (3)  
  • example-free-text-search-property.png
  • example-free-text-search-tooltip-pic-property.png
  • html5-speech-input-search.png
  Files folder image Files (40)  
File Role Description
Files folder imageController (2 files)
Files folder imageEngine (5 files, 2 directories)
Files folder imagestatic (3 directories)
Files folder imageView (3 files, 1 directory)
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE.txt Lic. License
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file requirements.txt Doc. Documentation

  Files folder image Files (40)  /  Controller  
File Role Description
  Plain text file Controller.php Class Class source
  Plain text file Main.php Class Class source

  Files folder image Files (40)  /  Engine  
File Role Description
Files folder imageFreeText (3 files, 1 directory)
Files folder imagePattern (2 files)
  Plain text file Config.php Class Class source
  Plain text file Loader.php Class Class source
  Plain text file Router.php Class Class source
  Plain text file Str.php Class Class source
  Plain text file View.php Class Class source

  Files folder image Files (40)  /  Engine  /  FreeText  
File Role Description
Files folder imageType (8 files)
  Plain text file Looking.php Class Class source
  Plain text file Parser.php Class Class source
  Plain text file Type.php Class Class source

  Files folder image Files (40)  /  Engine  /  FreeText  /  Type  
File Role Description
  Plain text file Area.php Class Class source
  Plain text file Bedroom.php Class Class source
  Plain text file County.php Class Class source
  Plain text file HouseType.php Class Class source
  Plain text file Price.php Class Class source
  Plain text file Property.php Class Class source
  Plain text file Rental.php Class Class source
  Plain text file Sale.php Class Class source

  Files folder image Files (40)  /  Engine  /  Pattern  
File Role Description
  Plain text file Singleton.php Class Class source
  Plain text file Stic.php Class Class source

  Files folder image Files (40)  /  static  
File Role Description
Files folder imagecss (4 files)
Files folder imageimg (1 file)
Files folder imagejs (3 files)

  Files folder image Files (40)  /  static  /  css  
File Role Description
  Accessible without login Plain text file bootstrap.css Data Auxiliary data
  Accessible without login Plain text file general.css Data Auxiliary data
  Accessible without login Plain text file speech-input.css Data Auxiliary data
  Accessible without login Plain text file tipsy.css Data Auxiliary data

  Files folder image Files (40)  /  static  /  img  
File Role Description
  Accessible without login Image file daft_logo.gif Icon Icon image

  Files folder image Files (40)  /  static  /  js  
File Role Description
  Accessible without login Plain text file general.js Data Auxiliary data
  Accessible without login Plain text file speech-input.js Data Auxiliary data
  Accessible without login Plain text file tipsy.js Data Auxiliary data

  Files folder image Files (40)  /  View  
File Role Description
Files folder imageinc (2 files)
  Accessible without login Plain text file not_found.tpl.php Aux. Auxiliary script
  Accessible without login Plain text file result.tpl.php Example Example script
  Accessible without login Plain text file search_form.tpl.php Aux. Auxiliary script

  Files folder image Files (40)  /  View  /  inc  
File Role Description
  Accessible without login Plain text file footer.tpl.php Aux. Auxiliary script
  Accessible without login Plain text file header.tpl.php Example Example script

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:173
This week:0
All time:8,802
This week:47Up