Coverage for python/lum/clu/odin/highlighter.py: 0%
18 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-17 18:41 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-17 18:41 +0000
1from termcolor import colored
3__all__ = ["OdinHighlighter"]
5class OdinHighlighter:
7 @staticmethod
8 def LABEL(token):
9 return colored(token, color="red", attrs=["bold"])
11 @staticmethod
12 def ARG(token):
13 return colored(token, on_color="on_green", attrs=["bold"])
15 @staticmethod
16 def TRIGGER(token):
17 return colored(token, on_color="on_blue", attrs=["bold"])
19 @staticmethod
20 def CONCEAL(token):
21 return colored(token, on_color="on_grey", attrs=["concealed"])
23 @staticmethod
24 def MENTION(token):
25 return colored(token, on_color="on_yellow")
27 # @staticmethod
28 # def highlight_mention(mention):
29 # """
30 # Formats text of mention
31 # """
32 # text_span = mention.sentenceObj.words[:]
33 # # format TBM span like an arg
34 # if mention.type == "TextBoundMention":
35 # for i in range(mention.start, mention.end):
36 # text_span[i] = OdinHighlighter.ARG(text_span[i])
37 # if mention.arguments:
38 # for (role, args) in mention.arguments.items():
39 # for arg in args:
40 # for i in range(arg.start, arg.end):
41 # text_span[i] = OdinHighlighter.ARG(text_span[i])
42 # # format trigger distinctly from args
43 # if mention.trigger:
44 # trigger = mention.trigger
45 # for i in range(trigger.start, trigger.end):
46 # text_span[i] = OdinHighlighter.TRIGGER(text_span[i])
48 # # highlight tokens contained in mention span
49 # for i in range(mention.start, mention.end):
50 # text_span[i] = OdinHighlighter.MENTION(text_span[i])
51 # mention_span = OdinHighlighter.MENTION(" ").join(text_span[mention.start:mention.end])
52 # # highlight spaces in mention span
53 # formatted_text = " ".join(text_span[:mention.start]) + " " + mention_span + " " + " ".join(text_span[mention.end:])
54 # return formatted_text.strip()