goonhoon
goonhoon

Reputation: 13

Customising DisplaCy html output for span categorizer

I am currently using Spacy's displacy to visualise my spancat trained model. Displacy renders a html file which I would like to further customise but I am unable to do so because of the way it is rendered:

The visualisation looks like this:

visualisation

And the html of the visualisation looks like this (only first few lines included):

<div class="spans" style="line-height: 2.5; direction: ltr">1                                                                      Exhibit 10.2 

                            CO - HOSTING AGREEMENT 

   This Co - Hosting Agreement ( the &quot; Agreement &quot; ) is made by and between NETWORKS ASSOCIATES , INC . , a Delaware corporation , doing business as Network Associates , Inc. , with its principal place of business at 3965 Freedom Circle , Santa Clara , California 95054 ( &quot; NAI &quot; ) , and SOFTWARE.NET CORPORATION , a Delaware corporation , a.k.a . Beyond.com , with its principal place of business at 1195 West Fremont Avenue , Sunnyvale , California 94087 ( &quot; Co - Host &quot; ) . 
<span style="font-weight: bold; display: inline-block; position: relative; height: 60px;">
    The
    
<span style="background: #ddd; top: 40px; height: 4px; left: -1px; width: calc(100% + 2px); position: absolute;">
</span>

    
<span style="background: #ddd; top: 40px; height: 4px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; left: -1px; width: calc(100% + 2px); position: absolute;">
    <span style="background: #ddd; z-index: 10; color: #000; top: -0.5em; padding: 2px 3px; position: absolute; font-size: 0.6em; font-weight: bold; line-height: 1; border-radius: 3px">
        Effective Date
    </span>
</span>`

I would like to keep the markdown of the original text as well as customise in css the labels, make them clickable and so on. Where should I look to be able to do this?

I saw that the displacy.js library can be accessed online, but it appears that this only applies to entity labeling and dependency parsing, not to span categorizer.

Thanks for any help :)

What I expected: the html will include every span highlighting (the label) in a separate class so that I can access it and customise it in CSS further.

What I got: there are no classes and I don't know how to access the specific parts of text in css without classes. Is it possible to change the way the html gets rendered?

Upvotes: 1

Views: 231

Answers (0)

Related Questions