I am trying to give recognized sentences in Text Tk(). I want to highlight with different colors to certain tokens in accordance their labels. I am deploying a model result to GUI. The model output text file format is like this:
# 1.0000
This B-LOC
is I-LOC
example I-LOC
of E-LOC
my O
data O
format O
. O
In O
this B-ORG
place E-ORG
, O
characters O
of O
my O
language O
is B-PNAME
applied E-PNAME
. O
And S-PNAME
help O
Me. O
Here is the code example.
if l_list[i] == "S-PNAME" or "B-PNAME" or "I-PNAME" or "E-PNAME":
self.output.update()
self.output.insert(END,s_list[i])
self.output.config(foreground='red')
elif l_list[i] == "S-ORG" or "B-ORG" or "I-ORG" or "E-ORG":
self.output.update()
self.output.insert(END,s_list[i])
self.output.config(foreground='pink')
else:
self.output.update()
self.output.insert(END,s_list[i])
I want to color tokens with P-NAME tags with red colour, LOC tags with pink colours etc....But in my output all sentences are coloured red.