我們準備了兩個句子來進行這次實驗
sentences = ['helo attention','have a nice day']一開始先建立詞表與對應的單詞one-hot encoding
vocabs = ' '.join(sentences).split()
vocabs = list(set(vocabs))| try: | |
| import re2 as re | |
| except: | |
| import re | |
| pattern = '(?P<code>\d{5}|\d{3})?\s*(?P<country>[台臺]灣)?(?P<city>\D+?[縣市])(?P<district>\D+?(市區|鎮區|鎮市|[鄉鎮市區]))?(?P<village>\D+?[村里](?!路))?(?P<neighbor>\d+[鄰])?(?P<road>\D+?(村路|[路街道段]))?(?P<section>(\d|\D)?段)?(?P<lane>\d+巷)?(?P<alley>\d+弄)?(?P<no>\d+號?)?(?P<seq>[-之]\d+?(號))?(?P<floor>(((\D|\d)+樓)|((B|地下室?)\d+)))?(?P<other>.+)?' | |
| addr_regex = re.compile(pattern) | |
| cn_num = '一二三四五六七八九十' | |
| cn_mapping = {k: str(v) for k, v in zip(list(cn_num), |
| S3_ACCESS_KEY_ID_GITLAB_BACKUP=<ACCESS_KEY> | |
| S3_SECRET_ACCESS_KEY_GITLAB_BACKUP=<SECRET_KEY> |
| import argparse | |
| import json | |
| import logging | |
| import pathlib | |
| from xml.etree import ElementTree | |
| log = logging.getLogger(__name__) | |
| def _parse_arguments() -> argparse.Namespace: |
| local 192.168.2.0 # SWAP THIS NUMBER WITH YOUR RASPBERRY PI IP ADDRESS | |
| dev tun | |
| proto udp #Some people prefer to use tcp. Don't change it if you don't know. | |
| port 1194 | |
| ca /etc/openvpn/easy-rsa/keys/ca.crt | |
| cert /etc/openvpn/easy-rsa/keys/Server.crt # SWAP WITH YOUR CRT NAME | |
| key /etc/openvpn/easy-rsa/keys/Server.key # SWAP WITH YOUR KEY NAME | |
| dh /etc/openvpn/easy-rsa/keys/dh1024.pem # If you changed to 2048, change that here! | |
| server 10.8.0.0 255.255.255.0 | |
| # server and remote endpoints |
| GATEWAY_FLAGS := -I. -I/usr/local/include -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I/usr/local/include | |
| GRPC_FLAGS := --python_out=. --grpc_python_out=. | |
| code: | |
| python -m grpc_tools.protoc $(GRPC_FLAGS) $(GATEWAY_FLAGS) *.proto | |
| gw: | |
| protoc $(GATEWAY_FLAGS) \ | |
| --go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \ |
| FROM python:3.6 | |
| # install bazel | |
| # check the bazel version what you want to build tensroflw and change the VERSION | |
| # https://www.tensorflow.org/install/source#linux | |
| ARG BAZEL_VERSION 0.15.0 | |
| ARG TENSORFLOW_VERSION 1.12.0 | |
| RUN apt-get update; apt-get install openjdk-8-jdk | |
| RUN set -ex && wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh \ | |
| && chmod +x bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh ./bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh \ |
| # syntax = docker/dockerfile:experimental | |
| FROM python:3.6 as base | |
| ###################################### | |
| FROM base as builder | |
| ENV PYTHONPATH=$PYTHONPATH:/install/lib/python3.6/site-packages/ | |
| # bind a wheel and install it |
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| ### fork from https://github.com/subyraman/sanic_compress | |
| import gzip | |
| DEFAULT_MIME_TYPES = frozenset([ | |
| 'text/html', 'text/css', 'text/xml', | |
| 'application/json', |
| # (C) Kyle Kastner, June 2014 | |
| # License: BSD 3 clause | |
| import scipy.stats as st | |
| import numpy as np | |
| class gmmhmm: | |
| #This class converted with modifications from https://code.google.com/p/hmm-speech-recognition/source/browse/Word.m | |
| def __init__(self, n_states): | |
| self.n_states = n_states |