Skip to content

test_lang_guessing

Test language recognition.

TestTextCat

Bases: unittest.TestCase

Test frases collected from nrk.no article collection.

Source code in /home/anders/projects/CorpusTools/corpustools/test/test_lang_guessing.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class TestTextCat(unittest.TestCase):
    """Test frases collected from nrk.no article collection."""

    def setUp(self):
        """Set up common resource."""
        self.guesser = text_cat.Classifier()

    @parameterized.expand(test_sentences)
    def test_textcat(self, input_text):
        """Test language recognition on input strings.

        The input strings have been classified as sme, while they in
        fact are nob.

        Args:
            input_text (str): text that should be classified by
                the language guesser.
        """
        self.assertEqual(self.guesser.classify(input_text), "nob")

    @parameterized.expand(test_sentences)
    def test_langid(self, input_text):
        """Test language recognition on input strings.

        The input strings have been classified as sme, while they in
        fact are nob.

        Args:
            input_text (str): text that should be classified by
                the language guesser.
        """
        self.assertEqual(langid.classify(input_text)[0], "no")

setUp()

Set up common resource.

Source code in /home/anders/projects/CorpusTools/corpustools/test/test_lang_guessing.py
93
94
95
def setUp(self):
    """Set up common resource."""
    self.guesser = text_cat.Classifier()

test_langid(input_text)

Test language recognition on input strings.

The input strings have been classified as sme, while they in fact are nob.

Parameters:

Name Type Description Default
input_text str

text that should be classified by the language guesser.

required
Source code in /home/anders/projects/CorpusTools/corpustools/test/test_lang_guessing.py
110
111
112
113
114
115
116
117
118
119
120
121
@parameterized.expand(test_sentences)
def test_langid(self, input_text):
    """Test language recognition on input strings.

    The input strings have been classified as sme, while they in
    fact are nob.

    Args:
        input_text (str): text that should be classified by
            the language guesser.
    """
    self.assertEqual(langid.classify(input_text)[0], "no")

test_textcat(input_text)

Test language recognition on input strings.

The input strings have been classified as sme, while they in fact are nob.

Parameters:

Name Type Description Default
input_text str

text that should be classified by the language guesser.

required
Source code in /home/anders/projects/CorpusTools/corpustools/test/test_lang_guessing.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
@parameterized.expand(test_sentences)
def test_textcat(self, input_text):
    """Test language recognition on input strings.

    The input strings have been classified as sme, while they in
    fact are nob.

    Args:
        input_text (str): text that should be classified by
            the language guesser.
    """
    self.assertEqual(self.guesser.classify(input_text), "nob")