Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /gradio-app_gradio /demo /text_analysis /run.py
| import gradio as gr | |
| import os | |
| os.system('python -m spacy download en_core_web_sm') | |
| import spacy # type: ignore | |
| from spacy import displacy # type: ignore | |
| nlp = spacy.load("en_core_web_sm") | |
| def text_analysis(text): | |
| doc = nlp(text) | |
| html = displacy.render(doc, style="dep", page=True) | |
| html = ( | |
| "<div style='max-width:100%; max-height:360px; overflow:auto'>" | |
| + html | |
| + "</div>" | |
| ) | |
| pos_count = { | |
| "char_count": len(text), | |
| "token_count": 0, | |
| } | |
| pos_tokens = [] | |
| for token in doc: | |
| pos_tokens.extend([(token.text, token.pos_), (" ", None)]) | |
| return pos_tokens, pos_count, html | |
| demo = gr.Interface( | |
| text_analysis, | |
| gr.Textbox(placeholder="Enter sentence here..."), | |
| ["highlight", "json", "html"], | |
| examples=[ | |
| ["What a beautiful morning for a walk!"], | |
| ["It was the best of times, it was the worst of times."], | |
| ], | |
| api_name="predict", | |
| ) | |
| demo.launch() | |
Xet Storage Details
- Size:
- 960 Bytes
- Xet hash:
- ffe5cd6834e91da154b3930f0e933c61145070acdb34a8fe8d4093835ccade90
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.