最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

用Python代碼自動生成文獻的IEEE引用格式的實現(xiàn)

 更新時間:2021年03月25日 09:38:40   作者:白水baishui  
這篇文章主要介紹了用Python代碼自動生成文獻的IEEE引用格式的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

今天嘗試著將引用文獻的格式按照IEEE的標準重新排版,感覺手動一條一條改太麻煩,而且很容易出錯,所以嘗試著用Python寫了一個小程序用于根據(jù)BibTeX引用格式來生成IEEE引用格式。

先看代碼,如下:

import re

def getIeeeJournalFormat(bibInfo):
  """
  生成期刊文獻的IEEE引用格式:{作者}, "{文章標題}," {期刊名稱}, vol. {卷數(shù)}, no. {編號}, pp. {頁碼}, {年份}.
  :return: {author}, "{title}," {journal}, vol. {volume}, no. {number}, pp. {pages}, {year}.
  """
  # 避免字典出現(xiàn)null值
  if "volume" not in bibInfo:
    bibInfo["volume"] = "null"
  if "number" not in bibInfo:
    bibInfo["number"] = "null"
  if "pages" not in bibInfo:
    bibInfo["pages"] = "null"

  journalFormat = bibInfo["author"] + \
      ", \"" + bibInfo["title"] + \
      ",\" " + bibInfo["journal"] + \
      ", vol. " + bibInfo["volume"] + \
      ", no. " + bibInfo["number"] + \
      ", pp. " + bibInfo["pages"] + \
      ", " + bibInfo["year"] + "."

  # 對格式進行調整,去掉沒有的信息,調整頁碼格式
  journalFormatNormal = journalFormat.replace(", vol. null", "")
  journalFormatNormal = journalFormatNormal.replace(", no. null", "")
  journalFormatNormal = journalFormatNormal.replace(", pp. null", "")
  journalFormatNormal = journalFormatNormal.replace("--", "-")
  return journalFormatNormal

def getIeeeConferenceFormat(bibInfo):
  """
  生成會議文獻的IEEE引用格式:{作者}, "{文章標題}, " in {會議名稱}, {年份}, pp. {頁碼}.
  :return: {author}, "{title}, " in {booktitle}, {year}, pp. {pages}.
  """
  conferenceFormat = bibInfo["author"] + \
          ", \"" + bibInfo["title"] + ",\" " + \
          ", in " + bibInfo["booktitle"] + \
          ", " + bibInfo["year"] + \
          ", pp. " + bibInfo["pages"] + "."

  # 對格式進行調整,,調整頁碼格式
  conferenceFormatNormal = conferenceFormat.replace("--", "-")
  return conferenceFormatNormal

def getIeeeFormat(bibInfo):
  """
  本函數(shù)用于根據(jù)文獻類型調用相應函數(shù)來輸出ieee文獻引用格式
  :param bibInfo: 提取出的BibTeX引用信息
  :return: ieee引用格式
  """
  if "journal" in bibInfo: # 期刊論文
    return getIeeeJournalFormat(bibInfo)
  elif "booktitle" in bibInfo: # 會議論文
    return getIeeeConferenceFormat(bibInfo)

def inforDir(bibtex):
  #pattern = "[\w]+={[^{}]+}"  用正則表達式匹配符合 ...={...} 的字符串
  pattern1 = "[\w]+=" # 用正則表達式匹配符合 ...= 的字符串
  pattern2 = "{[^{}]+}" # 用正則表達式匹配符合 內層{...} 的字符串

  # 找到所有的...=,并去除=號
  result1 = re.findall(pattern1, bibtex)
  for index in range(len(result1)) :
    result1[index] = re.sub('=', '', result1[index])
  # 找到所有的{...},并去除{和}號
  result2 = re.findall(pattern2, bibtex)
  for index in range(len(result2)) :
    result2[index] = re.sub('\{', '', result2[index])
    result2[index] = re.sub('\}', '', result2[index])

  # 創(chuàng)建BibTeX引用字典,歸檔所有有效信息
  infordir = {}
  for index in range(len(result1)):
    infordir[result1[index]] = result2[index]
  return infordir

