统计机器翻译(英语:Statistical Machine Translation,简写为SMT)是机器翻译的一种,基本思想是通过对大量的平行语料进行统计分析,构建模型,进而使用此模型进行翻译。
所谓的平行语料就是表达同一个意思的不同语言的句子,如:
這是一個蘋果。
This is an apple.
桌上有一本書。
There is a book on the table.
import arrow | |
def diff_month(d1, d2): | |
return (d1.year - d2.year) * 12 + d1.month - d2.month | |
def calc_deadline(start_date, period): | |
date = arrow.get(start_date) | |
now = arrow.get() |
import datetime | |
import redis | |
class DictStack(object): | |
def __init__(self, key_name, redis_option): | |
self._db = redis.StrictRedis(**redis_option) | |
self._key_name = key_name |
import copy | |
import types | |
def shield_sensitive(obj, *args): | |
""" | |
replace all sensitive value to `******`, according to instance attribute or dict key. | |
""" | |
try: |
# list all resource requested by a request | |
from ghost import Ghost | |
ghost = Ghost() | |
def get_all_resources(url): | |
with ghost.start() as session: | |
page, extra_resources = session.open(url) | |
for extra_resource in extra_resources: |
# 参考链接: http://stackoverflow.com/questions/101128/how-do-i-read-text-from-the-windows-clipboard-from-python | |
import win32clipboard | |
win32clipboard.OpenClipboard() | |
for i in range(0XFFFF): | |
try: | |
data = win32clipboard.GetClipboardData(i) | |
print("Clipboard Formats Value: {}(HEX:{:X})".format(i, i)) | |
print("ClipboardDate:\n{}".format(repr(data))) | |
print("------------------------------------------------------------------------") |