-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeUsingSepClasses.py
77 lines (43 loc) · 2.04 KB
/
CodeUsingSepClasses.py
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
#Using separateclasses
import web
#Url mappings
urls = (
'/tok', 'clean_and_tokenization',
'/stop', 'stopwords',
'/stem', 'stemming',
'/spell', 'spellcorrector',
)
app = web.application(urls, globals())
#Class for cleaning and tokenizing the text
#if we write - http://localhost:8080/tok - tokenization is performed
class clean_and_tokenization:
def GET(self):
# Create another file.
# Import that file
# call method from here.
dirty_sen = ["here! <><>?//||are$ some# very *simple basic? @sentences.","they% wont be# very #complex, i'm #sure.","the +point_ of% these) _examples is= *to learn\\ how% basic* (text_ cleaning+ works_ on *very simple* data."]
import app
return "CLEANING AND TOKENIZATION :-", app.clean_and_tokenizing(dirty_sen)
#Class for Removing the stopwords
#if we write - http://localhost:8080/stop - stopwords removal is performed
class stopwords:
def GET(self):
sent = [" i am working on very simple project but i am learning a lot"]
import app
return "STOPWORDS REMOVAL:-", app.stopwords_removal(sent)
#Class for Performing Stemming
#if we write - http://localhost:8080/stem - stemming is performed
class stemming:
def GET(self):
example_words = ["python","pythoner","pythoning","pythoned","pythonly"]
import app
return "STEMMING:-" , app.stemmingfunc(example_words)
#Class for performing spell correction
#if we write - http://localhost:8080/spell - spell correction is performed
class spellcorrector:
def GET(self):
import spellcorrector2
return "SPELL CORRECTOR:-" , spellcorrector2.correct('hte'),spellcorrector2.correct('heatlh'),spellcorrector2.known(spellcorrector2.edits1('hav')),spellcorrector2.known_edits2('an'),spellcorrector2.Prob('health'),spellcorrector2.Prob('policy')
#Running the Application
if __name__ == "__main__":
app.run()