-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringMatching.js
77 lines (53 loc) · 2.81 KB
/
StringMatching.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// const orgloc = require('./locality.json');
const orgloc = require('./static/pincode.json');
var FuzzyMatching = require('fuzzy-matching');
const {words} = require('./static/converttxtfiletoarr');
const favloc=[]
const favcity=[]
const cityset=new Set()
const locset=new Set()
const state = [ "Andhra Pradesh","Arunachal Pradesh","Assam","Bihar","Chhattisgarh","Goa","Gujarat","Haryana","Himachal Pradesh","Jammu and Kashmir","Jharkhand","Karnataka","Kerala","Madhya Pradesh","Maharashtra","Manipur","Meghalaya","Mizoram","Nagaland","Odisha","Punjab","Rajasthan","Sikkim","Tamil Nadu","Telangana","Tripura","Uttarakhand","Uttar Pradesh","West Bengal","Andaman and Nicobar Islands","Chandigarh","Dadra and Nagar Haveli","Daman and Diu","Delhi","Lakshadweep","Puducherry"]
orgloc.results.forEach(element => {
// var str=element['Officename ( BO/SO/HO)']
let str=element['OfficeName']
let len=str.length
let str2=element['District']
let pos=str.indexOf('(')
if(pos==-1) pos=len-3
// else pos=pos-3
str=str.substring(0,pos)
pos=str2.indexOf('(')
if(pos!=-1) str2=str2.substring(0,pos-1)
str=str.trim()
str2=str2.trim()
if(!words.includes(str.toLowerCase())){
locset.add(str)
}
if(!words.includes(str2.toLowerCase())){
cityset.add(str2)
}
favcity.push(str2)
favloc.push(str)
// console.log(str2)
// if(str2=='WEST'||str2=="SOUTH"||str2=="NORTH"||str2=="EAST"||str2=="NORTH EAST"||str2=="SOUTH WEST"||str2=="NORTH WEST"|| str2=="SOUTH EAST"){
// str2=str2+element['StateName']
// cityset.add(str2)
// favcity.push(str2)
// }
// else{
// cityset.add(str2)
// favcity.push(str2)
// }
});
// console.log(favloc.length)
// console.log(favcity.length)
// console.log(orgloc.results.length)
// console.log(orgloc.results[favcity.indexOf('MUMBAI')])
cityset.add('BANGALORE')
cityset.add('BARODA')
const locfm=new FuzzyMatching(locset);
const statefm=new FuzzyMatching(state);
const cityfm= new FuzzyMatching(cityset)
const cmpreps=["aboard","about","above","absent","across","afore","after","against","along","alongside","amid","amidst","among","amongst","anenst","apropos","apud","around","aside","astride","at","athwart","atop","barring","before","behind","below","beneath","beside","besides","between","beyond","op","by","circa","concerning","despite","down","during","except","excluding","failing","following","for","forenenst","from","given","including","inside","into","mid","midst","minus","modulo","near","next","on","onto","opposite","out","outside","over","past","regarding","round","than","till","times","toward","towards","under","underneath","unto","upon","versus","via","within"]
const prepsfm=new FuzzyMatching(cmpreps)
module.exports={locfm,statefm,favloc,cityfm,favcity,prepsfm}