Code Duplication    Length = 15-16 lines in 2 locations

processors/api.py 2 locations

@@ 456-471 (lines=16) @@
453
        return json.dumps(self.to_JSON_dict(), sort_keys=True, indent=4)
454
455
class TextWithURL(object):
456
457
    def __init__(self, text, url):
458
        self.text = text
459
        # TODO: throw exception if url is invalid
460
        self.url = url
461
462
    def to_JSON_dict(self):
463
        jdict = dict()
464
        jdict["text"] = self.text
465
        jdict["url"] = self.url
466
        return jdict
467
468
    def to_JSON(self):
469
        return json.dumps(self.to_JSON_dict(), sort_keys=True, indent=4)
470
471
class DocumentWithRules(object):
472
473
    def __init__(self, document, rules):
474
        # TODO: throw exception if isinstance(document, Document) is False
@@ 440-454 (lines=15) @@
437
# transmitted to the server for processing
438
#############################################
439
440
class TextWithRules(object):
441
442
    def __init__(self, text, rules):
443
        self.text = text
444
        self.rules = rules
445
446
    def to_JSON_dict(self):
447
        jdict = dict()
448
        jdict["text"] = self.text
449
        jdict["rules"] = self.rules
450
        return jdict
451
452
    def to_JSON(self):
453
        return json.dumps(self.to_JSON_dict(), sort_keys=True, indent=4)
454
455
class TextWithURL(object):
456
457
    def __init__(self, text, url):