面向Java开发者的ChatGPT提示词工程(10)

在ChatGPT的众多应用中,拼写检查和语法检查犹如璀璨的明珠,受到广大用户的热烈追捧。我对此深信不疑,且一直在实践中坚定不移。特别是在使用非母语的情况下,它的作用更为显著。接下来,让我们通过一些常见的拼写和语法问题的实例,一探ChatGPT如何巧妙地帮助我们解决这些难题的神奇之处。

拼写检查

首先,让我们看一个英语句子中存在拼写错误的例子:

You are welcone to leavn ChatGPT at the One More Society.

接下来,我们将利用ChatGPT来找出这个英语句子中的拼写错误:

java 复制代码
public static void main(String[] args) {
    String text = "You are welcone to leavn ChatGPT at the One More Society.";

    String prompt = "分析三个反引号之间的英文句子,找到英文句子中的拼写错误。如果没有找到,就回答"没有找到拼写错误"。\n"
            + "```%s```";
    String response = getCompletion(String.format(prompt, text));
    System.out.println(response);
}

然后,让我们一起执行这段代码,看一下输出结果:

在这个句子中有两个拼写错误。"welcone" 应该是 "welcome","leavn" 应该是 "leave"。

让我再来尝试没有拼写错误的句子。

java 复制代码
public static void main(String[] args) {
    String text = "You are welcome to learn ChatGPT at the One More Society.";

    String prompt = "分析三个反引号之间的英文句子,找到英文句子中的拼写错误。如果没有找到,就回答"没有找到拼写错误"。\n"
            + "```%s```";
    String response = getCompletion(String.format(prompt, text));
    System.out.println(response);
}

输出结果如下:

没有找到拼写错误。

语法检查

让我们看一个英语句子中存在语法错误的例子:

You is welcome to learns ChatGPT at the One More Society.

接下来,我们将利用ChatGPT来找出这个英语句子中的语法错误:

java 复制代码
public static void main(String[] args) {
    String text = "You is welcome to learns ChatGPT at the One More Society.";

    String prompt = "分析三个反引号之间的英文句子,找到英文句子中的语法错误。如果没有找到,就回答"没有找到语法错误"。\n"
            + "```%s```";
    String response = getCompletion(String.format(prompt, text));
    System.out.println(response);
}

然后,让我们一起执行这段代码,看一下输出结果:

这个句子中有两个语法错误。首先,"You is" 应该改为 "You are"。其次,"learns" 应该改为 "learn"。所以,正确的句子应该是 "You are welcome to learn ChatGPT at the One More Society."

让我再来尝试没有语法错误的句子。

java 复制代码
public static void main(String[] args) {
    String text = "You are welcome to learn ChatGPT at the One More Society.";

    String prompt = "分析三个反引号之间的英文句子,找到英文句子中的语法错误。如果没有找到,就回答"没有找到语法错误"。\n"
            + "```%s```";
    String response = getCompletion(String.format(prompt, text));
    System.out.println(response);
}

输出结果如下:

没有找到语法错误。

错别字检查

除了在英文的拼写及语法的海洋中,寻找那些隐藏的错误,我们也可以邀请ChatGPT作为我们的伙伴,一同在中文的错别字森林中进行探索。

让我们看一个中文句子中存在错别字的例子:

欢迎来倒万猫学社学习ChatGPT。

接下来,我们将利用ChatGPT来找出这个中文句子中的错别字:

java 复制代码
public static void main(String[] args) {
    String text = "欢迎来倒万猫学社学习ChatGPT。";

    String prompt = "分析三个反引号之间的中文句子,找到中文句子中的错别字。如果没有找到,就回答"没有找到错别字"。\n"
            + "```%s```";
    String response = getCompletion(String.format(prompt, text));
    System.out.println(response);
}

然后,让我们一起执行这段代码,看一下输出结果:

"倒万猫学社"中的"倒"字应该是"到",所以正确的句子应该是"欢迎来到万猫学社学习ChatGPT。"

让我再来尝试没有错别字的句子。

java 复制代码
public static void main(String[] args) {
    String text = "欢迎来到万猫学社学习ChatGPT。";

    String prompt = "分析三个反引号之间的中文句子,找到中文句子中的错别字。如果没有找到,就回答"没有找到错别字"。\n"
            + "```%s```";
    String response = getCompletion(String.format(prompt, text));
    System.out.println(response);
}

输出结果如下:

没有找到错别字

应用实例

我们经常会遇到各种AI英语作文批改工具,其中一些甚至需要付费使用。然而,只要掌握了本文的提示词技巧,你就能够自己创建一个AI作文批改助手。

