Я пытаюсь проанализировать комментарии Javadoc. Мне не нужно содержимое тега @link
. Как я могу удалить это?
Общий формат {@link.........}
С этим кодом ниже я получаю ошибку: ValueError: unexpected '{' in field name
with open("comments.txt", 'r') as f:
for line in f:
remove_link_tag = re.sub('{@link(.*?)}', lambda m: "
{@link{}}>".format(
m.group(1).replace(".", "").replace(",",
"").replace(";", "")), line, flags=re.DOTALL)
ВХОД:
/**
* Adds the specified source and target vertices to the graph, if not already included, and
* creates a new edge and adds it to the specified graph similarly to the
* {@link Graph#addEdge(Object, Object)} method.
* {@code sourceVertex}
* @param graph the graph for which the specified edge to be added
* @param sourceVertex source vertex of the edge
* @param targetVertex target vertex of the edge
* @param <V> the graph vertex type
* @param <E> the graph edge type
*
* @return The newly created edge if added to the graph, otherwise <code>
* null</code>.
*/
OUTPUT
/**
* Adds the specified source and target vertices to the graph, if not already included, and
* creates a new edge and adds it to the specified graph similarly to the
* method.
*
* {@code sourceVertex}
* @param graph the graph for which the specified edge to be added
* @param sourceVertex source vertex of the edge
* @param targetVertex target vertex of the edge
* @param <V> the graph vertex type
* @param <E> the graph edge type
*
* @return The newly created edge if added to the graph, otherwise <code>
* null</code>.
*/