a
    L9f                     @   sT   d dl Z d dlmZ d dlZd dlZd dlZd dlZd dlm	Z	 G dd de	Z
dS )    N)Path)HydraHeadAppc                   @   s   e Zd ZdddZdd ZdS )SpacyNLP c                 K   s   | j | || _d S )N)__dict__updatetitle)selfr   kwargs r   F/Users/putuwistika/Documents/TRILAK/hydralit-example/apps/spacy_nlp.py__init__   s    zSpacyNLP.__init__c                 C   sp   t tjttjdd}d}d}d}dd }t	d tj
d	d
d td tj||g dd
||d d S )Nextraszmodels.jsonZen_core_web_smzgDavid Bowie moved to the US in 1974, initially staying in New York City before settling in Los Angeles.zD**Explore trained [spaCy v3.0](https://nightly.spacy.io) pipelines**c              	   S   s@   z"t d| j dd}|jd W S  ttfy:   Y dS 0 d S )Nz.lang.z	.examplesZspacyr   r   )	importlibimport_modulelangZ	sentencesModuleNotFoundErrorImportError)Znlpexamplesr   r   r   get_default_text   s
    z&SpacyNLP.run.<locals>.get_default_texta1  Source for this great app is from the Streamlit gallery [NLP with spaCy](https://github.com/ines/spacy-streamlit-demo). An example of how easy it is to convert an existing application and use within a Hydralit multi-page application, see the secret saurce [here] (https://github.com/TangleSpace/hydralit).z<br><br>T)unsafe_allow_htmla  Yes, this application will show an error if you don't have the 'en_core_web_sm' Spacy model installed, this was left to show that if an app crashes, it won't affect the HydraApp or the other HydraHeadApps, this app will crash and burn on it's own. If you want to fix the error, just install the missing model with [**python -m spacy download en_core_web_sm**](https://spacy.io/usage))parserZnerZ
similaritytokens)Zdefault_modelZvisualizersZshow_visualizer_selectZsidebar_descriptionr   )srsly	read_jsonospathjoinr   __file__parentst	subheadermarkdowninfospacy_streamlitZ	visualize)r	   ZMODELSZDEFAULT_MODELZDEFAULT_TEXTDESCRIPTIONr   r   r   r   run   s     

zSpacyNLP.runN)r   )__name__
__module____qualname__r   r&   r   r   r   r   r   
   s   
r   )r$   pathlibr   	streamlitr    r   r   r   hydralitr   r   r   r   r   r   <module>   s   