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)
Я использую приведенный выше код, чтобы извлечь предложение с цитатой в нем. Как видите, последнее предложение содержит цитату (Гарри Вебер, 2005).
Но я получил такой результат:
[' 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.']
В результате должно получиться предложение, содержащее только цитату, например:
Отправной точкой является автоматизация функции (Garry Weber, 2005) агента информации о маршруте.
Я предполагаю, что проблема вызвана текстом в круглых скобках, как вы можете видеть во второй строке, которую он содержит (отклонения на), любое решение для моего кода?
\(.+
вы можете использовать здесь\([^)]+
. - person Sebastian Proske   schedule 13.08.2017