コード例 #1
0
ファイル: tests_beagleviewer.py プロジェクト: inpho/vsm
    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)
コード例 #2
0
ファイル: tests_beagleviewer.py プロジェクト: xiayanchen/vsm
    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)
コード例 #3
0
ファイル: tests_beaglecontext.py プロジェクト: xiayanchen/vsm
    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()
        '''
コード例 #4
0
ファイル: tests_beaglecomposite.py プロジェクト: HANNATH/vsm
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)
コード例 #5
0
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)
コード例 #6
0
ファイル: tests_beaglecontext.py プロジェクト: HANNATH/vsm
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)


    '''
コード例 #7
0
ファイル: tests_beaglecontext.py プロジェクト: HANNATH/vsm
    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()
        '''
コード例 #8
0
ファイル: tests_beaglecontext.py プロジェクト: HANNATH/vsm
    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)
コード例 #9
0
ファイル: tests_beaglecontext.py プロジェクト: xiayanchen/vsm
    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)
コード例 #10
0
    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()
コード例 #11
0
ファイル: tests_beaglecontext.py プロジェクト: xiayanchen/vsm
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)

    '''
コード例 #12
0
ファイル: beaglecomposite.py プロジェクト: argdundee/DbyD
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
コード例 #13
0
ファイル: tests_beaglecomposite.py プロジェクト: HANNATH/vsm
    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()