In [1]:
from vsm import *
from vsm.extensions.corpusbuilders import toy_corpus
plain_corpus = """
His theology challenged the Pope of the Roman Catholic Church by
teaching that the Bible is the only source of divinely revealed
knowledge.
Augustine is held in the Catholic Church to be the model teacher.
Augustine was recognized as a Doctor of the Church by Pope Boniface
VIII.
Roman Catholic theology stated that faith alone cannot justify man.
In the Catholic Church the Pope is regarded as the successor of Saint
Peter.
Alonzo Church was an American mathematician and logician who made
major contributions to mathematical logic and the foundations of
theoretical computer science.
The lambda calculus was introduced by mathematician Alonzo Church as
an investigation into the foundations of mathematics.
The Church Turing thesis states that a function is algorithmically
computable if and only if it is computable by a Turing machine.
Mathematical logic has close connections to the foundations of
mathematics, theoretical computer science.
A Turing machine can be adapted to simulate the logic of any computer
algorithm.
"""
metadata = ['Ecclesiastical ' + str(i) for i in xrange(1, 6)]
metadata += ['Logic ' + str(i) for i in xrange(1, 6)]
env_c = toy_corpus(plain_corpus, nltk_stop=False, metadata=metadata)
c = toy_corpus(plain_corpus, nltk_stop=True, metadata=metadata)
e = BeagleEnvironment(env_c, context_type='document')
e.train()
m = BeagleContextSeq(c, env_c, e.matrix, context_type='document')
m.train()
v = BeagleViewer(c, m)
In [2]:
v.dist_word_word('logic', print_len=24)
Out[2]:
In [3]:
np.around(v.dismat_word(['logic','church','catholic','pope']), decimals=2)
Out[3]: