Ejemplo n.º 1
0
    def html_visualize(self, viewer_mode, html_output, css_file=None, img_path=None, worker_ids=None):
        chats = []
        scenario_to_chats = defaultdict(set)
        dialogue_responses = None
        if self.question_scores:
            dialogue_responses = self.get_dialogue_responses(self.question_scores)

            # Put chats in the order of responses
            chats_with_survey = set()
            for dialogue_id, agent_responses in dialogue_responses.iteritems():
                chat = self.uuid_to_chat[dialogue_id]
                scenario_id = chat['scenario_uuid']
                chats.append((scenario_id, chat))
                chats_with_survey.add(dialogue_id)
                scenario_to_chats[scenario_id].add(dialogue_id)
            chats = [x[1] for x in sorted(chats, key=lambda x: x[0])]
            # Incomplete chats (redirected, no survey)
            for (dialogue_id, chat) in self.uuid_to_chat.iteritems():
                if dialogue_id not in chats_with_survey:
                    chats.append(chat)
        else:
            for (dialogue_id, chat) in self.uuid_to_chat.iteritems():
                scenario_id = chat['scenario_uuid']
                chats.append((scenario_id, chat))
                scenario_to_chats[scenario_id].add(dialogue_id)
            chats = [x[1] for x in sorted(chats, key=lambda x: x[0])]

        html_visualizer = HTMLVisualizer()
        html_visualizer.visualize(viewer_mode, html_output, chats,
            responses=dialogue_responses, css_file=css_file, img_path=img_path)
Ejemplo n.º 2
0
                        action='store_true',
                        help='Whether this is from partner survey')
    parser.add_argument('--task',
                        default='cl-neg',
                        choices=['cl-neg', 'fb-neg', 'mutual', 'movies'],
                        help='which task you are trying run')
    parser.add_argument(
        '--worker-ids',
        nargs='+',
        help='Path to json file containing chat_id to worker_id mappings')
    parser.add_argument('--hist',
                        default=False,
                        action='store_true',
                        help='Plot histgram of ratings')

    HTMLVisualizer.add_html_visualizer_arguments(parser)
    args = parser.parse_args()

    visualizer = Visualizer(args.dialogue_transcripts, args.survey_transcripts)
    visualizer.compute_effectiveness()

    if args.hist:
        visualizer.hist(question_scores, args.outdir, partner=args.partner)
    if args.worker_ids:
        visualizer.worker_stats()

    # TODO: move summary and hist to analyzer
    if args.summary:
        summary = visualizer.summarize()
        write_json(summary, args.stats)
    if args.html_output: