<commit_before>import unittest
import natasha

class BaseTestCase(unittest.TestCase):

    def setUp(self):
        self.combinator = natasha.Combinator(natasha.DEFAULT_GRAMMARS)

class PersonGrammarsTestCase(BaseTestCase):

    def test_full(self):
        grammar, rule, _ = next(self.combinator.extract("Шерер <NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "Full")

    def test_full_reversed(self):
        grammar, rule, _ = next(self.combinator.extract("<NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "FullReversed")

    def test_firstname_and_lastname(self):
        grammar, rule, _ = next(self.combinator.extract("<NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "FisrtnameAndLastname")

    def test_lastname_and_firstname(self):
        grammar, rule, _ = next(self.combinator.extract("<NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "LastnameAndFirstname")

    def test_lastname(self):
        grammar, rule, _ = next(self.combinator.extract("Шерер"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "Lastname")

    def test_firstname(self):
        grammar, rule, _ = next(self.combinator.extract("Анна"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "Firstname")

class DateTestCase(BaseTestCase):

    def test_full(self):
        grammar, rule, _ = next(self.combinator.extract("21 мая 1996 года"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "Full")

    def test_full_with_digits(self):
        grammar, rule, _ = next(self.combinator.extract("21/05/1996"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "FullWithDigits")
        grammar, rule, _ = next(self.combinator.extract("21 05 1996"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "FullWithDigits")

    def test_day_and_month(self):
        grammar, rule, _ = next(self.combinator.extract("21 мая"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "DayAndMonth")

    def test_year(self):
        grammar, rule, _ = next(self.combinator.extract("21 год"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "Year")

    def test_year_float(self):
        grammar, rule, _ = next(self.combinator.extract("1.5 года"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "YearFloat")

    def test_partial_year(self):
        grammar, rule, _ = list(self.combinator.extract("в конце 2015 года"))[-1]
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "PartialYearObject")

    def test_partial_month(self):
        grammar, rule, _ = next(self.combinator.extract("в конце мая"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "PartialMonthObject")

    def test_month(self):
        grammar, rule, _ = next(self.combinator.extract("мая"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "Month")

    def test_day_of_week(self):
        grammar, rule, _ = next(self.combinator.extract("в пятницу"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "DayOfWeek")<commit_msg>Tests for geo grammar<commit_after>import unittest
import natasha

class BaseTestCase(unittest.TestCase):

    def setUp(self):
        self.combinator = natasha.Combinator(natasha.DEFAULT_GRAMMARS)

class PersonGrammarsTestCase(BaseTestCase):

    def test_full(self):
        grammar, rule, _ = next(self.combinator.extract("Шерер <NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "Full")

    def test_full_reversed(self):
        grammar, rule, _ = next(self.combinator.extract("<NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "FullReversed")

    def test_firstname_and_lastname(self):
        grammar, rule, _ = next(self.combinator.extract("<NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "FisrtnameAndLastname")

    def test_lastname_and_firstname(self):
        grammar, rule, _ = next(self.combinator.extract("<NAME>"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "LastnameAndFirstname")

    def test_lastname(self):
        grammar, rule, _ = next(self.combinator.extract("Шерер"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "Lastname")

    def test_firstname(self):
        grammar, rule, _ = next(self.combinator.extract("Анна"))
        self.assertEqual(grammar, natasha.Person)
        self.assertEqual(rule, "Firstname")

class DateTestCase(BaseTestCase):

    def test_full(self):
        grammar, rule, _ = next(self.combinator.extract("21 мая 1996 года"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "Full")

    def test_full_with_digits(self):
        grammar, rule, _ = next(self.combinator.extract("21/05/1996"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "FullWithDigits")
        grammar, rule, _ = next(self.combinator.extract("21 05 1996"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "FullWithDigits")

    def test_day_and_month(self):
        grammar, rule, _ = next(self.combinator.extract("21 мая"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "DayAndMonth")

    def test_year(self):
        grammar, rule, _ = next(self.combinator.extract("21 год"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "Year")

    def test_year_float(self):
        grammar, rule, _ = next(self.combinator.extract("1.5 года"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "YearFloat")

    def test_partial_year(self):
        grammar, rule, _ = list(self.combinator.extract("в конце 2015 года"))[-1]
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "PartialYearObject")

    def test_partial_month(self):
        grammar, rule, _ = next(self.combinator.extract("в конце мая"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "PartialMonthObject")

    def test_month(self):
        grammar, rule, _ = next(self.combinator.extract("мая"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "Month")

    def test_day_of_week(self):
        grammar, rule, _ = next(self.combinator.extract("в пятницу"))
        self.assertEqual(grammar, natasha.Date)
        self.assertEqual(rule, "DayOfWeek")

class GeoTestCase(BaseTestCase):

    def test_federal_district(self):
        grammar, rule, _ = next(self.combinator.extract("северо-западный федеральный округ"))
        self.assertEqual(grammar, natasha.Geo)
        self.assertEqual(rule, "FederalDistrict")

    def test_federal_district_abbr(self):
        grammar, rule, _ = next(self.combinator.extract("северо-западный ФО"))
        self.assertEqual(grammar, natasha.Geo)
        self.assertEqual(rule, "FederalDistrictAbbr")

    def test_region(self):
        grammar, rule, _ = next(self.combinator.extract("северо-западная область"))
        self.assertEqual(grammar, natasha.Geo)
        self.assertEqual(rule, "Region")
        with self.assertRaises(StopIteration):
            next(self.combinator.extract("северо-западный область"))

    def test_complex_object(self):
        grammar, rule, _ = next(self.combinator.extract("северный кипр"))
        self.assertEqual(grammar, natasha.Geo)
        self.assertEqual(rule, "ComplexObject")
        with self.assertRaises(StopIteration):
            next(self.combinator.extract("северная кипр"))

    def test_partial_object(self):
        grammar, rule, _ = next(self.combinator.extract("на юго-западе кипра"))
        self.assertEqual(grammar, natasha.Geo)
        self.assertEqual(rule, "PartialObject")

    def test_object(self):
        grammar, rule, _ = next(self.combinator.extract("Москва́"))
        self.assertEqual(grammar, natasha.Geo)
        self.assertEqual(rule, "Object")
{'fraction_non_alphanumeric': 0.12617272071205196, 'fraction_numerical': 0.007938417127736349, 'mean_word_length': 3.4346666666666668, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2080036', 'n_tokens_mistral': 2689, 'n_tokens_neox': 2593, 'n_words': 415}