如是我闻: 用ChatGPT来帮我检查英语语法,是我使用最多的一个场景。最近发现了一个可以直观显示修改过后的文本差异的Pyhton库,这里将它的用法总结一下。
效果展示:
- 下载
redlines
pip install redlines
redlines
基本使用
from redlines import Redlines
from IPython.display import Markdown, display
text = f"""
Got this for my daughter for her birthday cuz she keeps taking \
mine from my room. Yes, adults also like pandas too. She takes \
it everywhere with her, and it's super soft and cute. One of the \
ears is a bit lower than the other, and I don't think that was \
designed to be asymmetrical. It's a bit small for what I paid for it \
though. I think there might be other options that are bigger for \
the same price. It arrived a day earlier than expected, so I got \
to play with it myself before I gave it to my daughter.
"""
reponse = f"""
Got this for my daughter for her birthday because she keeps taking mine from my room. Yes, adults also like pandas too. She takes it everywhere with her, and it's super soft and cute. However, one of the ears is a bit lower than the other, and I don't think that was designed to be asymmetrical. Additionally, it's a bit small for what I paid for it. I believe there might be other options that are bigger for the same price. On the positive side, it arrived a day earlier than expected, so I got to play with it myself before I gave it to my daughter."""
diff = Redlines(text, reponse) # 对比两段文本
display(Markdown(diff.output_markdown)) # 以Markdown输出
输出:
更多说明: redlines 0.4.2
非常的有品
以上