該 ai.fix_grammar 功能使用生成式 AI 來糾正輸入文本的拼寫、語法和標點符號,只需一行代碼即可。
備註
概觀
此 ai.fix_grammar 函式適用於 Spark DataFrames。 您必須將現有輸入資料行的名稱指定為參數。
函式會傳回新的 DataFrame,其中包含儲存在輸出資料行中的每個輸入文字資料列的更正文字。
語法
df.ai.fix_grammar(input_col="input", output_col="corrections")
參數
| 名稱 | Description |
|---|---|
input_col 為必填項目 |
包含現有直欄名稱的 字串 ,其中包含要更正拼字、文法和標點符號的輸入文字值。 |
output_col 可選 |
包含新資料行名稱的 字串 ,用於儲存每一列輸入文字的更正文字。 如果您未設定此參數,則會為輸出資料行產生預設名稱。 |
error_col 可選 |
字串,其中包含新欄位的名稱,以存儲處理每一行輸入文字時產生的任何 OpenAI 錯誤。 如果您未設定此參數,則會為錯誤資料行產生預設名稱。 如果輸入資料列沒有任何錯誤,則此資料列中的值會 null。 |
退貨
函式會傳回 Spark DataFrame ,其中包含一個新資料行,其中包含輸入資料行中每一列文字的更正文字。 如果輸入文字 null,則結果會 null。
Example
# This code uses AI. Always review output for mistakes.
df = spark.createDataFrame([
("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.",)
], ["text"])
results = df.ai.fix_grammar(input_col="text", output_col="corrections")
display(results)
此範例程式碼儲存格提供下列輸出:
相關內容
用 ai.analyze_sentiment檢測情緒。
使用 ai.classify 對文本進行分類。
用 ai.embed 產生向量嵌入。
使用 ai_extract 擷取實體。
用 ai.fix_grammar修復語法。
使用 ai.generate_response 回答自訂使用者提示。
使用 ai.similarity 計算相似度。
使用 ai.summarize 總結文本。
使用 ai.translate 翻譯文本。
進一步了解 全套 AI 功能。
自訂 AI功能的配置。
我們錯過了您需要的功能嗎? 請在 Fabric Ideas 論壇上提出建議。