예제 #1
0
    def test_lovins_snowball(self):
        """Test abydos.stemmer.lovins (Snowball testset).

        These test cases are from
        https://github.com/snowballstem/snowball-data/tree/master/lovins
        """
        #  Snowball Lovins test set
        with codecs.open(TESTDIR + '/corpora/snowball_lovins.csv',
                         encoding='utf-8') as snowball_testset:
            next(snowball_testset)
            for line in snowball_testset:
                if line[0] != '#':
                    line = line.strip().split(',')
                    word, stem = line[0], line[1]
                    self.assertEqual(lovins(word), stem.lower())
예제 #2
0
    def test_lovins_snowball(self):
        """test abydos.stemmer.lovins (Snowball testset)

        These test cases are from
        https://github.com/snowballstem/snowball-data/tree/master/lovins
        """
        #  Snowball Lovins test set
        with codecs.open(TESTDIR+'/corpora/snowball_lovins.csv',
                         encoding='utf-8') as snowball_testset:
            next(snowball_testset)
            for line in snowball_testset:
                if line[0] != '#':
                    line = line.strip().split(',')
                    word, stem = line[0], line[1]
                    self.assertEqual(lovins(word), stem.lower())
예제 #3
0
    def test_lovins(self):
        """Test abydos.stemmer.Lovins."""
        # base case
        self.assertEqual(self.stmr.stem(''), '')

        # test cases from Lovins' "Development of a Stemming Algorithm":
        # http://www.mt-archive.info/MT-1968-Lovins.pdf
        self.assertEqual(self.stmr.stem('magnesia'), 'magnes')
        self.assertEqual(self.stmr.stem('magnesite'), 'magnes')
        self.assertEqual(self.stmr.stem('magnesian'), 'magnes')
        self.assertEqual(self.stmr.stem('magnesium'), 'magnes')
        self.assertEqual(self.stmr.stem('magnet'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetic'), 'magnet')
        self.assertEqual(self.stmr.stem('magneto'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetically'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetism'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetite'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetitic'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetizable'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetization'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetize'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetometer'), 'magnetometer')
        self.assertEqual(self.stmr.stem('magnetometric'), 'magnetometer')
        self.assertEqual(self.stmr.stem('magnetometry'), 'magnetometer')
        self.assertEqual(self.stmr.stem('magnetomotive'), 'magnetomot')
        self.assertEqual(self.stmr.stem('magnetron'), 'magnetron')
        self.assertEqual(self.stmr.stem('metal'), 'metal')
        self.assertEqual(self.stmr.stem('metall'), 'metal')
        self.assertEqual(self.stmr.stem('metallically'), 'metal')
        self.assertEqual(self.stmr.stem('metalliferous'), 'metallifer')
        self.assertEqual(self.stmr.stem('metallize'), 'metal')
        self.assertEqual(self.stmr.stem('metallurgical'), 'metallurg')
        self.assertEqual(self.stmr.stem('metallurgy'), 'metallurg')
        self.assertEqual(self.stmr.stem('induction'), 'induc')
        self.assertEqual(self.stmr.stem('inductance'), 'induc')
        self.assertEqual(self.stmr.stem('induced'), 'induc')
        self.assertEqual(self.stmr.stem('angular'), 'angl')
        self.assertEqual(self.stmr.stem('angle'), 'angl')

        # missed branch test cases
        self.assertEqual(self.stmr.stem('feminism'), 'fem')

        # Test wrapper
        self.assertEqual(lovins('magnesia'), 'magnes')
예제 #4
0
    def test_lovins(self):
        """Test abydos.stemmer.Lovins."""
        # base case
        self.assertEqual(self.stmr.stem(''), '')

        # test cases from Lovins' "Development of a Stemming Algorithm":
        # http://www.mt-archive.info/MT-1968-Lovins.pdf
        self.assertEqual(self.stmr.stem('magnesia'), 'magnes')
        self.assertEqual(self.stmr.stem('magnesite'), 'magnes')
        self.assertEqual(self.stmr.stem('magnesian'), 'magnes')
        self.assertEqual(self.stmr.stem('magnesium'), 'magnes')
        self.assertEqual(self.stmr.stem('magnet'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetic'), 'magnet')
        self.assertEqual(self.stmr.stem('magneto'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetically'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetism'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetite'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetitic'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetizable'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetization'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetize'), 'magnet')
        self.assertEqual(self.stmr.stem('magnetometer'), 'magnetometer')
        self.assertEqual(self.stmr.stem('magnetometric'), 'magnetometer')
        self.assertEqual(self.stmr.stem('magnetometry'), 'magnetometer')
        self.assertEqual(self.stmr.stem('magnetomotive'), 'magnetomot')
        self.assertEqual(self.stmr.stem('magnetron'), 'magnetron')
        self.assertEqual(self.stmr.stem('metal'), 'metal')
        self.assertEqual(self.stmr.stem('metall'), 'metal')
        self.assertEqual(self.stmr.stem('metallically'), 'metal')
        self.assertEqual(self.stmr.stem('metalliferous'), 'metallifer')
        self.assertEqual(self.stmr.stem('metallize'), 'metal')
        self.assertEqual(self.stmr.stem('metallurgical'), 'metallurg')
        self.assertEqual(self.stmr.stem('metallurgy'), 'metallurg')
        self.assertEqual(self.stmr.stem('induction'), 'induc')
        self.assertEqual(self.stmr.stem('inductance'), 'induc')
        self.assertEqual(self.stmr.stem('induced'), 'induc')
        self.assertEqual(self.stmr.stem('angular'), 'angl')
        self.assertEqual(self.stmr.stem('angle'), 'angl')

        # missed branch test cases
        self.assertEqual(self.stmr.stem('feminism'), 'fem')

        # Test wrapper
        self.assertEqual(lovins('magnesia'), 'magnes')