2
text = "Trondheim is a small city with a university and 140000 inhabitants. Its central bus systems has 42 bus lines, serving 590 stations, with 1900 (departures per) day in average. T h a t gives approximately 60000 scheduled bus station passings per day, which is somehow represented in the route data base. The starting point is to automate the function (Garry Weber, 2005) of a route information agent."
print re.findall(r"([^.]*?\(.+ [0-9]+\)[^.]*\.)",text)
私は上記のコードを使用して、文章を引用して抽出しています。あなたが見ることができるように、最後の文には引用が含まれています(Garry Weber、2005)。Python - 引用符を含む文章を抽出するには?
しかし、私はこの結果を得ました: [中央バスシステムには42のバスラインがあり、590ステーションを提供しています(平均1900出発日)。 T h a tは、約60000の予定されたバスステーション通過を1日に与えるが、これは何らかの形でルートデータベースに表される。
結果は、次のような引用のみを含む文でなければなりません: 出発点は、機能を自動化することです( Garry Weber、2005)に経路情報エージェントを追加した。
問題は、かっこ内のテキストによって発生していると思います。第2行には、そのコードが含まれています(出発順)。
ここで '\(。+')の代わりに '\([^)] +'を使用することができます。 –
ああ私の問題 – Ivan