【问题标题】:How to get the text inside the TextBlob result?如何获取 TextBlob 结果中的文本?
【发布时间】:2020-05-31 07:10:17
【问题描述】:

我正在使用 TextBlob 进行拼写检查。这是我的代码:

corrected_words = []

for i in data_words:
    for j in i:
        corrected_words.append((TextBlob(j).correct()))

我得到的结果如下:

[TextBlob("me"),
 TextBlob("correct"),
 TextBlob("table"),
 TextBlob("breakfast")]

如何简单地输出引号内的文本? 也尝试过使用 .text 来处理 correct() 函数,但没有成功。

TIA

【问题讨论】:

    标签: spell-checking textblob


    【解决方案1】:

    我跑了下面的代码:

    corrected_words = []
    data_words = ['Swiss', 'Blank', 'leeve', "doen", "coem"]
    
    for i in data_words:
        corrected_words.append((TextBlob(i).correct()))
    
        
    print("correct words: ")
    print(corrected_words)
    print("")
    
    print("Final strings:")
    for i in corrected_words:
        print(i)    
    

    找到的输出如下:

    正确的话:

    [TextBlob("Swiss"), TextBlob("Flank"), TextBlob("leave"), TextBlob("down"), TextBlob("come")]

    最后的字符串:

    瑞士

    侧翼

    离开

    向下

    让我知道这是否适合你。

    【讨论】:

      猜你喜欢
      • 2014-08-17
      • 1970-01-01
      • 2017-08-04
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      • 2015-10-02
      • 1970-01-01
      • 2010-10-22
      相关资源
      最近更新 更多