This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import unicodedata | |
from transformers import AutoTokenizer | |
from . import punctuation, symbols, pu_symbols | |
from num2words import num2words | |
from pythainlp.tokenize import word_tokenize | |
from pythainlp.transliterate import romanize | |
from pythainlp.util import normalize as thai_normalize | |
from pythainlp.util import thai_to_eng, eng_to_thai | |
from melo.text.thai_dictionary import english_dictionary, etc_dictionary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datagen = ImageDataGenerator( | |
rotation_range=20, | |
width_shift_range=0.2, | |
height_shift_range=0.2 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageDraw, ImageFont | |
# Settings | |
W, H = (224, 224) | |
# Font | |
for font_name in font_names: | |
font = ImageFont.truetype("fonts/"+font_name, 224, encoding='utf-8') | |
for i in range(ord('ก'), ord('ฮ')+1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import classical | |
import quantum | |
import pandas as pd | |
from IPython.core import display as ICD | |
sbits = [0, 1] | |
tbits = [(0, 0), (0, 1), (1, 0), (1, 1)] | |
tables = [] | |
classicalTable = pd.DataFrame(columns=['bit', 'not']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def xor_gate(bit1, bit2, backend='sim', token=None): | |
assert bit1 in (0, 1) and bit2 in (0, 1), "Only 0 or 1" | |
quantumBits = 2 | |
classicalBits = 1 | |
XOR = QuantumCircuit(quantumBits, classicalBits) | |
if bit1 == 1: | |
XOR.x(0) | |
if bit2 == 1: | |
XOR.x(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def xor_gate(bit1, bit2): | |
assert bit1 in (0, 1) and bit2 in (0, 1), "Only 0 or 1" | |
if bit1 != bit2: | |
return 1 | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def or_gate(bit1, bit2, backend='sim', token=None): | |
assert bit1 in (0, 1) and bit2 in (0, 1), "Only 0 or 1" | |
quantumBits = 3 | |
classicalBits = 1 | |
OR = QuantumCircuit(quantumBits, classicalBits) | |
if bit1 == 1: | |
OR.x(0) | |
if bit2 == 1: | |
OR.x(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def or_gate(bit1, bit2): | |
assert bit1 in (0, 1) and bit2 in (0, 1), "Only 0 or 1" | |
if 1 in (bit1, bit2): | |
return 1 | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def and_gate(bit1, bit2, backend='sim', token=None): | |
assert bit1 in (0, 1) and bit2 in (0, 1), "Only 0 or 1" | |
quantumBits = 3 | |
classicalBits = 1 | |
AND = QuantumCircuit(quantumBits, classicalBits) | |
if bit1 == 1: | |
AND.x(0) | |
if bit2 == 1: | |
AND.x(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def and_gate(bit1, bit2): | |
assert bit1 in (0, 1) and bit2 in (0, 1), "Only 0 or 1" | |
return bit1 * bit2 |
NewerOlder