<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
# moehime / scripts / chart plotter
#
# Copyright (C) 2012 <NAME> <<EMAIL>>
#
# This file is part of moehime.
#
# moehime is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# moehime is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with moehime.  If not, see <http://www.gnu.org/licenses/>.

# TODO: MASSIVELY REFACTOR THIS!!! 这个得大尺度重构

from __future__ import unicode_literals, division

import sys

stderr = sys.stderr

import cPickle
import re
from itertools import izip_longest

import datetime
from time import mktime

import matplotlib.pyplot as plt
import matplotlib.font_manager as fontmgr
from matplotlib.dates import date2num, AutoDateFormatter, AutoDateLocator

RE_NAME = re.compile(
        r'^(?P<name>.*?)(?:（(?P<shortname>[^）]+)）)?＠(?P<series>.*)$'
        )

#####################################################################
# Plotting settings

IMAGE_SIZE = (8.0, 6.0, )

AXES_TRANSPARENCY = True

SHOW_TITLE = False
TITLE_FORMAT = '最萌%(year)d %(month)02d/%(day)02d 第 %(group)d 组面票图'<commit_msg>Preliminary backend detection code 初步的后端检测代码<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
# moehime / scripts / chart plotter
#
# Copyright (C) 2012 <NAME> <<EMAIL>>
#
# This file is part of moehime.
#
# moehime is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# moehime is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with moehime.  If not, see <http://www.gnu.org/licenses/>.

# TODO: MASSIVELY REFACTOR THIS!!! 这个得大尺度重构

from __future__ import unicode_literals, division

import sys

stderr = sys.stderr

import cPickle
import re
from itertools import izip_longest

import datetime
from time import mktime

# backends possibly need configuration, mainly because of Windows
# Also Tk's look-and-feel sucks
# XXX this code is definitely smelly, needs to get rid of very soon
# 图形后端可能需要配置，主要是因为要支持 Windows 的原因
# 而且 Tk 界面给人感觉实在蛋疼
# XXX 这段代码味道很不好，需要非常快地解决掉
import matplotlib
_backend_decided = False

if sys.platform == 'win32':
    try:
        import PySide
        matplotlib.rc('backend', qt4='PySide')
        matplotlib.use('Qt4Agg')
        _backend_decided = True
    except ImportError:
        pass
else:
    # let's use auto detection on non-Windows platforms
    # 非 Windows 平台就用自动检测吧
    _backend_decided = True

if not _backend_decided:
    raise RuntimeError('could not decide what backend to use')
del _backend_decided

import matplotlib.pyplot as plt
import matplotlib.font_manager as fontmgr
from matplotlib.dates import date2num, AutoDateFormatter, AutoDateLocator

RE_NAME = re.compile(
        r'^(?P<name>.*?)(?:（(?P<shortname>[^）]+)）)?＠(?P<series>.*)$'
        )

#####################################################################
# Plotting settings

IMAGE_SIZE = (8.0, 6.0, )

AXES_TRANSPARENCY = True

SHOW_TITLE = False
TITLE_FORMAT = '最萌%(year)d %(month)02d/%(day)02d 第 %(group)d 组面票图'
{'fraction_non_alphanumeric': 0.1266684114106255, 'fraction_numerical': 0.008898194190002618, 'mean_word_length': 4.360448807854137, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7442780', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1271, 'n_words': 434}