arXiv:2409.14609cs.SEcs.IR2024-09

开源工具Nirjas可精准提取代码元数据并分类注释。

Nirjas: An open source framework for extracting metadata from the source code

  • 基于正则表达式,结构化提取代码注释与元数据
  • 支持多语言注释识别,准确分离代码与注释类型
  • 适合代码分析、合规审查及开源项目研究者使用

元数据和注释在软件开发中至关重要。本文介绍源代码中的元数据和注释如何帮助理解软件。我们提出一个基于Python的开源框架Nirjas,可结构化地提取这些信息。不同编程语言存在多种注释语法、类型和通用规范,边缘情况易引入噪声,Nirjas采用正则表达式实现高精度提取,相较非正则方法更准确且能有效分离噪声。该框架可区分不同类型注释、源代码,并提供行号、文件名、使用的编程语言、总代码行数(SLOC)等详细信息。Nirjas为独立的Python库,可通过源码或pip安装。其最初为谷歌夏季编码项目开发,现由FOSSology组织维护。

原文摘要 · Abstract (English)

Metadata and comments are critical elements of any software development process. In this paper, we explain how metadata and comments in source code can play an essential role in comprehending software. We introduce a Python-based open-source framework, Nirjas, which helps in extracting this metadata in a structured manner. Various syntaxes, types, and widely accepted conventions exist for adding comments in source files of different programming languages. Edge cases can create noise in extraction, for which we use Regex to accurately retrieve metadata. Non-Regex methods can give results but often miss accuracy and noise separation. Nirjas also separates different types of comments, source code, and provides details about those comments, such as line number, file name, language used, total SLOC, etc. Nirjas is a standalone Python framework/library and can be easily installed via source or pip (the Python package installer). Nirjas was initially created as part of a Google Summer of Code project and is currently developed and maintained under the FOSSology organization.

代码分析开源工具元数据提取

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。