Esempio n. 1
0
 def display_listener_matrix(self, mat, title='', digits=4):
     """Pretty-printed (to stdout) listener matrix to standard output"""
     display_matrix(mat,
                    title='L{}'.format(title),
                    rnames=self.messages,
                    cnames=self.states,
                    digits=digits)
Esempio n. 2
0
 def display_listener_matrix(self, mat, title='', digits=4):
     """Pretty-printed (to stdout) listener matrix to standard output"""
     display_matrix(
         mat,
         title='L{}'.format(title),
         rnames=self.messages,
         cnames=self.states,
         digits=digits)
Esempio n. 3
0
 def display(self, digits=4):
     """Display all the lexica in a readable way"""
     for i, mat in enumerate(self.lexica2matrices()):
         display_matrix(mat,
                        rnames=self.messages,
                        cnames=self.states,
                        title="Lex{}".format(i),
                        digits=digits)
Esempio n. 4
0
 def display(self, digits=4):
     """Display all the lexica in a readable way"""
     for i, mat in enumerate(self.lexica2matrices()):      
         display_matrix(
             mat,
             rnames=self.messages,
             cnames=self.states,
             title="Lex{}".format(i),
             digits=digits)
Esempio n. 5
0
 def display_joint_listener(self, mat, title='', digits=4):
     """Pretty-printed (to stdout) lexicon x world joint probability
     table for a given message"""
     lexnames = ['Lex%s: %s' % (i, self.lex2str(lex))
                 for i, lex in enumerate(self.lexica)]
     display_matrix(
         mat,
         rnames=lexnames,
         cnames=self.states,
         title=title,
         digits=digits)        
Esempio n. 6
0
 def display_joint_listener(self, mat, title='', digits=4):
     """Pretty-printed (to stdout) lexicon x world joint probability
     table for a given message"""
     lexnames = [
         'Lex%s: %s' % (i, self.lex2str(lex))
         for i, lex in enumerate(self.lexica)
     ]
     display_matrix(mat,
                    rnames=lexnames,
                    cnames=self.states,
                    title=title,
                    digits=digits)
Esempio n. 7
0
 def listener_report(self, digits=4):
     print("=" * 70)  # Divider bar.
     print('Lexica: {}'.format(self.lexcount))
     print('Final listener')
     display_matrix(self.final_listener,
                    rnames=self.messages,
                    cnames=self.states,
                    digits=digits)
     print('\nBest inferences:')
     best_inferences = self.get_best_inferences(digits=digits)
     for msg, val in sorted(best_inferences.items()):
         print("\t{} {}".format(msg, val))
     print("\nLaTeX table:\n")
     print(self.final_listener2latex())
Esempio n. 8
0
 def listener_report(self, digits=4):
     print("=" * 70) # Divider bar.
     print('Lexica: {}'.format(self.lexcount))
     print('Final listener')
     display_matrix(
         self.final_listener,
         rnames=self.messages,
         cnames=self.states,
         digits=digits)
     print('\nBest inferences:')
     best_inferences = self.get_best_inferences(digits=digits)  
     for msg, val in sorted(best_inferences.items()):
         print("\t{} {}".format(msg, val))
     print("\nLaTeX table:\n")
     print(self.final_listener2latex())
Esempio n. 9
0
        return refine

    def refinements(self, semval):
        return powerset(semval, minsize=1)


######################################################################

if __name__ == '__main__':

    players = [a, b]
    shots = [s1, s2]
    basic_states = (0, 1)
    worlds = get_worlds(basic_states=(0, 1), length=2, increasing=False)
    baselexicon = define_lexicon(player=players, shot=shots, worlds=worlds)

    ug = UncertaintyGrammars(
        baselexicon=baselexicon,
        messages=[("PlayerA(scored)", "iv(PlayerA, scored)"),
                  ("PlayerB(scored)", "iv(PlayerB, scored)"),
                  ("every(player)(scored)", "iv(fa(every, player), scored)"),
                  ("no(player)(scored)", "iv(fa(no, player), scored)"),
                  ("some_player(scored)", "iv(some_player, scored)")],
        worlds=worlds,
        refinable={'scored': []},
        nullmsg=True)

    worldnames = [worldname(w) for w in worlds]
    for lex in ug.lexicon_iterator():
        display_matrix(lex, rnames=ug.messages, cnames=worldnames)
Esempio n. 10
0
                refine[word] = [semval]
        return refine

    def refinements(self, semval):
        return powerset(semval, minsize=1)
       
######################################################################

if __name__ == '__main__':

    players = [a,b]
    shots = [s1,s2]
    basic_states = (0,1)
    worlds = get_worlds(basic_states=(0,1), length=2, increasing=False)
    baselexicon = define_lexicon(player=players, shot=shots, worlds=worlds)

    ug = UncertaintyGrammars(
        baselexicon=baselexicon,
        messages=[("PlayerA(scored)",       "iv(PlayerA, scored)"),
                  ("PlayerB(scored)",       "iv(PlayerB, scored)"),
                  ("every(player)(scored)", "iv(fa(every, player), scored)"),
                  ("no(player)(scored)",    "iv(fa(no, player), scored)"),
                  ("some_player(scored)",   "iv(some_player, scored)")],
        worlds=worlds,
        refinable={'scored':[]},
        nullmsg=True)

    worldnames = [worldname(w) for w in worlds]
    for lex in ug.lexicon_iterator():
        display_matrix(lex, rnames=ug.messages, cnames=worldnames)