# Path: segeval/similarity/weight.py
# def weight_s_scale(substitutions, max_s, min_s=1):
#     '''
#     Default weighting function for substitution edit operations by the distance between ordinal boundary types.
#     '''
# 
#     return weight_t_scale(substitutions, max_s - min_s + 1)
# 
# def weight_t_scale(transpositions, max_n):
#     '''
#     Default weighting function for transposition edit operations by the distance that transpositions span.
#     '''
#     numerator = 0
#     for transposition in transpositions:
#         numerator += abs(transposition[0] - transposition[1])
#     return Decimal(numerator) / max_n


import unittest
from decimal import Decimal
from segeval.similarity import (weight_s_scale, weight_t_scale)
Tests weight functions.

.. moduleauthor:: Chris Fournier <chris.m.fournier@gmail.com>
'''
from __future__ import absolute_import


class TestWeight(unittest.TestCase):

    '''
    Test similarity helper functions.
    '''

    def test_weight_t_scale(self):
        '''
        Test to see that penalties for substitution edits are discounted from
        3 to 1.5.
        '''
        transpositions = [[1,2], [1,3], [1,4]]
        weight = weight_t_scale(transpositions, 4)
        self.assertEqual(weight, Decimal('1.5'))

    def test_weight_s_scale(self):
        '''
        Test to see that penalties for transposition edits are discounted from
        3 to 1.5.
        '''
        substitutions = [[1,2], [1,3], [1,4]]
        weight = weight_s_scale(substitutions, 4)
        self.assertEqual(weight, Decimal('1.5'))

# Path: segeval/similarity/weight.py
# def weight_s_scale(substitutions, max_s, min_s=1):
#     '''
#     Default weighting function for substitution edit operations by the distance between ordinal boundary types.
#     '''
# 
#     return weight_t_scale(substitutions, max_s - min_s + 1)
# 
# def weight_t_scale(transpositions, max_n):
#     '''
#     Default weighting function for transposition edit operations by the distance that transpositions span.
#     '''
#     numerator = 0
#     for transposition in transpositions:
#         numerator += abs(transposition[0] - transposition[1])
#     return Decimal(numerator) / max_n


# Path: segeval/similarity/weight_test.py
import unittest
from decimal import Decimal
from segeval.similarity import (weight_s_scale, weight_t_scale)

Tests weight functions.

.. moduleauthor:: Chris Fournier <chris.m.fournier@gmail.com>
'''
from __future__ import absolute_import


class TestWeight(unittest.TestCase):

    '''
    Test similarity helper functions.
    '''

    def test_weight_t_scale(self):
        '''
        Test to see that penalties for substitution edits are discounted from
        3 to 1.5.
        '''
        transpositions = [[1,2], [1,3], [1,4]]
        weight = weight_t_scale(transpositions, 4)
        self.assertEqual(weight, Decimal('1.5'))

    def test_weight_s_scale(self):
        '''
        Test to see that penalties for transposition edits are discounted from
        3 to 1.5.
        '''
        substitutions = [[1,2], [1,3], [1,4]]
        weight = weight_s_scale(substitutions, 4)
        self.assertEqual(weight, Decimal('1.5'))

        weight = weight_s_scale(substitutions, 5, 2)