from queue import Queue as Pipe
from threading import Thread
import re


class Filter1(Thread):
    q_in: Pipe
    q_out: Pipe

    def run(self):
        text = self.q_in.get()
        contexts = re.split(r"TEXT|GRAPH|PICTURE", text)
        labels = re.findall(r"TEXT|GRAPH|PICTURE", text)
        contexts = [i.strip("\n, „“") for i in contexts[1:]]

        for i, j in zip(labels, contexts):
            self.q_out.put(i)
            self.q_out.put(j)
        self.q_out.put(EOFError(""))
