Using NLTK
- import:
import nltk
- download examples:
import nltk
, thennltk.download()
- opens nltk downloader GUI can download collections/packages
- corpora: sets of structured text
- Example:
import pandas as pd | |
# create dataframes | |
df1 = pd.DataFrame({'key': ['K0', 'K1', 'K2'], | |
'W': ['W0', 'W1', 'W2'], | |
'Y': ['Y0', 'Y1', 'Y2']}) | |
df2 = pd.DataFrame({'key': ['K0', 'K1', 'K2'], | |
'X': ['X0', 'X1', 'X2'], | |
'Z': ['Z0', 'Z1', 'Z2']}) |
// sets | |
let exampleSet = new Set(); | |
// has one property - size | |
exampleSet.add(1); // exampleSet: Set {1} | |
exampleSet.add(1); // exampleSet: Set {1} | |
exampleSet.add(2); // exampleSet: Set {1, 2} | |
// deletion | |
exampleSet.delete(1); // true, exampleSet: Set {2} |
// array literal | |
let array1 = [1,2,3,4]; | |
array1.push(5); //array1 = [1,2,3,4,5] | |
array1.push(7); //array1 = [1,2,3,4,5,7] | |
array1.push(2); //array1 = [1,2,3,4,5,7,2] | |
console.log(array1); | |
// deletion: pop returns last item | |
let array2 = [1,2,3,4]; | |
array2.pop(); //returns 4, array2 = [1,2,3] |
// JavaScript objects can be created via the object literal {} or via the syntax new Object(); | |
// Additional properties can be added or accessed in one of two ways: | |
// object.propertyName or object['propertyName']. | |
let javascriptObj = {}; | |
let testArr = [1,2,3,4]; | |
javascriptObj.array = testArr; | |
console.log(javascriptObj); |
// tail recursion: uses O(N) time and O(N) space (call stack) | |
function getNthFibTail(n, prev, curr){ | |
if(n === 0){ return prev; } | |
if(n === 1){ return curr; } | |
return getNthFibTail((n-1), curr, (curr+prev)); | |
} |
<ng-template #titleTemplate let-text="title"> | |
<h4 class="p-2 bg-success text-white">{{text}}</h4> | |
</ng-template> | |
<ng-template [ngTemplateOutlet]="titleTemplate" | |
[ngTemplateOutletContext]="{title: 'Header'}"> | |
</ng-template> | |
<div class="text-white m-2"> |