kavyamanohar commited on
Commit
3ceaaa9
1 Parent(s): 3c2b743

Add python script to plot frequency profile

Browse files
Files changed (1) hide show
  1. plot_freq_profile.py +35 -0
plot_freq_profile.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib
2
+ import matplotlib.pyplot as plt
3
+ import sys
4
+ import operator
5
+ import argparse
6
+ import pandas as pd
7
+ import numpy as np
8
+
9
+ filename = "ml.vocabfreq.tsv"
10
+ data=pd.read_csv(filename,sep='\t')
11
+ data.columns=['word', 'frequency']
12
+ data.head()
13
+ data['rank'] = np.arange(len(data))+1
14
+ data.head()
15
+
16
+
17
+ fig1, ax1 = plt.subplots(figsize=(40,20))
18
+ ax1.set_title("Frequency Profile of IndicNLP Corpus ", fontsize=80)
19
+ ax1.set_ylabel("Token Frequency", fontsize=70)
20
+ ax1.set_xlabel("Rank in the frequency list", fontsize=70)
21
+ goldrank=data['rank'][0:999]
22
+ goldfreq=data['frequency'][0:999]
23
+
24
+ ax1.loglog(data['rank'], data['frequency'],color='#00629B', linewidth=7.0,label='Token frequency')
25
+ ax1.fill_between(goldrank, goldfreq, color='#D5E8D4', alpha=0.9,label='Coverage of gold standard lexicon' )
26
+ ax1.legend(fontsize=60)
27
+ # ax1.set_yticks([1,3, 10,100,1000,10000])
28
+ # ax1.set_xticks([1, 400000])
29
+ ax1.tick_params(axis='both', labelsize=50)
30
+ # ax1.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
31
+ # ax1.get_yaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
32
+ ax1.grid(linewidth=3)
33
+
34
+ plt.savefig("rank.png")
35
+ # plt.show()