Example #1
0
def kon_delta(p, q):
    """For two phonemes, get distance."""
    len_p, len_q = len(p), len(q)
    if len_p == len_q == 1:
        # phoneme is individual token
        return aline.delta(p, q)
    else:
        # phoneme is a pair of tokens
        paired = zip(p * len_q, q * len_p)
        return sum(aline.delta(ii, jj) for ii, jj in paired) / 2
Example #2
0
 def test_aline_delta(self):
     """
     Test aline for computing the difference between two segments
     """
     result = aline.delta('p', 'q')
     expected = 20.0
     
     self.assertEqual(result, expected)
     
     result = aline.delta('a', 'A')
     expected = 0.0
     
     self.assertEqual(result, expected)
Example #3
0
    def test_aline_delta(self):
        """
        Test aline for computing the difference between two segments
        """
        result = aline.delta('p', 'q')
        expected = 20.0

        self.assertEqual(result, expected)

        result = aline.delta('a', 'A')
        expected = 0.0

        self.assertEqual(result, expected)
def test_aline_delta():
    """
    Test aline for computing the difference between two segments
    """
    assert aline.delta("p", "q") == 20.0
    assert aline.delta("a", "A") == 0.0
Example #5
0
def test_aline_delta():
    """
    Test aline for computing the difference between two segments
    """
    assert aline.delta('p', 'q') == 20.0
    assert aline.delta('a', 'A') == 0.0