File size: 1,231 Bytes
21baa2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
'''
Created on ١٠‏/٠٣‏/٢٠١٠

@Created by: Muhammad Altabba
'''

from .Word import *

class Sentence(object):
    """
     # PyUML: Do not remove this line! # XMI_ID:_qyYg4Y35Ed-gg8GOK1TmhA
    """
    '''
    Text Sentence
    '''
    OriginalString = "";
    
    # List of instances of the Word class:
    Words = [];

    def __init__(self, string):
        '''
        Constructor
        '''
        self.OriginalString = string;
        self.Words = [];
        
    def Tokenize(self):        
        i = 0;
        while i < len(self.OriginalString):
            nextIndex = len(self.OriginalString);
            dotIndex = self.OriginalString.find(' ', i);
            if nextIndex > dotIndex and dotIndex != -1:
                nextIndex = dotIndex;
            word = Word(self.OriginalString[i:nextIndex])
            word.TokenType = TokenType();
            self.Words.append(word);
            i += nextIndex - i + 1
        pass
        
    def __str__(self):
        str = 'Sentence:';
        str += '\tOriginal String:' + self.OriginalString;
        str += '\n\tWords:';
        str += '\n';
        for i in range(len(self.Words)):
            str += self.Words[i].__str__();
        return str;