统计机器翻译(英语:Statistical Machine Translation,简写为SMT)是机器翻译的一种,基本思想是通过对大量的平行语料进行统计分析,构建模型,进而使用此模型进行翻译。
所谓的平行语料就是表达同一个意思的不同语言的句子,如:
這是一個蘋果。
This is an apple.
桌上有一本書。
There is a book on the table.
# 参考链接: 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("------------------------------------------------------------------------") |
# 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: |
import copy | |
import types | |
def shield_sensitive(obj, *args): | |
""" | |
replace all sensitive value to `******`, according to instance attribute or dict key. | |
""" | |
try: |
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 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() |
*** Error in `/home/jeffrey/workspace/romulan-env/bin/python2.7': free(): corrupted unsorted chunks: 0x00000000036437e0 *** | |
======= Backtrace: ========= | |
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fcf86e667e5] | |
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fcf86e6f37a] | |
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fcf86e7353c] | |
/home/jeffrey/workspace/romulan-env/bin/python2.7[0x509019] | |
/home/jeffrey/workspace/romulan-env/bin/python2.7[0x4b5244] | |
/home/jeffrey/workspace/romulan-env/bin/python2.7[0x4a6359] | |
/home/jeffrey/workspace/romulan-env/local/lib/python2.7/site-packages/pymssql.so(+0x20cb2)[0x7fcf738a9cb2] | |
/home/jeffrey/workspace/romulan-env/bin/python2.7(PyEval_EvalFrameEx+0x5780)[0x4c9780] |
import collections | |
class groupby2(object): | |
""" | |
[k for k, g in groupby2('AAAABBBCCDAABBB')] --> A B C D | |
""" | |
def __init__(self, iterable, key=lambda x: x): | |
self.key_func = key |
CREATE TABLE TABLE_A | |
( | |
AID NUMBER(10) NOT NULL PRIMARY KEY | |
); | |
CREATE TABLE TABLE_B | |
( | |
BID NUMBER(12) NOT NULL PRIMARY KEY, | |
AID NUMBER(10) NOT NULL REFERENCES TABLE_A (AID) | |
); |
-- 条件为IN的时候是51条,条件为Not In的时候应该是7条结果是0 | |
SELECT | |
DISTINCT CH || QH AREACODE | |
FROM PTB_YHZL | |
-- 58 rows | |
WHERE PTB_YHZL.CH || QH NOT IN ( | |
SELECT PTB_DQ.CH || QH | |
FROM PTB_FCXX | |
LEFT JOIN ptb_dq ON PTB_FCXX.CH = PTB_DQ.CH | |
-- 53 rows |