Last active
November 5, 2016 09:27
-
-
Save briehanlombaard/362eb7900df9872259a556367498c5fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML> | |
| <html> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
| <link rel="stylesheet" href="main.css"> | |
| <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.0/babel.min.js"></script> | |
| <script type="text/babel" src="https://raw.githubusercontent.com/explosion/displacy-ent/master/assets/js/displacy-ent.js"></script> | |
| </head> | |
| <body> | |
| <div id="displacy"></div> | |
| <script type="text/babel"> | |
| const displacy = new displaCyENT('http://localhost:8000', { | |
| container: '#displacy' | |
| }); | |
| const entities = { | |
| "entities": [ | |
| { | |
| "name": "Michelangelo Caravaggio", | |
| "type": "PERSON", | |
| "metadata": { | |
| "wikipedia_url": "http://en.wikipedia.org/wiki/Caravaggio" | |
| }, | |
| "salience": 0.75942981, | |
| "mentions": [ | |
| { | |
| "text": { | |
| "content": "Michelangelo Caravaggio", | |
| "beginOffset": 0 | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| "name": "Italian", | |
| "type": "LOCATION", | |
| "metadata": { | |
| "wikipedia_url": "http://en.wikipedia.org/wiki/Italy" | |
| }, | |
| "salience": 0.20193423, | |
| "mentions": [ | |
| { | |
| "text": { | |
| "content": "Italian", | |
| "beginOffset": 25 | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| "name": "The Calling of Saint Matthew", | |
| "type": "WORK_OF_ART", | |
| "metadata": { | |
| "wikipedia_url": "http://en.wikipedia.org/wiki/index.html?curid=2838808" | |
| }, | |
| "salience": 0.03863598, | |
| "mentions": [ | |
| { | |
| "text": { | |
| "content": "The Calling of Saint Matthew", | |
| "beginOffset": 56 | |
| } | |
| } | |
| ] | |
| } | |
| ], | |
| "language": "en" | |
| }; | |
| let spans = []; | |
| for (let e of entities.entities) { | |
| for (let m of e.mentions) { | |
| spans.push({ | |
| start: m.text.beginOffset, | |
| end: m.text.beginOffset + m.text.content.length, | |
| type: e.type | |
| }); | |
| } | |
| } | |
| const text = "Michelangelo Caravaggio, Italian painter, is known for 'The Calling of Saint Matthew'."; | |
| const ents = ['person', 'org', 'gpe', 'location', 'product', 'work_of_art']; | |
| displacy.render(text, spans, ents); | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| color: #111; | |
| font-size: 20px; | |
| font-family: sans-serif; | |
| line-height: 40px; | |
| -moz-text-size-adjust: 100%; | |
| -webkit-text-size-adjust: 100%; | |
| -ms-text-size-adjust: 100%; | |
| -webkit-font-smoothing: antialiased; | |
| text-rendering: optimizeLegibility; | |
| -moz-osx-font-smoothing: grayscale; | |
| } | |
| .entities { | |
| line-height: 2 | |
| } | |
| [data-entity] { | |
| border-radius: 0.25em; | |
| padding: 0.25em 0.35em; | |
| margin: 0 0.25em; | |
| line-height: 1; | |
| display: inline-block; | |
| } | |
| [data-entity]:after { | |
| box-sizing: border-box; | |
| content: attr(data-entity); | |
| font-size: 0.6em; | |
| line-height: 1; | |
| padding: 0.35em 0.35em; | |
| border-radius: 0.35em; | |
| text-transform: uppercase; | |
| display: inline-block; | |
| vertical-align: middle; | |
| margin: 0 0 0.1rem 0.5rem | |
| } | |
| [data-entity][data-entity="person"] { | |
| background: rgba(166, 226, 45, 0.2); | |
| border-color: #a6e22d | |
| } | |
| [data-entity][data-entity="person"]:after { | |
| background: #a6e22d | |
| } | |
| [data-entity][data-entity="norp"] { | |
| background: rgba(224, 0, 132, 0.2); | |
| border-color: #e00084 | |
| } | |
| [data-entity][data-entity="norp"]:after { | |
| background: #e00084 | |
| } | |
| [data-entity][data-entity="facility"] { | |
| background: rgba(67, 198, 252, 0.2); | |
| border-color: #43c6fc | |
| } | |
| [data-entity][data-entity="facility"]:after { | |
| background: #43c6fc | |
| } | |
| [data-entity][data-entity="org"] { | |
| background: rgba(67, 198, 252, 0.2); | |
| border-color: #43c6fc | |
| } | |
| [data-entity][data-entity="org"]:after { | |
| background: #43c6fc | |
| } | |
| [data-entity][data-entity="gpe"] { | |
| background: rgba(253, 151, 32, 0.2); | |
| border-color: #fd9720 | |
| } | |
| [data-entity][data-entity="gpe"]:after { | |
| background: #fd9720 | |
| } | |
| [data-entity][data-entity="loc"], | |
| [data-entity][data-entity="location"] { | |
| background: rgba(253, 151, 32, 0.2); | |
| border-color: #fd9720 | |
| } | |
| [data-entity][data-entity="loc"]:after, | |
| [data-entity][data-entity="location"]:after { | |
| background: #fd9720 | |
| } | |
| [data-entity][data-entity="product"] { | |
| background: rgba(142, 125, 255, 0.2); | |
| border-color: #8e7dff | |
| } | |
| [data-entity][data-entity="product"]:after { | |
| background: #8e7dff | |
| } | |
| [data-entity][data-entity="event"] { | |
| background: rgba(255, 204, 0, 0.2); | |
| border-color: #fc0 | |
| } | |
| [data-entity][data-entity="event"]:after { | |
| background: #fc0 | |
| } | |
| [data-entity][data-entity="work_of_art"] { | |
| background: rgba(255, 204, 0, 0.2); | |
| border-color: #fc0 | |
| } | |
| [data-entity][data-entity="work_of_art"]:after { | |
| background: #fc0 | |
| } | |
| [data-entity][data-entity="language"] { | |
| background: rgba(255, 204, 0, 0.2); | |
| border-color: #fc0 | |
| } | |
| [data-entity][data-entity="language"]:after { | |
| background: #fc0 | |
| } | |
| [data-entity][data-entity="date"] { | |
| background: rgba(47, 187, 171, 0.2); | |
| border-color: #2fbbab | |
| } | |
| [data-entity][data-entity="date"]:after { | |
| background: #2fbbab | |
| } | |
| [data-entity][data-entity="time"] { | |
| background: rgba(47, 187, 171, 0.2); | |
| border-color: #2fbbab | |
| } | |
| [data-entity][data-entity="time"]:after { | |
| background: #2fbbab | |
| } | |
| [data-entity][data-entity="percent"] { | |
| background: rgba(153, 153, 153, 0.2); | |
| border-color: #999 | |
| } | |
| [data-entity][data-entity="percent"]:after { | |
| background: #999 | |
| } | |
| [data-entity][data-entity="money"] { | |
| background: rgba(153, 153, 153, 0.2); | |
| border-color: #999 | |
| } | |
| [data-entity][data-entity="money"]:after { | |
| background: #999 | |
| } | |
| [data-entity][data-entity="quantity"] { | |
| background: rgba(153, 153, 153, 0.2); | |
| border-color: #999 | |
| } | |
| [data-entity][data-entity="quantity"]:after { | |
| background: #999 | |
| } | |
| [data-entity][data-entity="ordinal"] { | |
| background: rgba(153, 153, 153, 0.2); | |
| border-color: #999 | |
| } | |
| [data-entity][data-entity="ordinal"]:after { | |
| background: #999 | |
| } | |
| [data-entity][data-entity="cardinal"] { | |
| background: rgba(153, 153, 153, 0.2); | |
| border-color: #999 | |
| } | |
| [data-entity][data-entity="cardinal"]:after { | |
| background: #999 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment