1: <?php
2: /**
3: * Sastrawi (https://github.com/sastrawi/sastrawi)
4: *
5: * @link http://github.com/sastrawi/sastrawi for the canonical source repository
6: * @license https://github.com/sastrawi/sastrawi/blob/master/LICENSE The MIT License (MIT)
7: */
8:
9: namespace Sastrawi\Morphology\Disambiguator;
10:
11: /**
12: * Disambiguate Prefix Rule 3
13: * Rule 3 : berCAerV -> ber-CAerV where C != 'r'
14: *
15: */
16: class DisambiguatorPrefixRule3 implements DisambiguatorInterface
17: {
18: /**
19: * Disambiguate Prefix Rule 3
20: * Rule 3 : berCAerV -> ber-CAerV where C != 'r'
21: * return string|null
22: */
23: public function disambiguate($word)
24: {
25: $matches = null;
26: $contains = preg_match('/^ber([bcdfghjklmnpqrstvwxyz])([a-z])er([aiueo])(.*)$/', $word, $matches);
27:
28: if ($contains === 1) {
29: if ($matches[1] === 'r') {
30: return;
31: }
32:
33: return $matches[1] . $matches[2] . 'er' . $matches[3] . $matches[4];
34: }
35: }
36: }
37: