激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - 用Python代碼自動生成文獻的IEEE引用格式的實現

用Python代碼自動生成文獻的IEEE引用格式的實現

2021-09-27 00:35白水baishui Python

這篇文章主要介紹了用Python代碼自動生成文獻的IEEE引用格式的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

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

先看代碼,如下:

import re

def getIeeeJournalFormat(bibInfo):
  """
  生成期刊文獻的IEEE引用格式:{作者}, "{文章標題}," {期刊名稱}, vol. {卷數}, no. {編號}, pp. {頁碼}, {年份}.
  :return: {author}, "{title}," {journal}, vol. {volume}, no. {number}, pp. {pages}, {year}.
  """
  # 避免字典出現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):
  """
  本函數用于根據文獻類型調用相應函數來輸出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])

  # 創建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: # 如果輸入空行,則說明引用內容已經輸入完畢
      break
    else:
      bibtex.append(lines)
    i += 1
  return inforDir("".join(bibtex))

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

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

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

用Python代碼自動生成文獻的IEEE引用格式的實現

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

用Python代碼自動生成文獻的IEEE引用格式的實現

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

用Python代碼自動生成文獻的IEEE引用格式的實現

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

用Python代碼自動生成文獻的IEEE引用格式的實現

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

用Python代碼自動生成文獻的IEEE引用格式的實現

之后點擊兩下回車,即可得到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引用格式的實現的文章就介紹到這了,更多相關Python自動生成IEEE格式內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://blog.csdn.net/baishuiniyaonulia/article/details/114026471

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美性生活xxxxx | 久久精品a一级国产免视看成人 | 国产一级淫片在线观看 | 嗯~啊~弄嗯~啊h高潮视频 | 99精品视频一区二区三区 | 毛片中文字幕 | 国产精品一区二区三区在线看 | 久久一区二区三区av | 一二区成人影院电影网 | 欧美中文字幕一区二区三区亚洲 | 国产一区网址 | 国产精品www| 欧美a黄| 性爱免费视频 | 一级片九九 | 99日韩精品视频 | 高清国产福利 | 伦理三区| 国产精品成人免费一区久久羞羞 | 天天看逼 | 日韩视频在线一区二区三区 | 久久久成人精品视频 | 一区二区三区欧美精品 | 亚洲成人福利 | 亚洲精品免费播放 | 精品在线视频播放 | 一本色道久久综合狠狠躁篇适合什么人看 | 蜜桃网站在线观看 | 亚洲一区二区网址 | 国产精品午夜未成人免费观看 | 久久久精品99 | 99亚洲 | 成人免费电影在线观看 | 欧美四级在线观看 | 免费永久看羞羞片网站入口 | 成人福利网| 超碰一区 | 久久久久久久国产a∨ | 国产精品99久久久久久久 | 护士hd欧美free性xxxx | 在线观看国产一区二区 |