import streamlit as st
# Custom CSS for better styling
st.markdown("""
""", unsafe_allow_html=True)
# Title
st.markdown('
Evaluate Sentence Grammar
', unsafe_allow_html=True)
# Introduction Section
st.markdown("""
Evaluating sentence grammar is crucial for maintaining the clarity and accuracy of written communication. Whether you're reviewing content for publication, editing academic work, or checking everyday writing, ensuring grammatical correctness is key.
This page showcases the implementation of a grammar evaluation pipeline using advanced NLP models. We leverage the T5 Transformer model, fine-tuned for assessing sentence grammar, to evaluate and identify potential errors in sentences.
""", unsafe_allow_html=True)
# T5 Transformer Overview
st.markdown('Understanding the T5 Transformer for Grammar Evaluation
', unsafe_allow_html=True)
st.markdown("""
The T5 (Text-To-Text Transfer Transformer) model, developed by Google, is a powerful tool for various NLP tasks, including grammar evaluation. When configured with the appropriate task, T5 can assess sentences for grammatical correctness, helping users identify and correct errors.
This capability is particularly useful in proofreading tools, automated editing software, and educational applications, where precise grammar is essential.
""", unsafe_allow_html=True)
# Performance Section
st.markdown('Performance and Use Cases
', unsafe_allow_html=True)
st.markdown("""
The T5 model exhibits strong performance in grammar evaluation tasks, providing accurate and contextually relevant assessments. This makes it a valuable resource for anyone looking to improve the quality of written content.
Use cases include academic proofreading, professional editing, and everyday writing checks, where maintaining grammatical integrity is of utmost importance.
""", unsafe_allow_html=True)
# Implementation Section
st.markdown('Implementing Grammar Evaluation
', unsafe_allow_html=True)
st.markdown("""
The following example demonstrates how to implement a grammar evaluation pipeline using Spark NLP. The pipeline includes a document assembler and the T5 model configured for evaluating sentence grammar.
""", unsafe_allow_html=True)
st.code('''
import sparknlp
from sparknlp.base import *
from sparknlp.annotator import *
from pyspark.ml import Pipeline
# Initialize Spark NLP
spark = sparknlp.start()
# Define the pipeline stages
documentAssembler = DocumentAssembler() \\
.setInputCol("text") \\
.setOutputCol("documents")
t5 = T5Transformer.pretrained('t5_base') \\
.setTask("cola:") \\
.setInputCols(["documents"])\\
.setMaxOutputLength(200)\\
.setOutputCol("prediction")
pipeline = Pipeline().setStages([documentAssembler, t5])
# Input data example
data = spark.createDataFrame([["She don't knows nothing about what's happening in the office."]]).toDF("text")
# Apply the pipeline for grammar evaluation
result = pipeline.fit(data).transform(data)
result.select("prediction.result").show(truncate=False)
''', language='python')
# Example Output
st.text("""
+--------------------+
|corrections.result |
+--------------------+
|unacceptable |
+--------------------+
""")
# Model Info Section
st.markdown('Choosing the Right T5 Model for Grammar Evaluation
', unsafe_allow_html=True)
st.markdown("""
For evaluating sentence grammar, we use the model: "t5_base" with the task set to "cola:". This model is specifically tuned to assess grammatical correctness in English sentences.
Explore other T5 models tailored for different NLP tasks on the Spark NLP Models Hub to find the best fit for your specific needs.
""", unsafe_allow_html=True)
# References Section
st.markdown('References
', unsafe_allow_html=True)
st.markdown("""
""", unsafe_allow_html=True)
# Community & Support Section
st.markdown('Community & Support
', unsafe_allow_html=True)
st.markdown("""
- Official Website: Documentation and examples
- Slack: Live discussion with the community and team
- GitHub: Bug reports, feature requests, and contributions
- Medium: Spark NLP articles
- YouTube: Video tutorials
""", unsafe_allow_html=True)
# Quick Links Section
st.markdown('Quick Links
', unsafe_allow_html=True)
st.markdown("""
""", unsafe_allow_html=True)