PHP code example of aymanrb / php-unstructured-text-parser
1. Go to this page and download the library: Download aymanrb/php-unstructured-text-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aymanrb / php-unstructured-text-parser example snippets
ser = new aymanrb\UnstructuredTextParser\TextParser('/path/to/templatesDirectory');
$textToParse = 'Text to be parsed fetched from a file, mail, web service, or even added directly to the a string variable like this';
//performs brute force parsing against all available templates, returns first match successful parsing
$parseResults = $parser->parseText($textToParse);
foreach ($parseResults as $key => $value) {
echo "$key: $value" . PHP_EOL;
}
//slower, performs a similarity check on available templates to select the most matching template before parsing
foreach ($parser->parseText($textToParse, true) as $key => $value) {
echo "$key: $value" . PHP_EOL;
}
//or use the getParsedRawData() method to get the results as an array
$resultsArray = $parser->parseText($textToParse)->getParsedRawData();
//ParseText used to return array in 1.x
$extractedArray = $parser->parseText($textToParse);
//In 2.x you need to do the following if you want an array
$extractedArray = $parser->parseText($textToParse)->getParsedRawData();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.