Ejemplo n.º 1
0
    def create_paragraph(self):
        current_paragraph = None
        if len(self.bookTokens) > 0 and self.structs.has_key("p"):
            current_paragraph = Token(
                id       = uuid4(),
                data     = u"\u2029", #¶ "\n\n"
                type     = Token.WHITESPACE, #i.e. PARAGRAPH
                work     = self.work1,
                position = self.tokenCount,
            )
            self.tokenCount += 1
            current_paragraph.save()
            self.structs["p"].end_marker = current_paragraph
            self.close_structure("p")            
            self.bookTokens.append(current_paragraph)

        assert(not self.structs.has_key("p"))
        print("¶")
        self.structs["p"] = Structure(
            work = self.work1,
            element = "p",
            position = self.structCount,
        )
        if current_paragraph:
            self.structs["p"].start_marker = current_paragraph
        self.structCount += 1
Ejemplo n.º 2
0
 def create_punct_token(self, punct_data):
     punc_token = Token(
         id       = uuid4(),
         data     = punct_data,
         type     = Token.PUNCTUATION,
         work     = self.work1,
         position = self.tokenCount,
     )
     self.tokenCount += 1
     punc_token.save()
     self.bookTokens.append(punc_token)
Ejemplo n.º 3
0
 def create_whitespace_token(self):
     ws_token = Token(
         id       = uuid4(),
         data     = " ",
         type     = Token.WHITESPACE,
         work     = self.work1,
         position = self.tokenCount,
         )
     self.tokenCount += 1
     ws_token.save()
     self.bookTokens.append(ws_token)
Ejemplo n.º 4
0
 def create_token(self, token_data):
     word_token = Token(
         id       = uuid4(),
         data     = token_data,
         type     = Token.WORD,
         work     = self.work1,
         position = self.tokenCount,
     )
     self.tokenCount += 1
     word_token.save()
     self.bookTokens.append(word_token)
Ejemplo n.º 5
0
    def create_uncertain(self):
        assert(not self.structs.has_key('doubted'))
        print("### OPEN BRACKET")
        
        open_bracket_token = Token(
            id       = uuid4(),
            data     = '[',
            type     = Token.PUNCTUATION,
            work     = self.work1,
            position = self.tokenCount
        )
        self.tokenCount += 1
        open_bracket_token.save()
        self.bookTokens.append(open_bracket_token)

        self.structs['doubted'] = Structure(
            work = self.work1,
            element = 'doubted',
            position = self.structCount,
            start_marker = open_bracket_token
            )
        self.structCount += 1