假设我们的目标是批改初中一年级学生的英语作文。首先,我们需要让ChatGPT扮演一个初中英语老师的角色。然后,我们让它帮助我们检查作文中的拼写和语法错误,并将修正后的作文输出。

这样,我们就能够利用AI的力量,以更高效、准确的方式批改英语作文,同时也能为学生提供更具针对性的反馈,帮助他们提高英语写作水平。

让我们看一个英语作文的例子:

Last summer, I go to the beach with my family. It was very fun and exciting. We swim in the sea and build sand castles. The water was very warlm and the sand was hot. I see many fishs in the water and they was beautiful.

接下来,我们将利用ChatGPT进行英语作文的批改:

java 复制代码
public static void main(String[] args) {
    String text = "Last summer, I go to the beach with my family. It was very fun and exciting. "
            + "We swim in the sea and build sand castles. The water was very warlm and the sand was hot. "
            + "I see many fishs in the water and they was beautiful.";

    String prompt = "你是一名优秀的初中英语老师。三个反引号之间的是学生写的英语作文。\n"
            + "第一步:找到英语作文中的所有的拼写错误。如果找到,给出正确的拼写;如果没有找到,就回答"没有找到拼写错误"。\n"
            + "第二步:找到英语作文中的所有的语法错误。如果找到,给出正确的写法,并且详细描述相关的语法知识点;如果没有找到,就回答"没有找到语法错误"。\n"
            + "第三步:修改英语作文中的拼写错误和语法错误后输出整篇作文。\n\n"
            + "```%s```";
    String response = getCompletion(String.format(prompt, text));
    System.out.println(response);
}

然后,让我们一起执行这段代码,看一下输出结果:

第一步:找到英语作文中的所有的拼写错误。

  1. "warlm" 应该是 "warm"
  2. "fishs" 应该是 "fish"

第二步:找到英语作文中的所有的语法错误。

  1. "I go to the beach with my family." 应该是 "I went to the beach with my family." 这是一个过去时的句子,所以应该使用过去式的动词。
  2. "We swim in the sea and build sand castles." 应该是 "We swam in the sea and built sand castles." 同样,这是一个过去时的句子,所以应该使用过去式的动词。
  3. "I see many fish in the water and they was beautiful." 应该是 "I saw many fish in the water and they were beautiful." 这是一个过去时的句子,所以应该使用过去式的动词。另外,"they" 是复数,所以应该使用 "were" 而不是 "was"。

第三步:修改英语作文中的拼写错误和语法错误后输出整篇作文。

Last summer, I went to the beach with my family. It was very fun and exciting. We swam in the sea and built sand castles. The water was very warm and the sand was hot. I saw many fish in the water and they were beautiful.

总结

本文详细介绍了如何利用ChatGPT进行拼写检查、语法检查和错别字检查。

首先通过实例展示了如何使用ChatGPT找出英语句子中的拼写错误,然后又通过另一个实例展示了如何找出英语句子中的语法错误。

此外,还介绍了如何使用ChatGPT找出中文句子中的错别字。

最后,通过一个实例展示了如何利用ChatGPT批改英语作文,包括找出作文中的拼写错误和语法错误,并给出修正后的作文。

《面向Java开发者的ChatGPT提示词工程》总目录

相关推荐
yt948329 分钟前
C#实现CAN通讯接口
java·linux·前端
阿维同学11 分钟前
自动驾驶关键算法深度研究
人工智能·算法·自动驾驶
卷到起飞的数分12 分钟前
Java零基础笔记07(Java编程核心:面向对象编程 {类,static关键字})
java·开发语言·笔记
盼小辉丶15 分钟前
TensorFlow深度学习实战——基于自编码器构建句子向量
人工智能·深度学习·tensorflow
舌尖上的五香20 分钟前
ThreadLocal、InheritableThreadLocal、TransmittableThreadLocal
java
okok__TXF21 分钟前
Sentinel入门篇【流量治理】
java·sentinel
谁他个天昏地暗23 分钟前
Java 实现 Excel 文件对比与数据填充
java·开发语言·excel
倔强的石头1061 小时前
Bright Data MCP+Trae :快速构建电商导购助手垂直智能体
大数据·人工智能
今天背单词了吗9801 小时前
算法学习笔记:11.冒泡排序——从原理到实战,涵盖 LeetCode 与考研 408 例题
java·学习·算法·排序算法·冒泡排序
小付爱coding1 小时前
Spring AI Alibaba 来啦!!!
人工智能