def inputBibTex():
  """
  在這里輸入BibTeX格式的文獻引用信息
  :return:提取出的BibTeX引用信息
  """
  bibtex = []
  print("請輸入BibTeX格式的文獻引用:")
  i = 0
  while i < 15: # 觀察可知BibTeX格式的文獻引用不會多于15行
    lines = input()
    if len(lines) == 0: # 如果輸入空行,則說明引用內容已經(jīng)輸入完畢
      break
    else:
      bibtex.append(lines)
    i += 1
  return inforDir("".join(bibtex))

if __name__ == '__main__':
  bibInfo = inputBibTex() # 獲得BibTeX格式的文獻引用
  print(getIeeeFormat(bibInfo)) # 輸出ieee格式

下面我來詳細說說這個代碼怎么使用。

首先,我們需要獲取到文獻的BibTeX引用格式,可以在百度學術,或者谷歌學術的應用欄中找到,例如這里以谷歌學術舉例:

在這里插入圖片描述

在搜索框搜索論文:Reinforcement learning to rank in e-commerce search engine: Formalization, analysis, and application,跳轉到以下頁面:

在這里插入圖片描述

點擊“引用”,再點擊“BibTex”

在這里插入圖片描述

跳轉到以下頁面,復制所有字符串

在這里插入圖片描述

運行我們上面給出的代碼,在交互窗口把我們復制的字符串粘貼過去:

在這里插入圖片描述

之后點擊兩下回車,即可得到IEEE格式的文獻引用了:

這里我分了會議論文和期刊論文種格式,大家如果想要其他引用格式,可以在我的代碼的基礎上進行增刪改,下面我放一些引用格式轉換的例子:

會議論文1:

Reinforcement learning to rank in e-commerce search engine: Formalization, analysis, and application

BibTeX格式:

@inproceedings{hu2018reinforcement,
title={Reinforcement learning to rank in e-commerce search engine: Formalization, analysis, and application},
author={Hu, Yujing and Da, Qing and Zeng, Anxiang and Yu, Yang and Xu, Yinghui},
booktitle={Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining},
pages={368–377},
year={2018}
}

IEEE格式:

Hu, Yujing and Da, Qing and Zeng, Anxiang and Yu, Yang and Xu, Yinghui, “Reinforcement learning to rank in e-commerce search engine: Formalization, analysis, and application,” , in Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, 2018, pp. 368-377.

會議論文2:

A contextual-bandit approach to personalized news article recommendation

BibTeX格式:

@inproceedings{li2010contextual,
title={A contextual-bandit approach to personalized news article recommendation},
author={Li, Lihong and Chu, Wei and Langford, John and Schapire, Robert E},
booktitle={Proceedings of the 19th international conference on World wide web},
pages={661–670},
year={2010}
}

IEEE格式:

Li, Lihong and Chu, Wei and Langford, John and Schapire, Robert E, “A contextual-bandit approach to personalized news article recommendation,” , in Proceedings of the 19th international conference on World wide web, 2010, pp. 661-670.

期刊論文1:

Infrared navigation-Part I: An assessment of feasibility

BibTeX格式:

@article{duncombe1959infrared,
title={Infrared navigation—Part I: An assessment of feasibility},
author={Duncombe, JU},
journal={IEEE Trans. Electron Devices},
volume={11},
number={1},
pages={34–39},
year={1959}
}

IEEE格式:

Duncombe, JU, “Infrared navigation—Part I: An assessment of feasibility,” IEEE Trans. Electron Devices, vol. 11, no. 1, pp. 34-39, 1959.

期刊論文2(arXiv):

Reinforcement learning for slate-based recommender systems: A tractable decomposition and practical methodology

BibTeX格式:

@article{ie2019reinforcement,
title={Reinforcement learning for slate-based recommender systems: A tractable decomposition and practical methodology},
author={Ie, Eugene and Jain, Vihan and Wang, Jing and Narvekar, Sanmit and Agarwal, Ritesh and Wu, Rui and Cheng, Heng-Tze and Lustman, Morgane and Gatto, Vince and Covington, Paul and others},
journal={arXiv preprint arXiv:1905.12767},
year={2019}
}

IEEE格式:

Ie, Eugene and Jain, Vihan and Wang, Jing and Narvekar, Sanmit and Agarwal, Ritesh and Wu, Rui and Cheng, Heng-Tze and Lustman, Morgane and Gatto, Vince and Covington, Paul and others, “Reinforcement learning for slate-based recommender systems: A tractable decomposition and practical methodology,” arXiv preprint arXiv:1905.12767, 2019.

到此這篇關于用Python代碼自動生成文獻的IEEE引用格式的實現(xiàn)的文章就介紹到這了,更多相關Python自動生成IEEE格式內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Python OpenCV學習之圖像形態(tài)學

    Python OpenCV學習之圖像形態(tài)學

    形態(tài)學處理方法是基于對二進制圖像進行處理的,卷積核決定圖像處理后的效果。本文將為大家詳細介紹一下OpenCV中的圖像形態(tài)學,感興趣的可以了解一下
    2022-01-01
  • python3.x+pyqt5實現(xiàn)主窗口狀態(tài)欄里(嵌入)顯示進度條功能

    python3.x+pyqt5實現(xiàn)主窗口狀態(tài)欄里(嵌入)顯示進度條功能

    這篇文章主要介紹了python3.x+pyqt5實現(xiàn)主窗口狀態(tài)欄里(嵌入)顯示進度條功能,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-07-07
  • Python使用re模塊驗證危險字符

    Python使用re模塊驗證危險字符

    這篇文章主要介紹了如何基于python驗證危險字符,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-05-05
  • python實現(xiàn)數(shù)據(jù)可視化超詳細講解

    python實現(xiàn)數(shù)據(jù)可視化超詳細講解

    Python的數(shù)據(jù)可視化是將數(shù)據(jù)以圖形或圖表的形式呈現(xiàn),使復雜的信息更易于理解和分析,本文給大家詳細介紹了python數(shù)據(jù)可視化的實現(xiàn),文中通過圖文結合的方式介紹的非常詳細,需要的朋友可以參考下
    2024-06-06
  • 安裝python及pycharm的教程圖解

    安裝python及pycharm的教程圖解

    本文通過圖文并茂的形式給大家介紹了安裝python及pycharm的方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-10-10
  • Python自制圖像批量壓縮工具

    Python自制圖像批量壓縮工具

    這篇文章主要為大家詳細介紹了如何使用Python自制一個圖像批量壓縮工具,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2024-04-04
  • 簡單介紹利用TK在Python下進行GUI編程的教程

    簡單介紹利用TK在Python下進行GUI編程的教程

    這篇文章主要介紹了簡單介紹利用TK在Python下進行GUI編程的教程,本文來自于IBM官方開發(fā)者技術文檔,需要的朋友可以參考下
    2015-04-04
  • python裝飾器代碼深入講解

    python裝飾器代碼深入講解

    這篇文章主要介紹了python裝飾器代碼深入講解,文章使用代碼講解了pythone裝飾器的用法,有感興趣的同學可以學習下
    2021-03-03
  • Python類方法__init__和__del__構造、析構過程分析

    Python類方法__init__和__del__構造、析構過程分析

    這篇文章主要介紹了Python類方法__init__和__del__構造、析構過程分析,本文分析了什么時候構造、什么時候析構、成員變量如何處理、Python中的共享成員函數(shù)如何訪問等問題,需要的朋友可以參考下
    2015-03-03
  • Python開發(fā)的HTTP庫requests詳解

    Python開發(fā)的HTTP庫requests詳解

    Requests是用Python語言編寫,基于urllib,采用Apache2 Licensed開源協(xié)議的HTTP庫。它比urllib更加方便,可以節(jié)約我們大量的工作,完全滿足HTTP測試需求。Requests的哲學是以PEP 20 的習語為中心開發(fā)的,所以它比urllib更加Pythoner。更重要的一點是它支持Python3哦!
    2017-08-08

最新評論

岳池县| 邵阳县| 彭泽县| 营山县| 涞源县| 连江县| 镇赉县| 宝山区| 内黄县| 南乐县| 镇坪县| 德惠市| 鄂伦春自治旗| 大化| 罗江县| 清水河县| 临城县| 大冶市| 金川县| 上犹县| 师宗县| 太保市| 黑山县| 那坡县| 郑州市| 凉城县| 额尔古纳市| 舒兰市| 江山市| 遵化市| 太原市| 军事| 兴国县| 寿光市| 兰溪市| 策勒县| 成都市| 封开县| 大英县| 西青区| 贵阳市|