difference between similar() and concordance in nltk

前端 未结 5 1830
夕颜
夕颜 2021-01-01 02:33

I have read the text1.similar(\"monstrous\") and text1.concordance(\"monstrous\") from this.

Where I couldn\'t get the satisfactory answer for the difference betwee

5条回答
  •  生来不讨喜
    2021-01-01 02:44

    I will explain with example:

    text1.similar("monstrous")
    

    will output the words with similar context such as word1 ______ word2. For example it outputs the word doleful. If you run:

    text1.concordance("monstrous")
    

    You will see among the matches the line:

    that has survived the flood ; most monstrous and most mountainous ! That Himmal

    If you run:

    text1.concordance("doleful")
    

    You will see among the matches the line:

    ite perspectives . There ' s a most doleful and most mocking funeral ! The sea

    And

    text1.common_contexts(["monstrous", "doleful"])
    

    will output common surrounding words of monstrous and doleful which are "most" and "and"

    most_and

提交回复
热议问题