-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdispatcher.py
77 lines (64 loc) · 1.77 KB
/
dispatcher.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
"""
Dispatcher function for the separation of the words.
Receive keywords (one line string in witch words
are separated using simple comma) from the database
as parameters and return each keyword separately
"""
#use cerberus for form validation
__title__ = 'dispatcher'
__version__ = '0.0.1a'
__author__ = 'Amédée DERA'
__license__ = 'MIT'
import os
class Dispatcher(object):
def __init__(self, data=0):
self.data = data
def setdata(self, data):
self.data = data
Test = Dispatcher()
Test2 = Dispatcher()
# Test.setdata (['working', 'eating', 'sliping', 'enjoying', 'life'])
Test.setdata (['working, eating, sliping, enjoying, life'])
Test2.setdata ('working, eating, sliping, enjoying, life')
"""
A faire
compter le nombre d'items et ne garder que les 3 premiers, puis rajouter endoffile de
sorte à avoir un point de fin de lecture bien connue.
compter les redondances et supprimer les copies
"""
def parserLine(line):
i = 0
x = line.data
a,b = len(x), len(x)
if b == 3:
return True
a:a = 'endoffile' #make sure the last item is known (for better parsing)
k = x.split(",")
print(k)
parserLine(Test2)
def parserList(list):
i = 0
x = list.data
a,b = len(x), len(x)
if b == 3:
return True
a:a = 'endoffile' #make sure the last item is known (for better parsing)
#x *=
for t in x:
print(x[i])
#.cpaitalize(), upper(), lower()
i += 1
print(b)
parserList(Test)
"""def tokenize(chaine):
ponc = [' ','.',',','!','?',';',':']
mot=""
for char in chaine:
if char in ponc:
print(mot)
print(char)
mot=""
else:
mot = mot + char
print (tokenize("il marche, elle marche."))
"""