Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The ai.fix_grammar function uses generative AI to correct the spelling, grammar, and punctuation of input text, with a single line of code.
Note
- This article covers using ai.fix_grammar with pandas. To use ai.fix_grammar with PySpark, see this article.
- See other AI functions in this overview article.
- Learn how to customize the configuration of AI functions.
Overview
The ai.fix_grammar function extends the pandas Series class. To correct the spelling, grammar, and punctuation of each row of input, call the function on a pandas DataFrame text column.
The function returns a pandas Series that contains corrected text values, which can be stored in a new DataFrame column.
Syntax
df["corrections"] = df["input"].ai.fix_grammar()
Parameters
None
Returns
The function returns a pandas Series that contains corrected text for each input text row. If the input text is null, the result is null.
Example
# This code uses AI. Always review output for mistakes.
df = pd.DataFrame([
"There are an error here.",
"She and me go weigh back. We used to hang out every weeks.",
"The big picture are right, but you're details is all wrong."
], columns=["text"])
df["corrections"] = df["text"].ai.fix_grammar()
display(df)
This example code cell provides the following output:
Related content
Detect sentiment with ai.analyze_sentiment.
Categorize text with ai.classify.
Generate vector embeddings with ai.embed.
Extract entities with ai_extract.
Answer custom user prompts with ai.generate_response.
Calculate similarity with ai.similarity.
Summarize text with ai.summarize.
Translate text with ai.translate.
Learn more about the full set of AI functions.
Customize the configuration of AI functions.
Did we miss a feature you need? Suggest it on the Fabric Ideas forum.