1: <?php
2: 3: 4: 5: 6: 7:
8:
9: namespace Sastrawi\Stemmer\Context\Visitor;
10:
11: use Sastrawi\Stemmer\Context\ContextInterface;
12: use Sastrawi\Stemmer\Context\Removal;
13:
14: 15: 16: 17: 18: 19:
20: class RemovePlainPrefix implements VisitorInterface
21: {
22: public function visit(ContextInterface $context)
23: {
24: $result = $this->remove($context->getCurrentWord());
25:
26: if ($result != $context->getCurrentWord()) {
27: $removedPart = preg_replace("/$result/", '', $context->getCurrentWord(), 1);
28:
29: $removal = new Removal(
30: $this,
31: $context->getCurrentWord(),
32: $result,
33: $removedPart,
34: 'DP'
35: );
36:
37: $context->addRemoval($removal);
38: $context->setCurrentWord($result);
39: }
40: }
41:
42: 43: 44: 45: 46: 47:
48: public function remove($word)
49: {
50: return preg_replace('/^(di|ke|se)/', '', $word, 1);
51: }
52: }
53: