I've created a custom html template. It highlights some text. That works. Now I also want to show the pattern matched text. How can I do that in my custom recipe?
Here is my html template -
Subject: {{subject}} From: {{from}} To: {{to}}
{{body}}
If there is any pattern matched in the content - subject or body, I'd like they be highlighted as what textcat.teach with pattern does.
Ah, well, in that case you'd actually have to implement the rendering logic for that yourself – slice the text on each match character offsets and then wrap the matched slices in some HTML tag. The algorithm for that isn't complicated and you can see an example of this in the displacy code – but not sure if it's worth it?
Instead of doing it all in HTML, it might be easier to just use a custom interface with blocks and use Prodigy's built-in ner interface that can already render highlighted spans in the text. So your first block would be your HTML block with the html_template and the second block would be the ner block that'd render the "text" and a list of "spans" containing the matches.
Yes, blocks worked! Because my text is a bit long so the result is not prefect since user needs to scroll down to see the better formatted content.
I implemented a classification + html view. Here is my configuration -
I guess you could leave out the {{body}} in your HTML template and only show the formatted text in the block? (Or maybe I'm misunderstanding the problem.) You could also experiment with some custom theme settings like font size, maximum card width etc. to fit more content on the screen.
That's exactly what I did. I put the context information in html at the top and the classification view at the bottom. The result is not perfect. But it's good for mow. I will play with other css settings. Thanks.