Python库-出版物引用拆分

Python库-出版物引用拆分,python,citations,biblatex,Python,Citations,Biblatex,我有一堆引用字符串,我想把它们分割成一个引用。下面是我在OWL引文网站上找到的一个例子。我有MLA、APA等引文类型的组合。是否有python库或其他应用程序可以将这些字符串拆分为列表中的元素。由于引用类型的多样性,我尝试避免使用正则表达式,并且我还尝试使用“/n”进行拆分,但是,我的一些字符串没有“/n”分隔符……因此您可以看到这个问题。我想知道是否有更好的捕获方法。我不寻找捕获的名称,日期,标题…找到一个库,这样做…我只需要字符串分开。任何帮助都将不胜感激!!!!谢谢 输入字符串-示例 De

我有一堆引用字符串,我想把它们分割成一个引用。下面是我在OWL引文网站上找到的一个例子。我有MLA、APA等引文类型的组合。是否有python库或其他应用程序可以将这些字符串拆分为列表中的元素。由于引用类型的多样性,我尝试避免使用正则表达式,并且我还尝试使用“/n”进行拆分,但是,我的一些字符串没有“/n”分隔符……因此您可以看到这个问题。我想知道是否有更好的捕获方法。我不寻找捕获的名称,日期,标题…找到一个库,这样做…我只需要字符串分开。任何帮助都将不胜感激!!!!谢谢

输入字符串-示例

Dean, Cornelia. "Executive on a Mission: Saving the Planet." The New York Times, 22 May 2007, www.nytimes.com/2007/05/22/science/earth/22ander.html?_r=0. Accessed 12 May 2016.

Ebert, Roger. Review of An Inconvenient Truth, directed by Davis Guggenheim. rogerebert.com, 1 June 2006, www.rogerebert.com/reviews/an-inconvenient-truth-2006. Accessed 15 June 2016.
['Dean, Cornelia. "Executive on a Mission: Saving the Planet." The New York Times, 22 May 2007, www.nytimes.com/2007/05/22/science/earth/22ander.html?_r=0. Accessed 12 May 2016.',
'Ebert, Roger. Review of An Inconvenient Truth, directed by Davis Guggenheim. rogerebert.com, 1 June 2006, www.rogerebert.com/reviews/an-inconvenient-truth-2006. Accessed 15 June 2016.']
输出-样本

Dean, Cornelia. "Executive on a Mission: Saving the Planet." The New York Times, 22 May 2007, www.nytimes.com/2007/05/22/science/earth/22ander.html?_r=0. Accessed 12 May 2016.

Ebert, Roger. Review of An Inconvenient Truth, directed by Davis Guggenheim. rogerebert.com, 1 June 2006, www.rogerebert.com/reviews/an-inconvenient-truth-2006. Accessed 15 June 2016.
['Dean, Cornelia. "Executive on a Mission: Saving the Planet." The New York Times, 22 May 2007, www.nytimes.com/2007/05/22/science/earth/22ander.html?_r=0. Accessed 12 May 2016.',
'Ebert, Roger. Review of An Inconvenient Truth, directed by Davis Guggenheim. rogerebert.com, 1 June 2006, www.rogerebert.com/reviews/an-inconvenient-truth-2006. Accessed 15 June 2016.']

尝试
拆分
,然后使用
过滤器删除空元素

string = '''Dean, Cornelia. "Executive on a Mission: Saving the Planet." The New York Times, 22 May 2007, www.nytimes.com/2007/05/22/science/earth/22ander.html?_r=0. Accessed 12 May 2016.

Ebert, Roger. Review of An Inconvenient Truth, directed by Davis Guggenheim. rogerebert.com, 1 June 2006, www.rogerebert.com/reviews/an-inconvenient-truth-2006. Accessed 15 June 2016.'''

result = list(filter(None, string.split('\n')))
输出:

['Dean, Cornelia. "Executive on a Mission: Saving the Planet." The New York Times, 22 May 2007, www.nytimes.com/2007/05/22/science/earth/22ander.html?_r=0. Accessed 12 May 2016.', 'Ebert, Roger. Review of An Inconvenient Truth, directed by Davis Guggenheim. rogerebert.com, 1 June 2006, www.rogerebert.com/reviews/an-inconvenient-truth-2006. Accessed 15 June 2016.']

如果要使用换行符分隔字符串
s
\n
可以使用带有listcomp的字符串方法
splitlines()
来过滤空元素:

[i for i in s.splitlines() if i]