def setUp(self): from vsm.corpus.util.corpusbuilders import random_corpus from vsm.model.beagleenvironment import BeagleEnvironment from vsm.model.beaglecontext import BeagleContextSeq from vsm.model.beagleorder import BeagleOrderSeq from vsm.model.beaglecomposite import BeagleComposite ec = random_corpus(1000, 50, 0, 20, context_type='sentence') cc = ec.apply_stoplist(stoplist=[str(i) for i in range(0, 50, 7)]) e = BeagleEnvironment(ec, n_cols=5) e.train() cm = BeagleContextSeq(cc, ec, e.matrix) cm.train() om = BeagleOrderSeq(ec, e.matrix) om.train() m = BeagleComposite(cc, cm.matrix, ec, om.matrix) m.train() self.venv = BeagleViewer(ec, e) self.vctx = BeagleViewer(cc, cm) self.vord = BeagleViewer(ec, om) self.vcom = BeagleViewer(cc, m)
def setUp(self): from vsm.corpus.util.corpusbuilders import random_corpus from vsm.model.beagleenvironment import BeagleEnvironment from vsm.model.beaglecontext import BeagleContextSeq from vsm.model.beagleorder import BeagleOrderSeq from vsm.model.beaglecomposite import BeagleComposite ec = random_corpus(1000, 50, 0, 20, context_type='sentence') cc = ec.apply_stoplist(stoplist=[str(i) for i in range(0,50,7)]) e = BeagleEnvironment(ec, n_cols=5) e.train() cm = BeagleContextSeq(cc, ec, e.matrix) cm.train() om = BeagleOrderSeq(ec, e.matrix) om.train() m = BeagleComposite(cc, cm.matrix, ec, om.matrix) m.train() self.venv = BeagleViewer(ec, e) self.vctx = BeagleViewer(cc, cm) self.vord = BeagleViewer(ec, om) self.vcom = BeagleViewer(cc, m)
class TestBeagleComposite(unittest.TestCase): def setUp(self): from vsm.corpus.util.corpusbuilders import random_corpus from vsm.model.beaglecomposite import BeagleComposite from vsm.model.beagleenvironment import BeagleEnvironment from vsm.model.beaglecontext import BeagleContextSeq from vsm.model.beagleorder import BeagleOrderSeq self.ec = random_corpus(1000, 50, 0, 20, context_type='sentence') self.cc = self.ec.apply_stoplist(stoplist=[str(i) for i in xrange(0,50,7)]) self.e = BeagleEnvironment(self.ec, n_cols=5) self.e.train() self.cm = BeagleContextSeq(self.cc, self.ec, self.e.matrix) self.cm.train() self.om = BeagleOrderSeq(self.ec, self.e.matrix) self.om.train() self.m = BeagleComposite(self.cc, self.cm.matrix, self.ec, self.om.matrix) self.m.train() def test_BeagleCompositeIO(self): from tempfile import NamedTemporaryFile from vsm.model.beaglecomposite import BeagleComposite import os try: tmp = NamedTemporaryFile(delete=False, suffix='.npz') self.m.save(tmp.name) tmp.close() m1 = BeagleComposite.load(tmp.name) self.assertTrue((self.m.matrix == m1.matrix).all()) finally: os.remove(tmp.name)
class TestBeagleComposite(unittest.TestCase): def setUp(self): from vsm.corpus.util.corpusbuilders import random_corpus from vsm.model.beaglecomposite import BeagleComposite from vsm.model.beagleenvironment import BeagleEnvironment from vsm.model.beaglecontext import BeagleContextSeq from vsm.model.beagleorder import BeagleOrderSeq self.ec = random_corpus(1000, 50, 0, 20, context_type='sentence') self.cc = self.ec.apply_stoplist( stoplist=[str(i) for i in range(0, 50, 7)]) self.e = BeagleEnvironment(self.ec, n_cols=5) self.e.train() self.cm = BeagleContextSeq(self.cc, self.ec, self.e.matrix) self.cm.train() self.om = BeagleOrderSeq(self.ec, self.e.matrix) self.om.train() self.m = BeagleComposite(self.cc, self.cm.matrix, self.ec, self.om.matrix) self.m.train() def test_BeagleCompositeIO(self): from tempfile import NamedTemporaryFile from vsm.model.beaglecomposite import BeagleComposite import os try: tmp = NamedTemporaryFile(delete=False, suffix='.npz') self.m.save(tmp.name) tmp.close() m1 = BeagleComposite.load(tmp.name) self.assertTrue((self.m.matrix == m1.matrix).all()) finally: os.remove(tmp.name)
class TestBeagleContext(unittest.TestCase): def setUp(self): from vsm.corpus.util.corpusbuilders import random_corpus from vsm.model.beaglecontext import BeagleContextSeq, BeagleContextMulti from vsm.model.beagleenvironment import BeagleEnvironment self.ec = random_corpus(1000, 50, 0, 5, context_type='sentence') self.cc = self.ec.apply_stoplist(stoplist=[str(i) for i in xrange(0,50,7)]) self.e = BeagleEnvironment(self.ec, n_cols=5) self.e.train() self.ms = BeagleContextSeq(self.cc, self.ec, self.e.matrix) self.ms.train() ''' self.mm = BeagleContextMulti(self.cc, self.ec, self.e.matrix) self.mm.train(n_procs=2) ''' def test_BeagleContextSeq(self): from tempfile import NamedTemporaryFile import os from vsm.model.beaglecontext import BeagleContextSeq try: tmp = NamedTemporaryFile(delete=False, suffix='.npz') self.ms.save(tmp.name) tmp.close() m1 = BeagleContextSeq.load(tmp.name) self.assertTrue((self.ms.matrix == m1.matrix).all()) finally: os.remove(tmp.name) '''
class TestBeagleContext(unittest.TestCase): def setUp(self): from vsm.corpus.util.corpusbuilders import random_corpus from vsm.model.beaglecontext import BeagleContextSeq, BeagleContextMulti from vsm.model.beagleenvironment import BeagleEnvironment self.ec = random_corpus(1000, 50, 0, 5, context_type='sentence') self.cc = self.ec.apply_stoplist( stoplist=[str(i) for i in range(0, 50, 7)]) self.e = BeagleEnvironment(self.ec, n_cols=5) self.e.train() self.ms = BeagleContextSeq(self.cc, self.ec, self.e.matrix) self.ms.train() ''' self.mm = BeagleContextMulti(self.cc, self.ec, self.e.matrix) self.mm.train(n_procs=2) ''' def test_BeagleContextSeq(self): from tempfile import NamedTemporaryFile import os from vsm.model.beaglecontext import BeagleContextSeq try: tmp = NamedTemporaryFile(delete=False, suffix='.npz') self.ms.save(tmp.name) tmp.close() m1 = BeagleContextSeq.load(tmp.name) self.assertTrue((self.ms.matrix == m1.matrix).all()) finally: os.remove(tmp.name) '''
def test_BeagleComposite(): from vsm.util.corpustools import random_corpus from vsm.model.beagleenvironment import BeagleEnvironment from vsm.model.beaglecontext import BeagleContextSeq from vsm.model.beagleorder import BeagleOrderSeq ec = random_corpus(1000, 50, 0, 20, context_type='sentence') cc = ec.apply_stoplist(stoplist=[str(i) for i in xrange(0,50,7)]) e = BeagleEnvironment(ec, n_cols=5) e.train() cm = BeagleContextSeq(cc, ec, e.matrix) cm.train() om = BeagleOrderSeq(ec, e.matrix) om.train() m = BeagleComposite(cc, cm.matrix, ec, om.matrix) m.train() from tempfile import NamedTemporaryFile import os try: tmp = NamedTemporaryFile(delete=False, suffix='.npz') m.save(tmp.name) tmp.close() m1 = BeagleComposite.load(tmp.name) assert (m.matrix == m1.matrix).all() finally: os.remove(tmp.name) return m.matrix