<commit_before># Copyright (c) 2013 The SAYCBridge Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import copy
import datetime
import urllib

import webapp2
import jinja2
import os

jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader("templates"))

from core.callhistory import CallHistory
from core.board import Board
from core.deal import Deal
from core.position import position_from_char
from core.call import Pass

from proxy import BidderProxy

import json


class JSONAutobidHandler(webapp2.RequestHandler):
    def _board_from_request(self):
        board_number = int(self.request.get('number'))
        vulnerability_string = self.request.get('vunerability')
        hand_strings = map(str, [
            self.request.get('deal[north]'),
            self.request.get('deal[east]'),
            self.request.get('deal[south]'),
            self.request.get('deal[west]'),
        ])

        deal = Deal.from_string(' '.join(hand_strings))
        dealer_char = self.request.get('dealer')
        # Note: We keep bids_string around to I can test old requests.
        calls_string = self.request.get('calls_string') or self.request.get('bids_string') or ''
        history = CallHistory.from_string(calls_string, dealer_char, vulnerability_string)
        return Board(board_number, deal, history)

    def _json_tuple(self, selection):
        json_tuple = [None, None, None, None, None]
        if not selection:
            return json_tuple
        if selection.call:
            json_tuple[0] = selection.call.name
        if selection.rule:
            json_tuple[1] = selection.rule.name
        if selection.hand_knowledge:
            json_tuple[2] = selection.hand_knowledge.pretty_one_line(include_last_call_name=False)
        if selection.rule and selection.call:
            json_tuple[3] = selection.rule.explanation_for_bid(selection.call)
            json_tuple[4] = selection.rule.sayc_page_for_bid(selection.call)<commit_msg>Remove some dead code<commit_after># Copyright (c) 2013 The SAYCBridge Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import copy
import datetime
import urllib

import webapp2
import jinja2
import os

jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader("templates"))

from core.callhistory import CallHistory
from core.board import Board
from core.deal import Deal
from core.position import position_from_char
from core.call import Pass

from proxy import BidderProxy

import json


class JSONAutobidHandler(webapp2.RequestHandler):
    def _board_from_request(self):
        board_number = int(self.request.get('number'))
        vulnerability_string = self.request.get('vunerability')
        hand_strings = map(str, [
            self.request.get('deal[north]'),
            self.request.get('deal[east]'),
            self.request.get('deal[south]'),
            self.request.get('deal[west]'),
        ])

        deal = Deal.from_string(' '.join(hand_strings))
        dealer_char = self.request.get('dealer')
        calls_string = self.request.get('calls_string', '')
        history = CallHistory.from_string(calls_string, dealer_char, vulnerability_string)
        return Board(board_number, deal, history)

    def _json_tuple(self, selection):
        json_tuple = [None, None, None, None, None]
        if not selection:
            return json_tuple
        if selection.call:
            json_tuple[0] = selection.call.name
        if selection.rule:
            json_tuple[1] = selection.rule.name
        if selection.hand_knowledge:
            json_tuple[2] = selection.hand_knowledge.pretty_one_line(include_last_call_name=False)
        if selection.rule and selection.call:
            json_tuple[3] = selection.rule.explanation_for_bid(selection.call)
            json_tuple[4] = selection.rule.sayc_page_for_bid(selection.call)
{'fraction_non_alphanumeric': 0.09326683291770574, 'fraction_numerical': 0.006982543640897756, 'mean_word_length': 3.2579617834394905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2996939', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1153, 'n_words': 280}