processors.tests.test_ds.DSTests.test_interval()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nop 1
dl 0
loc 17
rs 9.75
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
3
import unittest
4
from processors import *
5
import os
6
7
8
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
9
10
'''
11
Testing named entity recognition.
12
IOB notation should be neutralized for bionlp
13
'''
14
15
class DSTests(unittest.TestCase):
16
17
    def test_interval(self):
18
        a = Interval(start=1, end=3)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Interval does not seem to be defined.
Loading history...
19
        b = Interval(start=3, end=4)
20
        c = Interval(start=2, end=3)
21
        # commutative
22
        self.assertTrue(a.overlaps(c), "Problem detecting overlapping Intervals")
23
        self.assertTrue(c.overlaps(a), "Problem detecting overlapping Intervals")
24
        # commutative
25
        self.assertFalse(a.overlaps(b), "Problem detecting overlapping Intervals")
26
        self.assertFalse(b.overlaps(a), "Problem detecting overlapping Intervals")
27
        # check contains
28
        self.assertFalse(a.contains(b), "Problem with Interval.contains")
29
        self.assertTrue(a.contains(c), "Problem with Interval.contains")
30
        # check size
31
        self.assertEqual(a.size(), 2, "Problem with Interval.size")
32
        self.assertEqual(b.size(), 1, "Problem with Interval.size")
33
        self.assertEqual(c.size(), 1, "Problem with Interval.size")
34
35
if __name__ == "__main__":
36
    unittest.main()
37