PHP code example of moayadmgh / text-perfection

1. Go to this page and download the library: Download moayadmgh/text-perfection 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/ */

    

moayadmgh / text-perfection example snippets


use Moayadmgh\TextPerfection\TextPerfection;

$content = 'TextPerfection is a powerful text analysis and manipulation plugin for PHP. It provides various functionalities to analyze, format, and detect plagiarism in text content.';
$TextPerfectionObj = new TextPerfection($content);

$textPerfectionResult = $TextPerfectionObj->get();

return [
    'input_content' => $this->content,
    'text_analyzer' => [
        'word_count' => $this->textAnalyzer->getWordCount(),
        'unique_word_count' => $this->textAnalyzer->getUniqueWordCount(),
        'sentences_count' => $this->textAnalyzer->getSentencesCount(),
        'keyword_density' => $this->textAnalyzer->getKeywordDensity(),
        'average_word_length' => $this->textAnalyzer->getAverageWordLength(),
    ],
    'text_rewriter' => [
        'new_content' => $this->textRewriter->getNewContent(),
    ],
    'text_formatter' => [
        'formatted_content' => $this->textFormatter->getFormattedText(),
    ]
];

use Moayadmgh\TextPerfection\ContentAnalyzer;

$content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

$analyzer = new ContentAnalyzer();
$result = $analyzer->analyze($content);

echo "Word Count: " . $result->getWordCount() . PHP_EOL;
echo "Character Count: " . $result->getCharacterCount() . PHP_EOL;
echo "Average Word Length: " . $result->getAverageWordLength() . PHP_EOL;
echo "UniqueWordCount: " . $result->getUniqueWordCount() . PHP_EOL;
echo "Sentences Count: " . $result->getSentencesCount() . PHP_EOL;
echo "Keyword Density: " . $result->getKeywordDensity() . PHP_EOL;

use Moayadmgh\TextPerfection\ContentRewriter;

$content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

$rewriter = new ContentRewriter();
$rewriter->rewrite($content);
$rewrittenContent = $rewriter->getNewContent();

echo $rewrittenContent . PHP_EOL;

use Moayadmgh\TextPerfection\TextFormatter;

$content = "# This is going to be H1\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n- List item number 1\n- List item number 2";

$formatter = new TextFormatter();
$formatter->format($content);
$formattedContent = $formatter->getFormattedText();

echo $formattedContent . PHP_EOL;