This is a memo for myself as I read Introduction to Natural Language Processing Applications in 15 Steps.
--Personal MacPC: MacOS Mojave version 10.14.6 --docker version: Version 19.03.2 for both Client and Server
As described in the book, we will cover the construction of the learning environment and the knowledge (programming language and library) that are the prerequisites for the exercises.
No notes
The writing environment is distributed as requirements.txt, and Dockerfile is also distributed.
The requirements.txt describes the type and version of the library as shown below, and you can install the library in bulk using pip.
requirements.txt
numpy==1.15.0
scipy=1.1.0
...
mecab-python3==0.996.2
neologdn==0.3.2
...
#Installation example with pip
$ pip install --no-cache-dir -r requirements.txt
When using Dockerfile, build and start Docker container from Dockerfile. (I run it here)
###Container build###
#Run in the location where the Dockerfile is located
$ ls | grep Dockerfile
Dockerfile
#Build with repository name: 15step, tag name: latest
$ docker build -t 15step:latest .
###Container startup###
#When the container is started by default, python is started
$ docker run -it 15step:latest
Python 3.6.5 (default, Jun 27 2018, 08:22:23)
>>>
#Stop is quit()
>>>quit()
$
#How to start python after starting bash
$ docker run -it 15step:latest /bin/bash
/usr/src/app#
/usr/src/app# python
Python 3.6.5 (default, Jun 27 2018, 08:22:23)
>>>
--Allows you to use lists, tuples, and dictionaries properly
--Tuples are immutable
――How to write ternary operators in English compared to C language
- price = 1000 if age >= 20 else 800
--If age> = 20, price = 1000 is executed, otherwise price = 800 is executed.
--for statement
--For each list, for val in <list>:
--If you want a counter variable, set enumerate to for i, val in enumerate (<list>):
--If you want only the counter variable, set range to for i in range (5):
--Functions, classes, modules
--Load module ʻimport module as md --Call a function with
md.method --
from module import method to load module functions
--Call a function with method
--Regular expressions can be executed faster if the regular expression pattern is compiled in advance.
--The array is numpy.array (<list>)
--The dimension is <array> .shape
--Slice (obtained by specifying multiple elements) is <array> [m: n]
--Get elements m ~ n-1
--Optional if m = 0 or n = <array 1> operator <array 2>
--The inner product is numpy.dot (<array 1>, <array 2>)
--If you want to get the maximum value
--Getting the maximum value of an element is numpy.max (<array>)
--Getting the index of the maximum value of an element is numpy.argmax (<array>)
--Total, average, random number, initialization (initialize with 0, initialize with 1)
--Sequence join
--Vertical direction is numpy.vstack (<array 1>, <array 2>)
--Horizontal direction is numpy.hstack (<array 1>, <array 2>)
No notes
-Introduction to natural language processing application in 15 steps