English is the most spoken language in the world and French is an official language in 29 countries. As part of this exercise, we will build a French-to-English translator. Let's begin:
The dataset used here is sourced from http://www.manythings.org/anki/
- As with any other exercise, we begin by importing the libraries that we need to build our French-to-English translator:
import pandas as pd
import string
import re
import io
import numpy as np
from unicodedata import normalize
import keras, tensorflow
from keras.models import Model
from keras.layers import Input, LSTM, Dense
- Now that we have imported our libraries, let's read the dataset using the following code block:
def read_data(file):
data = []
with io.open(file, 'r') as file:
for entry in file:
entry = entry.strip()
data.append(entry)
return data
data = read_data('dataset/bilingual_pairs.txt')
- Let's figure...