|
import streamlit as st |
|
|
|
|
|
st.markdown(""" |
|
<style> |
|
.main-title { |
|
font-size: 36px; |
|
color: #4A90E2; |
|
font-weight: bold; |
|
text-align: center; |
|
} |
|
.sub-title { |
|
font-size: 24px; |
|
color: #4A90E2; |
|
margin-top: 20px; |
|
} |
|
.section { |
|
background-color: #f9f9f9; |
|
padding: 15px; |
|
border-radius: 10px; |
|
margin-top: 20px; |
|
} |
|
.section h2 { |
|
font-size: 22px; |
|
color: #4A90E2; |
|
} |
|
.section p, .section ul { |
|
color: #666666; |
|
} |
|
.link { |
|
color: #4A90E2; |
|
text-decoration: none; |
|
} |
|
</style> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown('<div class="main-title">Evaluate Sentence Grammar</div>', unsafe_allow_html=True) |
|
|
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<p>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.</p> |
|
<p>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.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown('<div class="sub-title">Understanding the T5 Transformer for Grammar Evaluation</div>', unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<p>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.</p> |
|
<p>This capability is particularly useful in proofreading tools, automated editing software, and educational applications, where precise grammar is essential.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown('<div class="sub-title">Performance and Use Cases</div>', unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<p>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.</p> |
|
<p>Use cases include academic proofreading, professional editing, and everyday writing checks, where maintaining grammatical integrity is of utmost importance.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown('<div class="sub-title">Implementing Grammar Evaluation</div>', unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<p>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.</p> |
|
</div> |
|
""", 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') |
|
|
|
|
|
st.text(""" |
|
+--------------------+ |
|
|corrections.result | |
|
+--------------------+ |
|
|unacceptable | |
|
+--------------------+ |
|
""") |
|
|
|
|
|
st.markdown('<div class="sub-title">Choosing the Right T5 Model for Grammar Evaluation</div>', unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<p>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.</p> |
|
<p>Explore other T5 models tailored for different NLP tasks on the <a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Models Hub</a> to find the best fit for your specific needs.</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown('<div class="sub-title">References</div>', unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<ul> |
|
<li><a class="link" href="https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html" target="_blank">Google AI Blog</a>: Exploring Transfer Learning with T5</li> |
|
<li><a class="link" href="https://sparknlp.org/models?annotator=T5Transformer" target="_blank">Spark NLP Model Hub</a>: Explore T5 models</li> |
|
<li><a class="link" href="https://github.com/google-research/text-to-text-transfer-transformer" target="_blank">GitHub</a>: T5 Transformer repository</li> |
|
<li><a class="link" href="https://arxiv.org/abs/1910.10683" target="_blank">T5 Paper</a>: Detailed insights from the developers</li> |
|
</ul> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown('<div class="sub-title">Community & Support</div>', unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<ul> |
|
<li><a class="link" href="https://sparknlp.org/" target="_blank">Official Website</a>: Documentation and examples</li> |
|
<li><a class="link" href="https://join.slack.com/t/spark-nlp/shared_invite/zt-198dipu77-L3UWNe_AJ8xqDk0ivmih5Q" target="_blank">Slack</a>: Live discussion with the community and team</li> |
|
<li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp" target="_blank">GitHub</a>: Bug reports, feature requests, and contributions</li> |
|
<li><a class="link" href="https://medium.com/spark-nlp" target="_blank">Medium</a>: Spark NLP articles</li> |
|
<li><a class="link" href="https://www.youtube.com/channel/UCmFOjlpYEhxf_wJUDuz6xxQ/videos" target="_blank">YouTube</a>: Video tutorials</li> |
|
</ul> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown('<div class="sub-title">Quick Links</div>', unsafe_allow_html=True) |
|
|
|
st.markdown(""" |
|
<div class="section"> |
|
<ul> |
|
<li><a class="link" href="https://sparknlp.org/docs/en/quickstart" target="_blank">Getting Started</a></li> |
|
<li><a class="link" href="https://nlp.johnsnowlabs.com/models" target="_blank">Pretrained Models</a></li> |
|
<li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp/tree/master/examples/python/annotation/text/english" target="_blank">Example Notebooks</a></li> |
|
<li><a class="link" href="https://sparknlp.org/docs/en/install" target="_blank">Installation Guide</a></li> |
|
</ul> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|