예제 #1
0
 def testFindLiterals(self):
     textTags = hrefliterals.extractTextInfo(
             self.document, self.exclude_re, '')
     literals = {'word':None, 'W.O.R.D.2.':None}
     literalTags = hrefliterals.findLiterals(
             textTags['f'], literals, {}, self.words, self.stemmer, 0)
     self.assertEqual(len(literalTags), 3)
     self.assertEqual(literalTags[0], hrefliterals.TextTag(
                 hrefliterals.TextTag.Type.LITERAL, 29, 34, 'word'))
     self.assertEqual(literalTags[1], hrefliterals.TextTag(
                 hrefliterals.TextTag.Type.LITERAL, 37, 42, 'W.O.R.D.2.'))
     self.assertEqual(literalTags[2], hrefliterals.TextTag(
                 hrefliterals.TextTag.Type.LITERAL, 43, 72, 'word'))
예제 #2
0
 def testReplaceTags(self):
     textTags = hrefliterals.extractTextInfo(
             self.document, self.exclude_re, '')
     literals = {'word':None, 'W.O.R.D.2.':None}
     literalTags = hrefliterals.findLiterals(
             textTags['f'], literals, {}, self.words, self.stemmer, 0)
     literalTags[0].value = '*'
     literalTags[1].value = '**'
     literalTags[2].value = '***'
     replaced = hrefliterals.replaceLiterals(self.source, literalTags)
     rsource = r"""
         \begin{document}* 1 ** ***
             \begin{equation}word\end{equation}
         \end{document}
     """
     self.assertEqual(replaced, rsource)
예제 #3
0
 def testReplaceTags(self):
     textTags = hrefliterals.extractTextInfo(self.document, self.exclude_re,
                                             '')
     literals = {'word': None, 'W.O.R.D.2.': None}
     literalTags = hrefliterals.findLiterals(textTags['f'], literals, {},
                                             self.words, self.stemmer, 0)
     literalTags[0].value = '*'
     literalTags[1].value = '**'
     literalTags[2].value = '***'
     replaced = hrefliterals.replaceLiterals(self.source, literalTags)
     rsource = r"""
         \begin{document}* 1 ** ***
             \begin{equation}word\end{equation}
         \end{document}
     """
     self.assertEqual(replaced, rsource)
예제 #4
0
 def testFindLiterals(self):
     textTags = hrefliterals.extractTextInfo(self.document, self.exclude_re,
                                             '')
     literals = {'word': None, 'W.O.R.D.2.': None}
     literalTags = hrefliterals.findLiterals(textTags['f'], literals, {},
                                             self.words, self.stemmer, 0)
     self.assertEqual(len(literalTags), 3)
     self.assertEqual(
         literalTags[0],
         hrefliterals.TextTag(hrefliterals.TextTag.Type.LITERAL, 29, 34,
                              'word'))
     self.assertEqual(
         literalTags[1],
         hrefliterals.TextTag(hrefliterals.TextTag.Type.LITERAL, 37, 42,
                              'W.O.R.D.2.'))
     self.assertEqual(
         literalTags[2],
         hrefliterals.TextTag(hrefliterals.TextTag.Type.LITERAL, 43, 72,
                              'word'))
예제 #5
0
 def findLiterals(self, source, literals, notLiterals):
     document = hrefliterals.parseDocument('f', StringIO.StringIO(source),
                                             os.getcwd())
     textTags = hrefliterals.extractTextInfo(document, self.exclude_re, '')
     return hrefliterals.findLiterals(textTags['f'], literals, notLiterals,
                                             self.words, self.stemmer, 0)
예제 #6
0
 def findLiterals(self, source, literals, notLiterals):
     document = hrefliterals.parseDocument('f', StringIO.StringIO(source),
                                           os.getcwd())
     textTags = hrefliterals.extractTextInfo(document, self.exclude_re, '')
     return hrefliterals.findLiterals(textTags['f'], literals, notLiterals,
                                      self.words, self.stemmer, 0)