コード例 #1
0
ファイル: langsci_tests.py プロジェクト: langsci/216
 def test_dediacriticize(self):
     """ Test an isolated string
     """
     result = delatex.dediacriticize(r"Bád\'ag\'{a}p{\'{a}}")
     self.assertEqual(result, "Bádagapa")
     
     
     result = delatex.dediacriticize(r"Bád\'ag\'{a}p{\'{a}}", stripbraces=False)
     self.assertEqual(result, "Bádagap{a}")
     
     result = delatex.dediacriticize(r"""\'{a}\`{a}\^{a}\~{a}\"{a}\={a}\.{a}\d{a}\v{a}\H{a}\u{a}\k{a}""")
     self.assertEqual(result, "aaaaaaaaaaaa")
コード例 #2
0
ファイル: bibtools.py プロジェクト: langsci/225
 def addsortname(self,name):
   """
   add an additional field for sorting for names with diacritics
   """
   
   try:
       residue = name.translate({ord(i):None for i in string.ascii_letters+'- ,{}.'})
   except  TypeError: #python2
       residue = ''  
   if residue == '':
     pass
   else:
     self.fields['sortname']= asciify(dediacriticize(name))