In [1]:
%matplotlib inline

In [1]:
from nltk import *
from nltk.util import ngrams
from nltk.corpus import stopwords
from nltk.tokenize import WhitespaceTokenizer, RegexpTokenizer
from nltk.stem.porter import *
from collections import Counter
import string
import os

In [42]:
# custom tokenizer
pattern = r'''(?x)    # set flag to allow verbose regexps
    ([A-Z]\.)+        # abbreviations, e.g. U.S.A.
    | \w+(-\w+)*        # words with optional internal hyphens
    | \$?\d+(\.\d+)?%?  # currency and percentages, e.g. $12.40, 82%
    | \.\.\.            # ellipsis
    | [][.,;"'?():-_`]  # these are separate tokens; includes ], [
    '''

In [2]:
text = 'deficiency'

In [12]:
from nltk.stem import WordNetLemmatizer
wordnet_lemmatizer = WordNetLemmatizer()
wordnet_lemmatizer.lemmatize('diseases')


Out[12]:
u'disease'

In [ ]:
download()


showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml

In [ ]:
pattern = r'''(?x)
    \w+(-\w+)*'''
text = 'That U.S.A. poster-print costs $12.40...'

In [ ]:
nltk.regexp_tokenize(text, pattern)

In [3]:
ncbi_dir = nltk.data.find('corpora/ncbi_corpus_nltk')
ncbi = nltk.corpus.PlaintextCorpusReader(ncbi_dir, '.*\.txt', word_tokenizer=WhitespaceTokenizer())
#ncbi = nltk.corpus.PlaintextCorpusReader(ncbi_dir, '.*\.txt', word_tokenizer=RegexpTokenizer(pattern=pattern))

In [132]:
# all to lower case, remove punctuation/parenthesis, remove numbers
punct = set(string.punctuation)
words = [w.lower().rstrip('.,)').strip('(') for w in ncbi.words() if not w.rstrip('.,)').strip('(').isdigit() and w not in punct]

In [60]:
# remove stopwords
words_stop = [w for w in words if w not in stopwords.words('english')]

In [61]:
# remove prose numbers
nums_to_nineteen = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve',
       'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
nums_above_nineteen = ['twenty', 'thirty', 'fourty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety', 'hundred']

words_num = [w for w in words_stop if w not in nums_to_nineteen and 
             not [num for num in nums_above_nineteen if num in w]]

In [25]:
#words_num

In [62]:
# stemming (lemmatize instead?)
stemmer = PorterStemmer()
words_stem = [stemmer.stem(w) for w in words_num]

In [73]:
# remove series of symbols (e.g., -/-), percentages, and single characters/whitespaces (e.g., n from 'n = 4', p from 'p < 0.01')
symbols = re.compile(r'\W+')
percent = re.compile(r'\d+%')
single = re.compile(r'^\w?$')
regex = [symbols, percent, single]
words_sym = [w for w in words_stem if (not any(rr.search(w) for rr in regex))]

In [74]:
words_sym


