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 RemoveDerivationalSuffix implements VisitorInterface
21: {
22: public function visit(ContextInterface $context)
23: {
24: $result = $this->removeSuffix($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: 'DS'
35: );
36:
37: $context->addRemoval($removal);
38: $context->setCurrentWord($result);
39: }
40: }
41:
42: 43: 44: 45: 46: 47: 48: 49:
50: public function removeSuffix($word)
51: {
52: return preg_replace('/(wan|wati|is|isme|isasi|i|kan|an)$/', '', $word, 1);
53: }
54: }
55: