# Path: server/src/voicebox/voicebox.py
# class Voicebox(object):
# 
#     @staticmethod
#     def build(texts):
#         corpus = Corpus('. '.join(texts))
# 
#         voicebox = {}
# 
#         for ngram, ngram_data in corpus.tree.iteritems():
#             voicebox[ngram] = {
#                 u'frequency': float(ngram_data.count) / float(corpus.wordcount)
#             }
# 
#             voicebox[ngram][u'after'] = ngram_data.after
#             for index, after in enumerate(ngram_data.after):
#                 ngram_after_total = sum([ngram_after_count for _, ngram_after_count in after.iteritems()])
#                 for ngram_after, ngram_after_count in after.iteritems():
#                     voicebox[ngram][u'after'][index][ngram_after] = float(ngram_after_count) / float(ngram_after_total)
# 
#         voicebox[u'wordcount'] = corpus.wordcount
# 
#         return voicebox


from unittest import TestCase
from server.src.voicebox.voicebox import Voicebox
from __future__ import absolute_import



class TestVoicebox(TestCase):

    def test_build_voicebox_multiple_texts(self):

# Path: server/src/voicebox/voicebox.py
# class Voicebox(object):
# 
#     @staticmethod
#     def build(texts):
#         corpus = Corpus('. '.join(texts))
# 
#         voicebox = {}
# 
#         for ngram, ngram_data in corpus.tree.iteritems():
#             voicebox[ngram] = {
#                 u'frequency': float(ngram_data.count) / float(corpus.wordcount)
#             }
# 
#             voicebox[ngram][u'after'] = ngram_data.after
#             for index, after in enumerate(ngram_data.after):
#                 ngram_after_total = sum([ngram_after_count for _, ngram_after_count in after.iteritems()])
#                 for ngram_after, ngram_after_count in after.iteritems():
#                     voicebox[ngram][u'after'][index][ngram_after] = float(ngram_after_count) / float(ngram_after_total)
# 
#         voicebox[u'wordcount'] = corpus.wordcount
# 
#         return voicebox


# Path: server/tests/voicebox/test_voicebox.py
from unittest import TestCase
from server.src.voicebox.voicebox import Voicebox

from __future__ import absolute_import



class TestVoicebox(TestCase):

    def test_build_voicebox_multiple_texts(self):

        voicebox = Voicebox.build(texts=[