import gradio as gr from interfaces.cap import demo as cap_demo from interfaces.manifesto import demo as manifesto_demo from interfaces.sentiment import demo as sentiment_demo from interfaces.emotion import demo as emotion_demo from interfaces.ner import demo as ner_demo from interfaces.ner import download_models as download_spacy_models from spacy import glossary entities = ["CARDINAL", "DATE", "EVENT", "FAC", "GPE", "LANGUAGE", "LAW", "LOC", "MONEY", "NORP", "ORDINAL", "ORG", "PERCENT", "PERSON", "PRODUCT", "QUANTITY", "TIME", "WORK_OF_ART"] ent_dict = glossary.GLOSSARY ent_sum = [f'{ent} = {ent_dict[ent]}' for ent in entities ] with gr.Blocks() as demo: gr.Markdown( f"""

Babel Machine Demo

This is a demo for text classification using language models finetuned on data labeled by CAP, Manifesto Project, sentiment, and emotion coding systems.
For the coding of complete datasets, please visit the official Babel Machine site.
Please note that named entity inputs are case sensitive.
For named entity recognition the following labels are used:

""" gr.TabbedInterface( interface_list=[cap_demo, manifesto_demo, sentiment_demo, emotion_demo, ner_demo], tab_names=["CAP", "Manifesto", "Sentiment (3)", "Emotions (8)", "Named Entity Recognition"], ) if __name__ == "__main__": download_spacy_models() demo.launch() # TODO: add all languages & domains