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 2
13: * Rule 2 : berCAP -> ber-CAP where C != 'r' AND P != 'er'
14: */
15: class DisambiguatorPrefixRule2 implements DisambiguatorInterface
16: {
17: public function disambiguate($word)
18: {
19: $matches = null;
20: $contains = preg_match('/^ber([bcdfghjklmnpqrstvwxyz])([a-z])(.*)$/', $word, $matches);
21:
22: if ($contains === 1) {
23: if (preg_match('/^er(.*)$/', $matches[3]) === 1) {
24: return;
25: }
26:
27: return $matches[1] . $matches[2] . $matches[3];
28: }
29: }
30: }
31: