-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArabicFilter.php
executable file
·51 lines (39 loc) · 1.5 KB
/
ArabicFilter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
namespace VPremiss\Arabicable;
use VPremiss\Arabicable\Facades\Arabic;
use VPremiss\Crafty\Facades\CraftyPackage;
class ArabicFilter
{
public function withHarakat(string $text): string
{
Arabic::validateForTextSpacing($text);
$text = Arabic::convertNumeralsToIndian($text);
$text = Arabic::normalizeSpaces($text);
$text = Arabic::convertPunctuationMarksToArabic($text);
$text = Arabic::removeSpacesAroundPunctuationMarks($text);
if (!CraftyPackage::getConfiguration('arabicable.spacing_after_punctuation_only')) {
$text = Arabic::addSpacesBeforePunctuationMarks($text);
}
$text = Arabic::addSpacesAfterPunctuationMarks($text);
$text = Arabic::removeSpacesWithinEnclosingMarks($text);
$text = Arabic::refineSpacesBetweenPunctuationMarks($text);
return $text;
}
public function withoutHarakat(string $text): string
{
$text = $this->withHarakat($text);
$text = Arabic::removeHarakat($text);
return $text;
}
public function forSearch(string $text): string
{
$text = Arabic::removeHarakat($text);
$text = Arabic::removeAllPunctuationMarks($text);
$text = Arabic::convertNumeralsToArabicAndIndianSequences($text);
$text = Arabic::deduplicateArabicAndIndianNumeralSequences($text);
$text = Arabic::normalizeHuroof($text);
$text = Arabic::normalizeSpaces($text);
return $text;
}
}