-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNLP_SK_Learning.py
More file actions
36 lines (23 loc) · 1.13 KB
/
Copy pathNLP_SK_Learning.py
File metadata and controls
36 lines (23 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 25 11:53:28 2018
@author: velmurugan.m
"""
#from sklearn.datasets import fetch_20newsgroups
from nltk import word_tokenize, pos_tag
#categories = ['alt.atheism', 'soc.religion.christian', 'comp.graphics', 'sci.med']
#twenty_train = fetch_20newsgroups(subset='train', categories=categories, shuffle=True, random_state=42)
#print twenty_train.data
lookup_dict = {
'svc' : 'service',
'svr' : 'service',
'cus' : 'customer',
'cust' : 'customer',
'actv' : 'active',
}
txtData = "If the svc is not good then cust can is actv. If the svr is actv then leave it to cus."
tokens = word_tokenize( (str(txtData )).lower() )
func = lambda val: lookup_dict[val] if val in lookup_dict else val
newVal = map( lambda val: lookup_dict[val] if val in lookup_dict else val, tokens )
print newVal
#newVal = map( (lambda val: if (inp in lookup_dict) lookup_dict[inp] else inp), tokens)