DSTests   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_interval() 0 17 1
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
import unittest
5
from processors import *
6
import os
7
8
9
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
10
11
'''
12
Testing named entity recognition.
13
IOB notation should be neutralized for bionlp
14
'''
15
16
class DSTests(unittest.TestCase):
17
18
    def test_interval(self):
19
        a = Interval(start=1, end=3)
20
        b = Interval(start=3, end=4)
21
        c = Interval(start=2, end=3)
22
        # commutative
23
        self.assertTrue(a.overlaps(c), "Problem detecting overlapping Intervals")
24
        self.assertTrue(c.overlaps(a), "Problem detecting overlapping Intervals")
25
        # commutative
26
        self.assertFalse(a.overlaps(b), "Problem detecting overlapping Intervals")
27
        self.assertFalse(b.overlaps(a), "Problem detecting overlapping Intervals")
28
        # check contains
29
        self.assertFalse(a.contains(b), "Problem with Interval.contains")
30
        self.assertTrue(a.contains(c), "Problem with Interval.contains")
31
        # check size
32
        self.assertEqual(a.size(), 2, "Problem with Interval.size")
33
        self.assertEqual(b.size(), 1, "Problem with Interval.size")
34
        self.assertEqual(c.size(), 1, "Problem with Interval.size")
35
36
if __name__ == "__main__":
37
    unittest.main()
38