Out[74]:
[u'identif',
 u'apc2',
 u'homologu',
 u'adenomat',
 u'polyposi',
 u'coli',
 u'tumour',
 u'suppressor',
 u'adenomat',
 u'polyposi',
 u'coli',
 u'apc',
 u'protein',
 u'control',
 u'wnt',
 u'signal',
 u'pathway',
 u'form',
 u'complex',
 u'glycogen',
 u'synthas',
 u'kinas',
 u'3beta',
 u'betacatenin',
 u'complex',
 u'format',
 u'induc',
 u'rapid',
 u'degrad',
 u'betacatenin',
 u'colon',
 u'carcinoma',
 u'cell',
 u'loss',
 u'apc',
 u'lead',
 u'accumul',
 u'betacatenin',
 u'nucleu',
 u'bind',
 u'activ',
 u'transcript',
 u'factor',
 u'review',
 u'report',
 u'identif',
 u'genom',
 u'structur',
 u'apc',
 u'homologu',
 u'mammalian',
 u'apc2',
 u'close',
 u'resembl',
 u'apc',
 u'overal',
 u'domain',
 u'structur',
 u'function',
 u'analyz',
 u'shown',
 u'contain',
 u'samp',
 u'domain',
 u'requir',
 u'bind',
 u'conductin',
 u'like',
 u'apc',
 u'apc2',
 u'regul',
 u'format',
 u'activ',
 u'complex',
 u'demonstr',
 u'use',
 u'transient',
 u'transcript',
 u'activ',
 u'assay',
 u'apc',
 u'colon',
 u'carcinoma',
 u'cell',
 u'human',
 u'apc2',
 u'map',
 u'chromosom',
 u'19p13',
 u'apc',
 u'apc2',
 u'may',
 u'therefor',
 u'compar',
 u'function',
 u'develop',
 u'cancer',
 u'common',
 u'msh2',
 u'mutat',
 u'english',
 u'north',
 u'american',
 u'hnpcc',
 u'origin',
 u'phenotyp',
 u'express',
 u'sex',
 u'specif',
 u'differ',
 u'colorect',
 u'cancer',
 u'frequenc',
 u'origin',
 u'phenotyp',
 u'express',
 u'germlin',
 u'msh2',
 u'gene',
 u'mutat',
 u'previous',
 u'identifi',
 u'kindr',
 u'hereditari',
 u'cancer',
 u'syndrom',
 u'hnpcc',
 u'investig',
 u'mutat',
 u'nt943',
 u'disrupt',
 u'splice',
 u'site',
 u'exon',
 u'lead',
 u'delet',
 u'exon',
 u'msh2',
 u'mrna',
 u'repres',
 u'frequent',
 u'msh2',
 u'mutat',
 u'far',
 u'report',
 u'although',
 u'mutat',
 u'initi',
 u'detect',
 u'colorect',
 u'cancer',
 u'famili',
 u'analys',
 u'eastern',
 u'england',
 u'extens',
 u'analysi',
 u'reduc',
 u'frequenc',
 u'english',
 u'hnpcc',
 u'kindr',
 u'analys',
 u'contrast',
 u'msh2',
 u'mutat',
 u'identifi',
 u'separ',
 u'identifi',
 u'colorect',
 u'famili',
 u'newfoundland',
 u'investig',
 u'origin',
 u'mutat',
 u'colorect',
 u'cancer',
 u'famili',
 u'england',
 u'newfoundland',
 u'unit',
 u'state',
 u'haplotyp',
 u'analysi',
 u'use',
 u'microsatellit',
 u'marker',
 u'link',
 u'msh2',
 u'perform',
 u'within',
 u'english',
 u'us',
 u'famili',
 u'littl',
 u'evid',
 u'recent',
 u'common',
 u'origin',
 u'msh2',
 u'splice',
 u'site',
 u'mutat',
 u'famili',
 u'contrast',
 u'common',
 u'haplotyp',
 u'identifi',
 u'flank',
 u'marker',
 u'ca5',
 u'd2s288',
 u'newfoundland',
 u'famili',
 u'find',
 u'suggest',
 u'founder',
 u'effect',
 u'within',
 u'newfoundland',
 u'similar',
 u'report',
 u'other',
 u'mlh1',
 u'mutat',
 u'finnish',
 u'hnpcc',
 u'famili',
 u'calcul',
 u'age',
 u'relat',
 u'risk',
 u'colorect',
 u'endometri',
 u'ovarian',
 u'cancer',
 u'nt943',
 u'msh2',
 u'mutat',
 u'carrier',
 u'patient',
 u'men',
 u'women',
 u'separ',
 u'sex',
 u'combin',
 u'penetr',
 u'age',
 u'year',
 u'cancer',
 u'colorect',
 u'cancer',
 u'respect',
 u'risk',
 u'colorect',
 u'cancer',
 u'significantli',
 u'higher',
 u'male',
 u'femal',
 u'age',
 u'year',
 u'respect',
 u'femal',
 u'high',
 u'risk',
 u'endometri',
 u'cancer',
 u'age',
 u'year',
 u'premenopaus',
 u'ovarian',
 u'cancer',
 u'year',
 u'intersex',
 u'differ',
 u'colorect',
 u'cancer',
 u'risk',
 u'implic',
 u'screen',
 u'programm',
 u'attempt',
 u'identifi',
 u'colorect',
 u'cancer',
 u'suscept',
 u'modifi',
 u'age',
 u'onset',
 u'huntington',
 u'diseas',
 u'sex',
 u'specif',
 u'influenc',
 u'apolipoprotein',
 u'genotyp',
 u'normal',
 u'cag',
 u'repeat',
 u'length',
 u'age',
 u'onset',
 u'ao',
 u'huntington',
 u'diseas',
 u'hd',
 u'known',
 u'correl',
 u'length',
 u'expand',
 u'cag',
 u'repeat',
 u'hd',
 u'gene',
 u'apolipoprotein',
 u'apo',
 u'genotyp',
 u'turn',
 u'known',
 u'influenc',
 u'ao',
 u'alzheim',
 u'diseas',
 u'render',
 u'apo',
 u'gene',
 u'like',
 u'candid',
 u'affect',
 u'ao',
 u'neurolog',
 u'diseas',
 u'therefor',
 u'determin',
 u'apo',
 u'genotyp',
 u'normal',
 u'cag',
 u'repeat',
 u'length',
 u'hd',
 u'gene',
 u'hd',
 u'patient',
 u'previous',
 u'analys',
 u'respect',
 u'cag',
 u'repeat',
 u'length',
 u'genotyp',
 u'apo',
 u'perform',
 u'blind',
 u'clinic',
 u'inform',
 u'addit',
 u'highlight',
 u'effect',
 u'normal',
 u'repeat',
 u'length',
 u'upon',
 u'ao',
 u'matern',
 u'inherit',
 u'hd',
 u'male',
 u'patient',
 u'show',
 u'apo',
 u'epsilon2epsilon3',
 u'genotyp',
 u'associ',
 u'significantli',
 u'earlier',
 u'ao',
 u'male',
 u'femal',
 u'sex',
 u'differ',
 u'ao',
 u'appar',
 u'apo',
 u'genotyp',
 u'find',
 u'suggest',
 u'subtl',
 u'differ',
 u'cours',
 u'neurodegener',
 u'hd',
 u'may',
 u'allow',
 u'interact',
 u'gene',
 u'exert',
 u'gender',
 u'specif',
 u'effect',
 u'upon',
 u'ao',
 u'famili',
 u'defici',
 u'seventh',
 u'compon',
 u'complement',
 u'associ',
 u'recurr',
 u'bacterem',
 u'infect',
 u'due',
 u'neisseria',
 u'serum',
 u'old',
 u'woman',
 u'recent',
 u'episod',
 u'dissemin',
 u'gonococc',
 u'infect',
 u'histori',
 u'meningococc',
 u'mening',
 u'arthriti',
 u'child',
 u'found',
 u'lack',
 u'serum',
 u'hemolyt',
 u'complement',
 u'activ',
 u'seventh',
 u'compon',
 u'complement',
 u'c7',
 u'detect',
 u'function',
 u'immunochem',
 u'assay',
 u'wherea',
 u'compon',
 u'normal',
 u'hemolyt',
 u'immunochem',
 u'assess',
 u'fresh',
 u'serum',
 u'lack',
 u'bactericid',
 u'activ',
 u'neisseria',
 u'gonorrhoea',
 u'addit',
 u'fresh',
 u'normal',
 u'serum',
 u'purifi',
 u'c7',
 u'restor',
 u'bactericid',
 u'activ',
 u'well',
 u'hemolyt',
 u'activ',
 u'absenc',
 u'function',
 u'c7',
 u'activ',
 u'could',
 u'account',
 u'basi',
 u'inhibitor',
 u'opson',
 u'gener',
 u'chemotact',
 u'activ',
 u'function',
 u'normal',
 u'complet',
 u'absenc',
 u'c7',
 u'also',
 u'found',
 u'sibl',
 u'clinic',
 u'syndrom',
 u'meningococc',
 u'mening',
 u'arthriti',
 u'child',
 u'sibl',
 u'clinic',
 u'well',
 u'son',
 u'hla',
 u'histocompat',
 u'type',
 u'famili',
 u'member',
 u'demonstr',
 u'evid',
 u'genet',
 u'linkag',
 u'c7',
 u'defici',
 u'major',
 u'histocompat',
 u'loci',
 u'report',
 u'repres',
 u'first',
 u'case',
 u'c7',
 u'defici',
 u'associ',
 u'infecti',
 u'complic',
 u'suggest',
 u'bactericid',
 u'activ',
 u'may',
 u'import',
 u'host',
 u'defens',
 u'bacterem',
 u'neisseria',
 u'infect',
 u'increas',
 u'incid',
 u'cancer',
 u'patient',
 u'hypoplasia',
 u'object',
 u'previou',
 u'report',
 u'suggest',
 u'increas',
 u'risk',
 u'cancer',
 u'among',
 u'patient',
 u'hypoplasia',
 u'chh',
 u'studi',
 u'carri',
 u'evalu',
 u'risk',
 u'among',
 u'patient',
 u'chh',
 u'rel',
 u'studi',
 u'design',
 u'patient',
 u'chh',
 u'identifi',
 u'countrywid',
 u'epidemiolog',
 u'survey',
 u'parent',
 u'nonaffect',
 u'sibl',
 u'identifi',
 u'popul',
 u'regist',
 u'center',
 u'cohort',
 u'underw',
 u'cancer',
 u'incid',
 u'finnish',
 u'cancer',
 u'registri',
 u'end',
 u'result',
 u'statist',
 u'signific',
 u'excess',
 u'risk',
 u'cancer',
 u'seen',
 u'among',
 u'patient',
 u'chh',
 u'standard',
 u'incid',
 u'ratio',
 u'confid',
 u'interv',
 u'mainli',
 u'attribut',
 u'lymphoma',
 u'standard',
 u'incid',
 u'ratio',
 u'confid',
 u'interv',
 u'addit',
 u'signific',
 u'excess',
 u'risk',
 u'basal',
 u'cell',
 u'carcinoma',
 u'seen',
 u'standard',
 u'incid',
 u'ratio',
 u'confid',
 u'interv',
 u'cancer',
 u'incid',
 u'among',
 u'sibl',
 u'parent',
 u'differ',
 u'averag',
 u'cancer',
 u'incid',
 u'finnish',
 u'popul',
 u'conclus',
 u'studi',
 u'confirm',
 u'increas',
 u'risk',
 u'cancer',
 u'especi',
 u'lymphoma',
 u'probabl',
 u'attribut',
 u'defect',
 u'immun',
 u'among',
 u'patient',
 u'chh',
 u'genotyp',
 u'phenotyp',
 u'patient',
 u'dihydropyrimidin',
 u'dehydrogenas',
 u'defici',
 u'dihydropyrimidin',
 u'dehydrogenas',
 u'dpd',
 u'defici',
 u'autosom',
 u'recess',
 u'diseas',
 u'characteris',
 u'homozyg',
 u'defici',
 u'patient',
 u'associ',
 u'variabl',
 u'clinic',
 u'phenotyp',
 u'order',
 u'understand',
 u'genet',
 u'phenotyp',
 u'basi',
 u'dpd',
 u'defici',
 u'review',
 u'famili',
 u'present',
 u'patient',
 u'complet',
 u'defici',
 u'dpd',
 u'group',
 u'patient',
 u'differ',
 u'mutat',
 u'identifi',
 u'includ',
 u'delet',
 u'mutat',
 u'1g',
 u'missens',
 u'mutat',
 u'85t',
 u'703c',
 u'2658g',
 u'2983g',
 u'analysi',
 u'preval',
 u'variou',
 u'mutat',
 u'among',
 u'dpd',
 u'patient',
 u'shown',
 u'point',
 u'mutat',
 u'invari',
 u'splice',
 u'donor',
 u'site',
 u'far',
 u'common',
 u'wherea',
 u'mutat',
 u'less',
 u'frequent',
 u'observ',
 u'larg',
 u'phenotyp',
 u'variabl',
 u'observ',
 u'convuls',
 u'disord',
 u'motor',
 u'retard',
 u'mental',
 u'retard',
 u'abund',
 u'manifest',
 u'clear',
 u'correl',
 u'genotyp',
 u'phenotyp',
 u'establish',
 u'alter',
 u'uracil',
 u'thymin',
 u'homeostasi',
 u'might',
 u'underli',
 u'variou',
 u'clinic',
 u'abnorm',
 u'encount',
 u'patient',
 u'dpd',
 u'defici',
 u'fibroblast',
 u'growth',
 u'factor',
 u'homolog',
 u'factor',
 u'gene',
 u'structur',
 u'express',
 u'map',
 u'syndrom',
 u'region',
 u'xq26',
 u'delin',
 u'duplic',
 u'breakpoint',
 u'patient',
 u'syndrom',
 u'bfl',
 u'syndrom',
 u'mental',
 u'retard',
 u'map',
 u'linkag',
 u'q26',
 u'region',
 u'human',
 u'chromosom',
 u'identifi',
 u'male',
 u'patient',
 u'featur',
 u'duplic',
 u'dup',
 u'q26q28',
 u'inherit',
 u'phenotyp',
 u'normal',
 u'mother',
 u'fluoresc',
 u'situ',
 u'hybridis',
 u'use',
 u'yeast',
 u'artifici',
 u'chromosom',
 u'clone',
 u'xq26',
 u'localis',
 u'duplic',
 u'breakpoint',
 u'approxim',
 u'interv',
 u'xq26',
 u'region',
 u'dxs155',
 u'databas',
 u'search',
 u'analysi',
 u'avail',
 u'genom',
 u'dna',
 u'sequenc',
 u'region',
 u'reveal',
 u'presenc',
 u'fibroblast',
 u'growth',
 u'factor',
 u'homolog',
 u'factor',
 u'gene',
 u'fhf2',
 u'within',
 u'duplic',
 u'breakpoint',
 u'interv',
 u'gene',
 u'structur',
 u'fhf2',
 u'determin',
 u'new',
 u'exon',
 u'identifi',
 u'includ',
 u'new',
 u'end',
 u'exon',
 u'1b',
 u'fhf2',
 u'larg',
 u'gene',
 u'extend',
 u'approxim',
 u'kb',
 u'xq26',
 u'compos',
 u'least',
 u'exon',
 u'show',
 u'altern',
 u'splice',
 u'altern',
 u'transcript',
 u'start',
 u'northern',
 u'blot',
 u'hybridis',
 u'show',
 u'highest',
 u'express',
 u'brain',
 u'skelet',
 u'muscl',
 u'fhf2',
 u'gene',
 u'localis',
 u'express',
 u'pattern',
 u'suggest',
 u'candid',
 u'gene',
 u'famili',
 u'case',
 u'bfl',
 u'syndrom',
 u'syndrom',
 u'form',
 u'mental',
 u'retard',
 u'map',
 u'region',
 u'germlin',
 u'gene',
 u'cdh1',
 u'mutat',
 u'predispos',
 u'famili',
 u'gastric',
 u'cancer',
 u'colorect',
 u'cancer',
 u'inherit',
 u'mutat',
 u'gene',
 u'cdh1',
 u'describ',
 u'recent',
 u'maori',
 u'kindr',
 u'famili',
 u'gastric',
 u'cancer',
 u'famili',
 u'gastric',
 u'cancer',
 u'genet',
 u'heterogen',
 u'clear',
 u'proport',
 u'gastric',
 u'cancer',
 u'suscept',
 u'popul',
 u'due',
 u'germlin',
 u'cdh1',
 u'mutat',
 u'therefor',
 u'screen',
 u'famili',
 u'gastric',
 u'cancer',
 u'kindr',
 u'british',
 u'irish',
 u'origin',
 u'germlin',
 u'cdh1',
 u'mutat',
 u'sscp',
 u'analysi',
 u'exon',
 u'flank',
 u'sequenc',
 u'famili',
 u'contain',
 u'case',
 u'gastric',
 u'cancer',
 u'first',
 u'degre',
 u'rel',
 u'affect',
 u'age',
 u'ii',
 u'case',
 u'gastric',
 u'cancer',
 u'novel',
 u'germlin',
 u'cdh1',
 u'mutat',
 u'nonsens',
 u'splice',
 u'site',
 u'detect',
 u'famili',
 u'mutat',
 u'predict',
 u'truncat',
 u'protein',
 u'signal',
 u'peptid',
 u'domain',
 u'famili',
 u'evid',
 u'suscept',
 u'gastric',
 u'colorect',
 u'thu',
 u'addit',
 u'case',
 u'gastric',
 u'cancer',
 u'cdh1',
 u'mutat',
 u'carrier',
 u'develop',
 u'colorect',
 u'cancer',
 u'age',
 u'year',
 u'confirm',
 u'germlin',
 u'mutat',
 u'cdh1',
 u'gene',
 u'caus',
 u'famili',
 u'gastric',
 u'cancer',
 u'popul',
 u'howev',
 u'minor',
 u'famili',
 u'gastric',
 u'cancer',
 u'account',
 u'cdh1',
 u'mutat',
 u'loss',
 u'function',
 u'implic',
 u'pathogenesi',
 u'sporad',
 u'colorect',
 u'cancer',
 u'find',
 u'provid',
 u'evid',
 u'germlin',
 ...]

