def test_phonetizeFR(self): dictdir = os.path.join(SPPAS, "resources", "dict") dictfile = os.path.join(dictdir, "fra.dict") dd = DictPron(dictfile) grph = DictPhon(dd) result = grph.phonetize('pas_encore', phonunk=False) self.assertEqual(result, 'UNK') result = grph.phonetize('pas_encore', phonunk=True) self.assertEqual(result, "p.a.a~.k.o.r|p.a.z.a~.k.o.r|p.a.a~.k.o.r.eu|p.a.z.a~.k.o.r.eu") result = grph.phonetize(u'/lemot/', phonunk=True) self.assertEqual(result, u"lemot") result = grph.phonetize(u'/lemot/', phonunk=False) self.assertEqual(result, u"lemot")
if not args.quiet: setup_logging(1,None) # ---------------------------------------------------------------------------- # Automatic Phonetization is here: # ---------------------------------------------------------------------------- unkopt = True if args.nounk: unkopt = False mapfile = None if args.map: mapfile = args.map if args.i: p = sppasPhon( args.dict, mapfile ) p.set_unk( unkopt ) p.set_usestdtokens( False ) p.run( args.i,args.o ) else: pdict = DictPron( args.dict, unkstamp=UNKSTAMP, nodump=False ) maptable = Mapping() if mapfile is not None: maptable = Mapping( mapfile ) phonetizer = DictPhon( pdict, maptable ) for line in sys.stdin: print phonetizer.phonetize( line, unkopt ) # ----------------------------------------------------------------------------