• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            sunrise

            每天不斷學習,才能不斷提升自己。

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              64 隨筆 :: 0 文章 :: 92 評論 :: 0 Trackbacks
            話不多說,奉上代碼。

            #/usr/bin/env python
            #
            coding=utf8

            #對提取的數據進行預處理

            def pretreat(infile,outfile):
              rfile = open(infile,'r')
              wfile = open(outfile,'wa+')
              while(1):
                line = rfile.readline()
                if not line:
                  break
                line = line.split('>')

                #數據的長度,避免重復計算
                lens = len(line)

                #獲得有效信息
                for i in range(lens):
                  line[i] = line[i].split('/')
                for i in range(lens):
                  #處理三元組第三個元素
                  #print line[i]
                  flag = 0
                  if '@zh' in line[i][0]:
                    line[i][0] = line[i][0].replace('@zh .','')
                    line[i][0] = line[i][0].replace('','')
                  if '^^<http:' in line[i][0]:
                    flag = 1
                    line[i][0] = line[i][0].replace('^^<http:','')
                    line[i][0] = line[i][0].replace('','')
                    print line[i][0]
                    wfile.write(line[i][0].strip())
                  if len(line[i]) >= 1 and i != 3 and 0 == flag:
                    if '' in line[i][len(line[i])-1]:
                      line[i][len(line[i])-1] = line[i][len(line[i])-1].replace('','')
                    wfile.write(line[i][len(line[i])-1].strip()+' ')
                wfile.write('\n')
              wfile.close()

            #判斷是否含有字母
            def is_alphabet(input):
              input = unicode(input,"utf-8")
              buf = []
              for uchar in input:
                if (uchar >= u'\u0041' and uchar<=u'\u005a'or (uchar >= u'\u0061' and uchar<=u'\u007a'):
                  return True
                else:
                  return False

              #去除國家名中含有字母的三元組
            def removealp(infile,outfile):
              rfile = open(infile,'r')
              wfile = open(outfile,'w')
              while(1):
                line = rfile.readline()
                if not line:
                  break
                linetmp = line
                line = line.split(' ')
                if False == is_alphabet(line[0]):
                  wfile.write(linetmp)
              wfile.close()


            pretreat('article_categories_en_uris_zh.nt','tag_article_categories_en_uris_zh.txt')
            posted on 2012-09-13 17:29 SunRise_at 閱讀(1420) 評論(0)  編輯 收藏 引用 所屬分類: 可愛的python
            久久99国产综合精品| 99久久国产免费福利| 色妞色综合久久夜夜| 久久这里只有精品18| 久久综合九色综合久99| 久久精品无码一区二区app| 伊人久久无码中文字幕| 99久久国产亚洲高清观看2024| 久久亚洲精品成人无码网站 | 国产成人无码久久久精品一| 久久精品国产精品亚洲艾草网美妙 | 国产2021久久精品| 97视频久久久| 久久99热这里只有精品国产| 国产人久久人人人人爽| 久久婷婷色香五月综合激情| 66精品综合久久久久久久| 熟妇人妻久久中文字幕| 久久久久久精品免费免费自慰| 久久久青草久久久青草| 久久发布国产伦子伦精品 | 久久99热这里只有精品国产| 国产一区二区精品久久岳| 久久久久久久人妻无码中文字幕爆| 日本久久久久久久久久| 精品国产综合区久久久久久 | 波多野结衣中文字幕久久| 亚洲中文字幕久久精品无码APP | 少妇内射兰兰久久| 激情五月综合综合久久69| 久久91精品国产91久久麻豆| 性做久久久久久久| 久久婷婷成人综合色综合| 精品乱码久久久久久久| 久久99精品久久久久子伦| 久久久久亚洲AV无码网站| 色综合久久中文字幕无码 | 国产综合成人久久大片91| 国产一区二区精品久久凹凸| 日本加勒比久久精品| 中文字幕无码久久精品青草|