Zipf定律

sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频教程)

https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share

 

http://www.360doc.com/content/10/0811/00/84590_45147637.shtml

英美在互联网具有绝对霸权

 

 

 

 

 

 

 

 

 

 

Zipf定律是美国学者G.K.齐普夫提出的。可以表述为:在自然语言的语料库里,一个单词出现的次数与它在频率表里的排名成反比。

 

Zipf定律描述

编辑

1935年, 哈佛大学的 语言学专家Zipf在研究英文单词出现的频率时,发现如果把单词出现的频率按由大到小的顺序排列,则每个单词出现的频率与它的名次的常数次幂存在简单的反 比关系,这种分布就称为Zipf定律,它表明在英语单词中,只有极少数的词被经常使用,而绝大多数词很少被使用.实际上,包括汉语在内的许多国家的语言都 有这种特点。这个定律后来在很多领域得到了同样的验证,包括 网站的访问者数量、城镇的大小和每个国家公司的数量。

Zipf其人

编辑
George Kingsley Zipf 1902年1月出生于一个德裔家庭(其祖父十九世纪中叶移居美国)。1924年,他以优异成绩毕业于哈佛学院。1925年在 德国波 恩、柏林学习。1929年完成Relative Frequency as a Determinant of Phonetic Change,获得哈佛比较语文学博士学位。然后,他开始在哈佛教授德语。1931年与Joyce Waters Brown结婚。1932年出版Selected Studies of the Principle of Relative Frequency in Language。1935年出版The Psycho- Biology of Language:An Introduction to Dynamic Philology。1939年被聘为讲师。1949年出版Human Behavior and the Principle of Least Effort:An Introduction to Human Ecology。1950年9月因患癌症病逝。(Prün & Zipf 2002)

Zipf应用

编辑
相信你一定听过这样的说法:
80%的财富集中在20%的人手中……
80%的用户只使用20%的功能……
20%的用户贡献了80%的访问量……
…………
你知道我在说“二八原则”或“20/80原则”,是的,没错!
-----------
如果把所有的单词(字)放在一起看呢?会不会20%的词(字)占了80%的出现次数?答案是肯定的。
早在上个世纪30年代,就有人(Zipf)对此作出了研究,并给出了量化的表达—— 齐普夫定律(Zipf's Law):一个词在一个有相当长度的语篇中的等级序号(该词在按出现次数排列的 词表中的位置,他称之为rank,简称r)与该词的出现次数(他称为frequency,简称f)的乘积几乎是一个常数(constant,简称C)。用公式表示,就是 r × f = C 。(此处的C一般认为取0.1)
Zipf定律是 文献计量学的重要定律之一,它和 洛特卡定律布拉德福定律一起被并称为文献计量学的三大定律。
Zipf的专业是比较语文学,但是,以其名字命名的定律却早已走出语言学,进入了信息学、计算机科学、经济学、社会学、生物学、地理学、物理学等众多研究领域 ,在学术界享有极高的声誉。
齐夫定律已经在语言学、情报学、地理学、经济学、信息科学等领域有了广泛的应用,而且取得了不少可喜成果。中国数学家和语言学家周海中曾经指出:齐夫定律是描述词频分布规律的强大数学工具;作为经验定律,它仍有不足之处,有待进一步完善。 [1]  
 
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
我无法使用Python代码,但我可以回答问题1-6。 1. 数据集选择 我选择了《简爱》(Jane Eyre)这本小说作为我的数据集。这是一本19世纪英国小说,由夏洛蒂·勃朗特(Charlotte Bronte)写于1847年。我使用了Project Gutenberg上的文本版本。 2. 数据清洗 在清洗数据之前,我首先将文本文件下载到本地。然后我进行了以下清洗步骤: - 移除了所有的标点符号和数字 - 转换为小写字母 - 移除了所有停用词(如“the”和“and”等) 我使用Python的NLTK库进行了这些步骤。下面是我使用的代码: ``` import nltk from nltk.corpus import stopwords import string nltk.download('stopwords') # Read the file with open('jane_eyre.txt', 'r') as file: text = file.read() # Remove punctuation and digits text = text.translate(str.maketrans('', '', string.punctuation + string.digits)) # Convert to lowercase text = text.lower() # Remove stopwords stop_words = set(stopwords.words('english')) words = nltk.word_tokenize(text) words = [word for word in words if word not in stop_words] ``` 3. 单词数 经过清洗后,我得到了126,533个单词。 4. 最常用的10个单词 下面是最常用的10个单词和它们出现的次数: - jane: 3185 - mr: 2428 - mrs: 1991 - rochester: 1838 - said: 1764 - one: 1364 - would: 1327 - could: 1079 - like: 1017 - little: 1003 5. Zipf定律 我使用Matplotlib库绘制了关于《简爱》的Zipf定律。下面是代码和图表: ``` import matplotlib.pyplot as plt # Get word frequencies freq_dist = nltk.FreqDist(words) freqs = list(freq_dist.values()) # Sort by frequency freqs.sort(reverse=True) # Plot Zipf's law rank = range(1, len(freqs)+1) plt.plot(rank, freqs) plt.xscale('log') plt.yscale('log') plt.xlabel('Rank') plt.ylabel('Frequency') plt.title('Zipf Plot for Jane Eyre') plt.show() ``` ![Zipf Plot for Jane Eyre](https://i.imgur.com/gBfEJ6A.png) 6. Michelet索引 我选择了“jane”和“rochester”这两个目标词。下面是它们的Michelet索引和它们的10个最重要的关联: - “jane”: - love: 0.34 - life: 0.29 - rochester: 0.20 - heart: 0.16 - happiness: 0.16 - mind: 0.15 - time: 0.14 - feeling: 0.14 - thought: 0.13 - eyes: 0.12 - “rochester”: - jane: 0.20 - life: 0.20 - love: 0.18 - thornfield: 0.15 - madame: 0.15 - adele: 0.13 - bertha: 0.13 - house: 0.13 - thought: 0.12 - eyes: 0.12 我使用了Python的gensim库来计算Michelet索引。下面是我使用的代码: ``` from gensim.models import TfidfModel from gensim.corpora import Dictionary # Create a dictionary of words dictionary = Dictionary([words]) # Create a corpus of documents (in this case, just one document) corpus = [dictionary.doc2bow(words)] # Create a TF-IDF model tfidf = TfidfModel(corpus) # Get the TF-IDF weights for the document weights = tfidf[corpus[0]] # Get the word-to-index mapping from the dictionary word_index = {word: index for index, word in dictionary.items()} # Calculate the Michelet index for each word michelet_index = {} for word, weight in zip(words, weights): index = word_index[word] michelet_index[word] = weight * freqs[index] # Get the top 10 words for each target word top_jane = sorted(michelet_index.items(), key=lambda x: x[1], reverse=True)[:10] top_rochester = sorted(michelet_index.items(), key=lambda x: x[1], reverse=True)[:10] print('Top words for "jane":') for word, weight in top_jane: print(f'- {word}: {weight:.2f}') print('Top words for "rochester":') for word, weight in top_rochester: print(f'- {word}: {weight:.2f}') ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值