In [ ]:
# deal with mention of genes, things like Gd (+)/Gd (-), etc.

In [75]:
print words_stop[0:5]
print words_stem[0:5]
print words_sym[0:5]


[u'identification', u'apc2', u'homologue', u'adenomatous', u'polyposis']
[u'identif', u'apc2', u'homologu', u'adenomat', u'polyposi']
[u'identif', u'apc2', u'homologu', u'adenomat', u'polyposi']

In [76]:
counts = Counter()

for w in words_sym:
    counts[w] += 1

In [80]:
fd = nltk.FreqDist(words_sym)
fd.plot(30, cumulative=False)



In [ ]:
## multi-word expression tokenizer
#Multi-Word Expression Tokenizer

#A MWETokenizer takes a string which has already been divided into tokens and retokenizes it, 
#merging multi-word expressions into single tokens, using a lexicon of MWEs:
##### maybe take the set of disease mentions and use these as lexicon of MWEs

#>>> from nltk.tokenize import MWETokenizer
#>>> tokenizer = MWETokenizer([('a', 'little'), ('a', 'little', 'bit'), ('a', 'lot')])
#>>> tokenizer.add_mwe(('in', 'spite', 'of'))

In [88]:
counts


Out[88]:
Counter({u'polypeptid': 8,
         u'exencephalu': 2,
         u'apoc2': 16,
         u'asian': 7,
         u'apoc1': 1,
         u'repetit': 1,
         u'gavag': 1,
         u'whose': 15,
         u'accur': 6,
         u'd1s491': 1,
         u'hemolysi': 4,
         u'4p16': 8,
         u'chenodeoxychol': 2,
         u'p65l': 4,
         u'fige': 2,
         u'downstream': 10,
         u'irrinki': 2,
         u'osteoblast': 1,
         u'pigment': 24,
         u'affect': 219,
         u'hitch': 1,
         u'leukoid': 1,
         u'vast': 3,
         u'fhm': 4,
         u'inbr': 1,
         u'disturb': 3,
         u'sensor': 1,
         u'upd': 5,
         u'fhc': 2,
         u'correct': 6,
         u'2p25': 1,
         u'heteroallel': 1,
         u'vector': 7,
         u'cholesterol': 21,
         u'chylomicronemia': 1,
         u'ivs12n1': 1,
         u'cpxr318': 2,
         u'bacon': 1,
         u'histor': 4,
         u'second': 43,
         u'aggreg': 6,
         u'illumin': 1,
         u'even': 15,
         u'neo': 1,
         u'ivs10nt546': 1,
         u'homeostasi': 9,
         u'neg': 32,
         u'asid': 1,
         u'transcrib': 9,
         u'asia': 3,
         u'centromer': 12,
         u'new': 133,
         u'aoii': 1,
         u'ongo': 2,
         u'elimin': 11,
         u'intellectu': 1,
         u'ophthalm': 3,
         u'men': 11,
         u'ferrou': 1,
         u'delchev': 1,
         u'q14': 3,
         u'china': 5,
         u'mep': 4,
         u'q13': 3,
         u'q12': 2,
         u'pancreat': 3,
         u'neurodegen': 10,
         u'vogelstein': 1,
         u'anonym': 8,
         u'interpret': 4,
         u'duoden': 9,
         u'deterior': 3,
         u'mellitu': 5,
         u'deregul': 3,
         u'arg243': 1,
         u'dri': 1,
         u'permit': 10,
         u'rsca3': 1,
         u'drd': 1,
         u'omax': 1,
         u'interferon': 2,
         u'angelman': 8,
         u'oncogenesi': 1,
         u'nonneonat': 2,
         u'subretin': 2,
         u'avenu': 2,
         u'spinocerebellar': 6,
         u'instabl': 33,
         u'erythroblast': 1,
         u'unit': 12,
         u'dna': 240,
         u'monosov': 1,
         u'myogen': 7,
         u'call': 14,
         u'recommend': 4,
         u'strike': 7,
         u'type': 144,
         u'dxs52': 5,
         u'relat': 37,
         u'notic': 1,
         u'herein': 5,
         u'grandfath': 6,
         u'adult': 31,
         u'loss': 107,
         u'stopcodon': 2,
         u'aalpha': 1,
         u'thymin': 2,
         u'thymic': 1,
         u'conceptu': 1,
         u'e482k': 1,
         u'dmpk': 29,
         u'cytochrom': 3,
         u'photomicrograph': 1,
         u'root': 7,
         u'newfoundland': 6,
         u'kinet': 9,
         u'give': 17,
         u'virtu': 1,
         u'infus': 4,
         u'malign': 19,
         u'962del4': 1,
         u'caution': 1,
         u'want': 1,
         u'l1cam': 1,
         u'seborrho': 1,
         u'bimod': 1,
         u'classifi': 3,
         u'craniofaci': 3,
         u'intestin': 8,
         u'w27': 3,
         u'hot': 5,
         u'confin': 5,
         u'confid': 13,
         u'alzheim': 1,
         u'oscillatori': 1,
         u'modest': 1,
         u'thr48ile': 1,
         u'attempt': 7,
         u'vicin': 2,
         u'vicia': 1,
         u'hpaii': 1,
         u'g395r': 1,
         u'maintain': 7,
         u'd1s249': 1,
         u'hyperphenylalaninem': 2,
         u'd1s245': 1,
         u'lambda': 3,
         u'origin': 100,
         u'prophylact': 2,
         u'hprtyal': 5,
         u'appar': 39,
         u'vari': 19,
         u'ligand': 2,
         u'fit': 2,
         u'mintier': 1,
         u'fix': 2,
         u'homozyg': 96,
         u'better': 7,
         u'persist': 5,
         u'hidden': 1,
         u'd11s151': 2,
         u'anim': 17,
         u'therapi': 21,
         u'4153dela': 1,
         u'accrual': 1,
         u'394arg': 1,
         u'lyophil': 1,
         u'interfamili': 1,
         u'promis': 2,
         u'parkinson': 1,
         u'radiolog': 1,
         u'interrupt': 1,
         u'bronchial': 1,
         u'n314d': 8,
         u'col2a1': 6,
         u'eczema': 4,
         u'mucopolysaccharidosi': 6,
         u'localis': 14,
         u'thymu': 2,
         u'oblig': 15,
         u'side': 4,
         u'bone': 12,
         u'mean': 30,
         u'development': 15,
         u'macromolecul': 2,
         u'apolipoprotein': 19,
         u'knockout': 11,
         u'aminopeptidas': 1,
         u'mda': 1,
         u'mdx': 16,
         u'immunofluoresc': 3,
         u'hemochromatot': 1,
         u'extract': 13,
         u'xp': 3,
         u'histidinemia': 4,
         u'rv': 2,
         u'gradient': 2,
         u'hypotens': 1,
         u'odontoma': 1,
         u'crucial': 5,
         u'content': 8,
         u'smn': 1,
         u'branch': 3,
         u'adapt': 3,
         u'rb': 5,
         u'quantifi': 1,
         u'ro': 1,
         u'dsb': 2,
         u'kiel': 1,
         u'2871delc': 2,
         u'hypermethyl': 2,
         u'myoton': 71,
         u'linear': 2,
         u'fava': 2,
         u'wherea': 35,
         u'intersex': 2,
         u'midpoint': 1,
         u'immort': 1,
         u'lineag': 5,
         u'hyopsynthesi': 1,
         u'r482h': 1,
         u'wfs1': 4,
         u'untreat': 2,
         u'atg': 2,
         u'sigal': 1,
         u'r2': 1,
         u'ata': 1,
         u'atm': 56,
         u'att': 1,
         u'atherosclerosi': 4,
         u'unabl': 5,
         u'atp': 3,
         u'isl': 3,
         u'kamiub': 2,
         u'confus': 3,
         u'ochronot': 2,
         u'breed': 2,
         u'rudosem': 1,
         u'grade': 3,
         u'wasp': 26,
         u'vitro': 38,
         u'protract': 1,
         u'edm1': 1,
         u'unlik': 8,
         u'edm4': 1,
         u'massiv': 4,
         u'vascul': 4,
         u'radiata': 1,
         u'neuromuscular': 7,
         u'evolut': 6,
         u'biosynthesi': 1,
         u'transitori': 1,
         u'underlin': 2,
         u'similarli': 3,
         u'recent': 90,
         u'multimer': 2,
         u'subclin': 1,
         u'danish': 5,
         u'edmd': 14,
         u'somewhat': 3,
         u'paracentr': 1,
         u'peculiar': 1,
         u'symptom': 27,
         u'glycosphingolipid': 2,
         u'd5s37': 1,
         u'photoreceptor': 13,
         u'rectl': 1,
         u'magel2': 10,
         u'project': 1,
         u'matter': 5,
         u'tion': 1,
         u'proteolyt': 2,
         u'dxs42': 6,
         u'postnat': 4,
         u'aapc': 3,
         u'fkhl14': 2,
         u'boston': 1,
         u'modern': 2,
         u'spectrum': 19,
         u'chen': 1,
         u'seen': 28,
         u'seem': 13,
         u'seek': 1,
         u'dival': 1,
         u'nonneuronopath': 1,
         u'ricof': 10,
         u'norri': 20,
         u'hpc1': 5,
         u'mxi1': 5,
         u'object': 12,
         u'regular': 3,
         u'vaccinia': 1,
         u'breakpoint': 41,
         u'oligonucleotid': 14,
         u'prematur': 28,
         u'tradit': 1,
         u'unexplain': 5,
         u'dog': 8,
         u'hospit': 3,
         u'melanocyt': 1,
         u'schisi': 1,
         u'busselton': 1,
         u'came': 1,
         u'explan': 9,
         u'dr2': 1,
         u'probe': 62,
         u'transluc': 1,
         u'ulcer': 4,
         u'frataxin': 17,
         u'lethal': 12,
         u'mediterranian': 1,
         u'despit': 14,
         u'hexadecanol': 4,
         u'acquir': 2,
         u'explain': 26,
         u'releas': 7,
         u'sugar': 4,
         u'explic': 1,
         u'rich': 1,
         u'rehydr': 2,
         u'r261q': 1,
         u'stop': 27,
         u'coast': 2,
         u'd17s78': 1,
         u'fgd1': 7,
         u'collabor': 3,
         u'subcontin': 1,
         u'bax': 5,
         u'patch': 2,
         u'superfamili': 2,
         u'chromatograph': 1,
         u'grandpatern': 1,
         u'nibrin': 7,
         u'respond': 3,
         u'wt1': 33,
         u'encephalopathi': 1,
         u'aldehyd': 2,
         u'recruit': 2,
         u'incoordin': 1,
         u'aminoglycosid': 3,
         u'result': 380,
         u'respons': 105,
         u'fail': 16,
         u'r483g': 1,
         u'best': 2,
         u'subject': 87,
         u'dinucleotid': 10,
         u'coloboma': 1,
         u'heterogen': 76,
         u'iri': 5,
         u'figur': 1,
         u'score': 55,
         u'epigenotyp': 1,
         u'bleach': 1,
         u'phosphoglycer': 1,
         u'ire': 6,
         u'niuean': 1,
         u'attribut': 3,
         u'inabl': 1,
         u'triplet': 9,
         u'apoai': 2,
         u'extend': 25,
         u'm368v': 1,
         u'sera': 9,
         u'atherogenesi': 2,
         u'extens': 20,
         u'extent': 13,
         u'hypodontia': 2,
         u'toler': 2,
         u'neuroepithelium': 1,
         u'hutterit': 1,
         u'agonist': 2,
         u'met': 13,
         u'adolesc': 5,
         u'contractur': 7,
         u'ventilatori': 2,
         u'metastat': 3,
         u'compromis': 2,
         u'fluorescein': 2,
         u'asp442': 1,
         u'height': 2,
         u'hydrophil': 1,
         u'assum': 2,
         u'ether': 1,
         u'duplic': 49,
         u'recur': 2,
         u'union': 1,
         u'specul': 3,
         u'much': 12,
         u'interest': 5,
         u'progenitor': 6,
         u'bifid': 1,
         u'tini': 1,
         u'oogenesi': 1,
         u'life': 9,
         u'regul': 32,
         u'retrospect': 5,
         u'eastern': 11,
         u'grmd': 3,
         u'suppress': 5,
         u'rgg': 1,
         u'mcc': 8,
         u'granulosa': 1,
         u'fibroblast': 61,
         u'k695r': 1,
         u'erythema': 1,
         u'child': 19,
         u'mcr': 1,
         u'cys2his2zinc': 1,
         u'12q14': 1,
         u'dissect': 1,
         u'commerci': 2,
         u'intak': 1,
         u'employ': 10,
         u'calcium': 1,
         u'near': 16,
         u'marriag': 2,
         u'viii': 6,
         u'risch': 1,
         u'postop': 1,
         u'occas': 3,
         u'endotheli': 1,
         u'anchor': 2,
         u'ix': 2,
         u'a25': 1,
         u'mexico': 1,
         u'iq': 10,
         u'ir': 3,
         u'oculocerebroren': 4,
         u'iv': 3,
         u'ii': 46,
         u'hypoplasia': 13,
         u'il': 1,
         u'in': 3,
         u'ia': 2,
         u'ic': 4,
         u'ib': 6,
         u'ie': 1,
         u'lmp2a': 1,
         u'disappear': 2,
         u'precis': 11,
         u'dilut': 1,
         u'isoelectr': 1,
         u'receiv': 4,
         u'rheumat': 1,
         u'make': 5,
         u'format': 28,
         u'recncii': 1,
         u'xj1': 1,
         u'big': 1,
         u'dxs72': 2,
         u'dxs77': 1,
         u'european': 24,
         u'elli': 1,
         u'cotransport': 10,
         u'molecul': 11,
         u'prognost': 3,
         u'kit': 8,
         u'adenoma': 6,
         u'prognosi': 3,
         u'refin': 13,
         u'engin': 2,
         u'overt': 1,
         u'inherit': 110,
         u'qualit': 1,
         u'radioimmunoassay': 2,
         u'i97': 2,
         u'weakli': 3,
         u'stimulu': 1,
         u'scn4a': 1,
         u'programm': 1,
         u'controversi': 2,
         u'unchang': 2,
         u'counti': 1,
         u'protocol': 3,
         u'golden': 2,
         u'linehan': 2,
         u'human': 321,
         u'sassari': 1,
         u'yet': 15,
         u'previous': 126,
         u'characterist': 47,
         u'hal': 2,
         u'it15': 4,
         u'easi': 2,
         u'character': 144,
         u'east': 2,
         u'hat': 1,
         u'alur': 2,
         u'deterg': 1,
         u'applic': 6,
         u'coron': 1,
         u'preserv': 3,
         u'toxin': 1,
         u'clonal': 3,
         u'tertiari': 1,
         u'birth': 13,
         u'iminodipeptiduria': 1,
         u'metatrop': 1,
         u'measur': 17,
         u'specif': 67,
         u'transvers': 11,
         u'nude': 2,
         u'manual': 1,
         u'bsssi': 2,
         u'quintana': 1,
         u'mpkuc': 2,
         u'unnecessari': 1,
         u'underli': 27,
         u'right': 1,
         u'old': 11,
         u'deal': 1,
         u'czech': 1,
         u'interv': 47,
         u'disord': 171,
         u'deaf': 12,
         u'maxim': 7,
         u'intern': 10,
         u'interf': 1,
         u'angiogenesi': 1,
         u'cryosect': 1,
         u'transmiss': 21,
         u'mcleod': 9,
         u'contrarili': 1,
         u'murin': 28,
         u'flux': 2,
         u'extracrani': 1,
         u'subclass': 3,
         u'buffer': 3,
         u'chimaer': 2,
         u'condit': 27,
         u'hdac1': 1,
         u'hdac2': 1,
         u'gl02': 1,
         u'dental': 1,
         u'undifferenti': 1,
         u'promot': 14,
         u'dp260': 4,
         u'faero': 1,
         u'interestingli': 7,
         u'ccaat': 2,
         u'slightli': 8,
         u'medulloblastoma': 3,
         u'commit': 2,
         u'breakag': 7,
         u'sequestr': 1,
         u'leptin': 1,
         u'encount': 1,
         u'creatin': 4,
         u'inv11': 1,
         u'glycine103': 1,
         u'hallmark': 1,
         u'son': 8,
         u'formerli': 4,
         u'degen': 1,
         u'nih3t3': 2,
         u'hypotonia': 5,
         u'genotyp': 35,
         u'novo': 19,
         u'faciogenit': 1,
         u'suffici': 19,
         u'support': 70,
         u'avail': 19,
         u'avaii': 3,
         u'fraction': 14,
         u'transillumin': 1,
         u'mutagenesi': 4,
         u'constantli': 1,
         u'scali': 1,
         u'analysi': 340,
         u'form': 106,
         u'offer': 5,
         u'forc': 1,
         u'imperfecta': 5,
         u'2513dela': 1,
         u'substrat': 12,
         u'berk': 1,
         u'hyperphenylalaninemia': 5,
         u'myopia': 4,
         u'l13p': 1,
         u'engraft': 1,
         u'sampl': 45,
         u'titteri': 1,
         u'unrel': 72,
         u'dissemin': 3,
         u'temper': 1,
         u'classif': 5,
         u'later': 17,
         u'classic': 40,
         u'congenita': 1,
         u'diagnosi': 79,
         u'proven': 1,
         u'p27kip1': 1,
         u'diagnost': 21,
         u'khk': 9,
         u'exist': 21,
         u'laghouat': 1,
         u'cytoskeleton': 2,
         u'quantiti': 6,
         u'myeloneuropathi': 1,
         u'amelogenesi': 5,
         u'neurophil': 1,
         u'excel': 1,
         u'akli': 2,
         u'microdelet': 8,
         u'role': 59,
         u'presum': 12,
         u'smell': 1,
         u'mri': 10,
         u'15q': 1,
         u'matur': 9,
         u'fabri': 2,
         u'handicap': 3,
         u'uncharacter': 5,
         u'willebrand': 22,
         u'intens': 1,
         u'abrog': 4,
         u'cleaver': 1,
         u'femal': 83,
         u'domingo': 1,
         u'furthermor': 22,
         u'd11s287e': 1,
         u'teeth': 1,
         u't274m': 4,
         u'daili': 1,
         u'corpu': 1,
         u'chain': 56,
         u'skip': 19,
         u'mild': 49,
         u'skin': 37,
         u'primer': 9,
         u'milk': 3,
         u'ecorii': 1,
         u'catalyt': 5,
         u'catalys': 1,
         u'aspa': 15,
         u'leukem': 1,
         u'ribosom': 1,
         u'father': 16,
         u'catalyz': 7,
         u'rel': 72,
         u'decis': 1,
         u'dxs206': 1,
         u'i82': 1,
         u'chemotact': 11,
         u'pyrin': 1,
         u'abetalipoproteinemia': 5,
         u'recognis': 3,
         u'yeast': 16,
         u'pichia': 1,
         u'embark': 1,
         u'insolubl': 1,
         u'exact': 2,
         u'nephropathi': 6,
         u'p5s1': 1,
         u'knockin': 1,
         u'die': 7,
         u'mb': 11,
         u'immunochem': 7,
         u'magnet': 4,
         u'hypobetalipoproteinemia': 8,
         u'round': 2,
         u'dir': 2,
         u'recombin': 90,
         u'burkitt': 1,
         u'prevent': 12,
         u'oncogen': 13,
         u'mn': 3,
         u'trisomi': 4,
         u'imbert': 1,
         u'microsequenc': 1,
         u'autolog': 3,
         u'compens': 3,
         u's19': 1,
         u'sign': 15,
         u'villu': 2,
         u'intronless': 1,
         u'hexosaminidas': 6,
         u'bovin': 3,
         u'r778l': 3,
         u'energi': 3,
         u'psigldc': 5,
         u'favour': 2,
         u'current': 14,
         u'erg': 22,
         u'suspect': 5,
         u'norrin': 2,
         u'deriv': 35,
         u'a456p': 1,
         u'guangzhou': 1,
         u'aldrp': 6,
         u'purin': 7,
         u'modif': 7,
         u'splice': 123,
         u'address': 2,
         u'drainag': 2,
         u'along': 11,
         u'stem': 6,
         u'pisticci': 1,
         u'box': 4,
         u'hbl': 5,
         u'p57kip2': 2,
         u'cgp57148b': 3,
         u'canadian': 5,
         u'shift': 8,
         u'worldwid': 5,
         u'rhodopsin': 2,
         u'haeiii': 2,
         u'women': 25,
         u'cyst': 4,
         u'dominantli': 9,
         u'commonli': 2,
         u'br': 2,
         u'proportion': 1,
         u'modul': 6,
         u'purul': 1,
         u'leav': 5,
         u'ipw': 1,
         u'eccentr': 1,
         u'retinopathi': 1,
         u'nonspherocyt': 6,
         u'resorpt': 1,
         u'univers': 2,
         u'visit': 1,
         u'increas': 126,
         u'actin': 6,
         u'tightli': 11,
         u'nebulin': 7,
         u'e390g': 2,
         u'afford': 1,
         u'peopl': 11,
         u'juvenil': 4,
         u'enhanc': 6,
         u'visual': 12,
         u'tandem': 5,
         u'examin': 78,
         u'punctat': 3,
         u'effort': 2,
         u'stain': 9,
         u'tp53': 12,
         u'tokyo': 1,
         u'kaelin': 1,
         u'decay': 1,
         u'desmoplast': 2,
         u'sarcoplasm': 1,
         u'uniqu': 25,
         u'whatev': 1,
         u'franc': 3,
         u'materi': 5,
         u'problemat': 1,
         u'kx': 1,
         u'complimentari': 1,
         u'endocrin': 1,
         u'genesi': 2,
         u'14q': 7,
         u'predict': 57,
         u'agent': 7,
         u'rbap46': 1,
         u'immunolog': 9,
         u'bacteriolysi': 1,
         u'coincident': 1,
         u'r59h': 1,
         u'rbap48': 1,
         u'strikingli': 4,
         u's9': 1,
         u'subnorm': 3,
         u'sufat': 1,
         u'variou': 24,
         u'fpc': 1,
         u'meshwork': 1,
         u'dryja': 1,
         u'3q22q23': 2,
         u'pure': 2,
         u'dr47': 1,
         u'pathway': 24,
         u'undertook': 1,
         u'map': 169,
         u'nondefici': 1,
         u'may': 180,
         u'max': 5,
         u'spot': 9,
         u'mab': 6,
         u'mae': 1,
         u'snp': 2,
         u'date': 15,
         u'suck': 1,
         u'data': 110,
         u'grow': 1,
         u'mao': 3,
         u'man': 15,
         u'stress': 4,
         u'nitroblu': 1,
         u'irradi': 3,
         u'wheelchair': 2,
         u'gestat': 1,
         u'switch': 2,
         u'coexpress': 3,
         u'deposit': 5,
         u'african': 13,
         u'purifi': 15,
         u'regimen': 2,
         u'se': 1,
         u'scotoma': 2,
         u'zmax': 6,
         u'thrombophil': 2,
         u'gradual': 2,
         u'dmt1': 12,
         u'kimmel': 1,
         u'solubl': 3,
         u'ttc': 2,
         u'epilepsi': 2,
         u'entiti': 7,
         u'dxs10': 4,
         u'reinforc': 2,
         u'dxs15': 1,
         u'monitor': 3,
         u'dxs16': 3,
         u'3600del11': 1,
         u'w24': 1,
         u'dysfunct': 13,
         u'main': 6,
         u'ascrib': 1,
         u'recoveri': 4,
         u'chromatin': 4,
         u'uniparent': 7,
         u'hypersensit': 4,
         u'initi': 27,
         u'nation': 1,
         u'interview': 1,
         u'nbs1': 7,
         u'therebi': 4,
         u'verifi': 4,
         u'cryptorchid': 1,
         u'possess': 13,
         u'anteced': 1,
         u'revers': 12,
         u'revert': 2,
         u'separ': 21,
         u'maher': 2,
         u'cdk4': 6,
         u'xlt': 4,
         u'xlr': 5,
         u'metachromat': 11,
         u'cetp': 40,
         u'fistula': 1,
         u'radioassay': 1,
         u'continu': 8,
         u'yield': 11,
         u'girl': 10,
         u'adren': 10,
         u'canada': 6,
         u'sensorineur': 8,
         u'alpha1': 2,
         u'endogam': 1,
         u'tyr180': 1,
         u'dutch': 11,
         u'camperdown': 2,
         u'hepatocyt': 1,
         u'hypopig': 1,
         u'diseas': 418,
         u'cosegreg': 3,
         u'domest': 1,
         u'million': 6,
         u'seventh': 10,
         u'heterochromatin': 2,
         u'gotz': 1,
         u'tursi': 1,
         u'frequenc': 100,
         u'recov': 1,
         u'principl': 1,
         u'1p36': 1,
         u'frequent': 53,
         u'first': 86,
         u'oper': 1,
         u'neurit': 1,
         u'carri': 80,
         u'distal': 32,
         u'd2s5': 1,
         u'mammari': 5,
         u'housekeep': 3,
         u'one': 1,
         u'acquisit': 1,
         u'biol': 2,
         u'spanish': 7,
         u'oppos': 3,
         u'open': 5,
         u'd1s2777': 1,
         u'convent': 5,
         u'osteolyt': 1,
         u'ambul': 1,
         u'1b': 2,
         u'cassett': 2,
         u'demonstr': 124,
         u'1g': 1,
         u'fmf': 30,
         u'myfh1p': 8,
         u'cite': 2,
         u'connat': 1,
         u'ambulatori': 1,
         u'hyperuricemia': 2,
         u'provinc': 4,
         u'gch1': 9,
         u'undoubtedli': 1,
         u'eighteenth': 1,
         u'germ': 17,
         u'interrel': 1,
         u'logist': 1,
         u'gaozhou': 1,
         u'solubil': 1,
         u'meiotic': 11,
         u'titrat': 2,
         u'19q13': 1,
         u'hyperplasia': 1,
         u'peduncl': 1,
         u'third': 26,
         u'r231h': 3,
         u'redefinit': 1,
         u'q454p': 1,
         u'fmr1': 27,
         u'russia': 1,
         u'f8c': 4,
         u'pyoderma': 2,
         u'prospect': 1,
         u'sac': 1,
         u'saa': 9,
         u'col9a2': 1,
         u'dash': 1,
         u'allel': 292,
         u'necrosi': 1,
         u'5382insc': 1,
         u'phosphoribosyl': 2,
         u'fertil': 3,
         u'hydrostat': 1,
         u'greek': 1,
         u'ialpha1': 1,
         u'consortium': 4,
         u'multisystem': 3,
         u'note': 8,
         u'dispar': 2,
         u'thyrocyt': 3,
         u'take': 3,
         u'advis': 1,
         u'destroy': 3,
         u'frament': 1,
         u'ependymoma': 1,
         u'channel': 11,
         u'transferas': 6,
         u'pain': 1,
         u'trace': 8,
         u'normal': 336,
         u'ruffl': 1,
         u'basava': 1,
         u'ctsc': 8,
         u'compress': 1,
         u'beta': 11,
         u'tract': 4,
         u'pair': 48,
         u'knee': 2,
         u'paget': 1,
         u'ankl': 3,
         u'allevi': 1,
         u'synonym': 1,
         u'enamel': 4,
         u'55fe': 1,
         u'jewri': 1,
         u'drive': 4,
         u'axe': 1,
         u'salt': 1,
         u'cobra': 1,
         u'show': 211,
         u'cornea': 1,
         u'cytotox': 1,
         u'concomit': 1,
         u'aplasia': 1,
         u'unprocess': 1,
         u'saccharomyc': 2,
         u'oncolog': 1,
         u'ahaii': 1,
         u'threshold': 2,
         u'serin': 7,
         u'retinoschisin': 7,
         u'slot': 2,
         u'slow': 5,
         u'imbal': 2,
         u'vitreoretin': 2,
         u'helic': 1,
         u'parametr': 2,
         u'black': 10,
         u'helix': 3,
         u'3beta': 1,
         u'extracellular': 6,
         u'inhibitori': 3,
         u'nearli': 8,
         u'hungarian': 2,
         u'distinctli': 1,
         u'p95': 1,
         u'secondari': 9,
         u'r58f': 1,
         u'gef': 6,
         u'serolog': 2,
         ...})

