예제 #1
0
def print_pinyin_with_tone(name):
    converter = pinyin.Converter()
    converter.load_word_file('chars.txt')
    #	result = converter.convert(name)
    firstname_pool_withtone = converter.convert(name,
                                                fmt='tn',
                                                sc=False,
                                                pp=False)  #df,tn,fl
    return firstname_pool_withtone
예제 #2
0
def print_pinyin(name):
    converter = pinyin.Converter()
    converter.load_word_file('chars.txt')
    firstname_pool = converter.convert(name, fmt='fl', sc=False, pp=False)
    #fmt:df,tn,fl;
    #sc-False:no space,True:have space

    #	result = converter.convert(name)
    #	name_pool = result.split(" ")
    #	firstname_pool = map(lambda x:x[0],name_pool)
    return firstname_pool
예제 #3
0
def welcome():
    try:
        name = request.args.get('name', '')
        converter = pinyin.Converter()
        pinyin_name = converter.convert(name)
        pys = pinyin_name.split(' ')
        short_pinyin_name = pys[0]
        for py in pys[1:]:
            short_pinyin_name += py[0]
        welcome_string = u'%s同学好,大家好,</br>最近我们组迎来了%s同学,欢迎他们加入我们温暖的大家庭!</br>%s同学的组内邮箱为: %[email protected]<br>大家多联系,多关照。</br>如果有任何问题,请联系管理员程善伯[email protected]或朱长峰[email protected]。</br>另:组内为每位同学分配了一定资源,附件中为组内资源介绍。</br></br>祝好!</br></br>谢谢</br>善伯' % (
            name, name, name[1:], short_pinyin_name)
        return welcome_string
    except:
        return "welcome"
예제 #4
0
def fetch_stock_basic(request):
    result = dict()
    try:
        if fetch_info['is_fetching_basic']:
            result['code'] = '1'
        else:
            fetch_info['is_fetching_basic'] = True
            df = tushare.get_stock_basics()
            records = df.to_records()
            for record in records:
                code = record['code']
                ggid = stock_utils.gen_ggid(code)
                sj_gp_jb = SjGpJb.objects.get_or_create(ggid=ggid)[0]
                sj_gp_jb.dm = code
                sj_gp_jb.mc = record['name']
                py = pinyin.Converter().convert(record['name'], fmt='fl', sc=False)
                sj_gp_jb.py = str_utils.qj_to_bj(py.lower().replace(' ', ''))
                sj_gp_jb.sshy = record['industry']
                sj_gp_jb.dq = record['area']
                sj_gp_jb.syl = record['pe']
                sj_gp_jb.ltgb = record['outstanding']
                sj_gp_jb.zgb = record['totals']
                sj_gp_jb.zzc = record['totalAssets']
                sj_gp_jb.ldzc = record['liquidAssets']
                sj_gp_jb.gdzc = record['fixedAssets']
                sj_gp_jb.gjj = record['reserved']
                sj_gp_jb.mggj = record['reservedPerShare']
                sj_gp_jb.mgsy = record['esp']
                sj_gp_jb.mgjz = record['bvps']
                sj_gp_jb.sjl = record['pb']
                ssrq = record['timeToMarket']
                if ssrq > 0:
                    sj_gp_jb.ssrq = str_utils.to_timezone(str(ssrq), "%Y%m%d")
                sj_gp_jb.tbsj = timezone.now()
                sj_gp_jb.save()
                result['code'] = '0'
                fetch_info['is_fetching_basic'] = False
    except Exception as e:
        result['code'] = '-1'
        result['message'] = e.message
        fetch_info['is_fetching_basic'] = False
    return JsonResponse(result)
예제 #5
0
# -*- coding: utf-8 -*-
##############################################################################
from osv import osv, fields
from anjuke import pinyin

converter = pinyin.Converter()


def _PINYIN(hanzi):
    res = False
    if hanzi:
        res = converter.convert(hanzi)
    return res


class so_to_dst(osv.osv_memory):
    """
    dst :  direct.sell.template
    """
    _name = 'so.to.dst'
    _columns = {
        'name': fields.char('Name', size=32, ),
    }
    
    def create_dst(self, cr, uid, ids, context=None):
        so_pool = self.pool.get('sale.order')
        dst_pool = self.pool.get('direct.sell.template')
        so_ids = context.get('active_ids')
        
        dst_ids = []
        for so in so_pool.browse(cr, uid, so_ids, context=context):
예제 #6
0
파일: tests.py 프로젝트: rock999/pinyin4py
 def testConverterWithFile(self):
     converter = pinyin.Converter()
     converter.load_word_file(
         os.path.dirname(os.path.abspath(__file__)) + '/words.txt')
     print converter.convert('什么莘莘莘莘学子莘庄闵行区北翟路')
예제 #7
0
파일: tests.py 프로젝트: rock999/pinyin4py
 def testConverter(self):
     converter = pinyin.Converter()
     print converter.convert(u'123 1.中文测试1。', fmt='tn', sc=False, pp=True)
예제 #8
0
# -*- coding: utf-8 -*-
# standard libs
import urllib, urllib2, re, json
# custom libs
import requests
from anjuke import pinyin
from lxml.html import fromstring
next_page_str = u"\u4e0b\u4e00\u9875"
max_provid = 32
pinyin_c = pinyin.Converter()

YOUR_AVOS_APP_ID = ''
YOUR_AVOS_APP_KEY = ''


def parse_school_name(node):
    a_list = node.xpath('./a')
    n = node if len(a_list) == 0 else a_list[0]
    return n.text_content()


def parse_school_node(node):
    td_list = node.xpath('./td')
    name = parse_school_name(td_list[0])
    location = td_list[1].text_content()
    category = td_list[2].text_content()
    level = td_list[5].text_content()
    fl = pinyin_c.convert(name, fmt='fl', sc=False)
    fpy = pinyin_c.convert(name, sc=False)
    return {
        'name': name,