from copy import copy
from collections import deque

from yargy import FactParser

from natasha.grammars import Person, Geo


class Combinator(object):

    DEFAULT_GRAMMARS = [
        Person,
        Geo,
    ]

    def __init__(self, grammars=None, cache_size=50000):
        self.grammars = grammars or self.DEFAULT_GRAMMARS
        self.parser = FactParser(cache_size=cache_size)

    def extract(self, text):
        tokens = deque(self.parser.tokenizer.transform(text))
        for grammar in self.grammars:
            for grammar_type, rule in grammar.__members__.items():
                for match in self.parser.extract(copy(tokens), rule.value):
                    yield (grammar, grammar_type, match)

@@ -116,16 +116,29 @@
 son, Geo
+, Money, Date
 %0A%0A%0Aclass
@@ -184,16 +184,31 @@
 ARS = %5B%0A
+        Money,%0A
         
@@ -228,16 +228,30 @@
    Geo,%0A
+        Date,%0A
     %5D%0A%0A 

Add new grammars to Combinator.DEFAULT_GRAMMARS