In [123]:
# 2-grams, stopwords included
files = os.listdir(ncbi_dir)

bigr = []

for f in files:
    words = [w.lower() for w in ncbi.words(f)]
    sub_bigr = list(bigrams(words))
    for s in sub_bigr:
        bigr.append(s)

fd_bigr = nltk.FreqDist(bigr)
fd_bigr.plot(30, cumulative=False)



In [124]:
# 2-grams, stopwords excluded
files = os.listdir(ncbi_dir)

bigr_stop = []

for f in files:
    words = [w.lower() for w in ncbi.words(f) if w.lower() not in stopwords.words('english')]
    sub_bigr = list(bigrams(words))
    for s in sub_bigr:
        bigr_stop.append(s)

fd_bigr_stop = nltk.FreqDist(bigr_stop)
fd_bigr_stop.plot(30, cumulative=False)



In [126]:
# 3-grams, stopwords excluded
files = os.listdir(ncbi_dir)

trigr_stop = []

for f in files:
    words = [w.lower() for w in ncbi.words(f) if w.lower() not in stopwords.words('english')]
    sub_trigr = list(trigrams(words))
    for s in sub_trigr:
        trigr_stop.append(s)

fd_trigr_stop = nltk.FreqDist(trigr_stop)
fd_trigr_stop.plot(30, cumulative=False)



In [129]:
# 4-grams
files = os.listdir(ncbi_dir)

n = 4

fourgr_stop = []

for f in files:
    words = [w.lower() for w in ncbi.words(f) if w.lower() not in stopwords.words('english')]
    sub_fourgr = list(ngrams(words, n))
    for s in sub_fourgr:
        fourgr_stop.append(s)

fd_fourgr_stop = nltk.FreqDist(fourgr_stop)
fd_fourgr_stop.plot(30, cumulative=False)



In [130]:
# POS tagging
words_tag = nltk.pos_tag(words)

In [ ]:
#