Я пытаюсь проанализировать комментарии Javadoc в python, и для этого мне нужны полные остановки для расщепления.Как добавить полные остановки в нужных местах в комментарии Javadoc?
Я хочу что-то вроде этого: Ввод:
/**
* The addVertex method checks to see if the vertex isn't null, and then if
* the graph does not contain the vertex, the vertex is then added and true
* is returned
*
* @param vertex
*
* @throws NullPointerException.
*
* @return b
*/
Вывод:
/**
* The addVertex method checks to see if the vertex isn't null, and then if
* the graph does not contain the vertex, the vertex is then added and true
* is returned.*here*
*
* @param vertex.*here*
*
* @throws NullPointerException.*here*
*
* @return b.*here*
*/
Примечание. Если точка / точка с запятой / запятая уже существует, замена выполняетсяне требуется, так как моя программа разделяется на основе этих 3 знаков препинания.
Кроме того, описания Javadoc могут иметь встроенные теги, такие как {@link ...}, знаки препинания не требуются.
Только до того, как потребуется @param, @throw, @return (также в конце).
РЕШЕНИЕ
test_str = ("/**\n"
" * The addVertex method checks to see if the vertex isn't null, and then if\n"
" * the graph does not contain the vertex, the vertex is then added and true\n"
" * is returned\n"
" *\n"
" * @param vertex\n"
" *\n"
" * @throws NullPointerException.\n"
" *\n"
" * @return b\n"
" */")
result = re.sub(r'(@param|@throw|@return)', r'.\1', test_str)
print(result)
Это добавляетполная остановка в необходимых местах, кроме последнего тега, не проблема для расщепления!