微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

你能修复我的代码来计算词汇丰富度吗?

如何解决你能修复我的代码来计算词汇丰富度吗?

我正在尝试使用 LexicalRichness (https://pypi.org/project/lexicalrichness/)。我复制并粘贴了代码

import lexicalrichness
from lexicalrichness import LexicalRichness

text = """Measure of textual lexical diversity,computed as the mean length of sequential words in
                a text that maintains a minimum threshold TTR score.

                Iterates over words until TTR scores falls below a threshold,then increase factor
                counter by 1 and start over. McCarthy and Jarvis (2010,pg. 385) recommends a factor
                threshold in the range of [0.660,0.750].
                (McCarthy 2005,McCarthy and Jarvis 2010)"""

use_TextBlob=True
lex = lexicalrichness(text)

print(lex.words)
print(lex.terms)
print(lex.ttr)
print(lex.rttr)
print(lex.cttr)
print(lex.msttr(segment_window=25))
print(lex.mattr(window_size=25))
print(lex.mtld(threshold=0.72))
print(lex.hdd(draws=42))

但它不起作用(错误信息是:TypeError: 'module' object is not callable)

你能帮我吗?提前致谢!

解决方法

检查这一行是否大写:lex = LexicalRichness(text)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。