semeru/Text-Code-CodeSearchNet-Python
收藏资源简介:
--- license: mit Programminglanguage: "Python" version: "N/A" Date: "Codesearchnet(Jun 2020 - paper release date)" Contaminated: "Very Likely" Size: "Standard Tokenizer (TreeSitter)" --- ### Dataset is imported from CodeXGLUE and pre-processed using their script. # Where to find in Semeru: The dataset can be found at /nfs/semeru/semeru_datasets/code_xglue/text-to-code/codesearchnet/python in Semeru # CodeXGLUE -- Code Search (AdvTest) ## Task Definition Given a natural language, the task is to search source code that matches the natural language. To test the generalization ability of a model, function names and variables in test sets are replaced by special tokens. ## Dataset The dataset we use comes from [CodeSearchNet](https://arxiv.org/pdf/1909.09436.pdf) and we filter the dataset as the following: - Remove examples that codes cannot be parsed into an abstract syntax tree. - Remove examples that #tokens of documents is < 3 or >256 - Remove examples that documents contain special tokens (e.g. <img ...> or https:...) - Remove examples that documents are not English. Besides, to test the generalization ability of a model, function names and variables in test sets are replaced by special tokens. ### Data Format After preprocessing dataset, you can obtain three .jsonl files, i.e. train.jsonl, valid.jsonl, test.jsonl For each file, each line in the uncompressed file represents one function. One row is illustrated below. - **repo:** the owner/repo - **path:** the full path to the original file - **func_name:** the function or method name - **original_string:** the raw string before tokenization or parsing - **language:** the programming language - **code/function:** the part of the `original_string` that is code - **code_tokens/function_tokens:** tokenized version of `code` - **docstring:** the top-level comment or docstring, if it exists in the original string - **docstring_tokens:** tokenized version of `docstring` - **url:** the url for the example (identify natural language) - **idx**: the index of code (identify code) ### Data Statistics Data statistics of the dataset are shown in the below table: | | #Examples | | ----- | :-------: | | Train | 251,820 | | Dev | 9,604 | | Test | 19,210 | ### Example Given a text-code file evaluator/test.jsonl: ```json {"url": "url0", "docstring": "doc0","function": "fun0", "idx": 10} {"url": "url1", "docstring": "doc1","function": "fun1", "idx": 11} {"url": "url2", "docstring": "doc2","function": "fun2", "idx": 12} {"url": "url3", "docstring": "doc3","function": "fun3", "idx": 13} {"url": "url4", "docstring": "doc4","function": "fun4", "idx": 14} ``` ### Input Predictions For each url for natural language, descending sort candidate codes and return their idx in order. For example: ```json {"url": "url0", "answers": [10,11,12,13,14]} {"url": "url1", "answers": [10,12,11,13,14]} {"url": "url2", "answers": [13,11,12,10,14]} {"url": "url3", "answers": [10,14,12,13,11]} {"url": "url4", "answers": [10,11,12,13,14]} ``` ## Reference <pre><code>@article{husain2019codesearchnet, title={Codesearchnet challenge: Evaluating the state of semantic code search}, author={Husain, Hamel and Wu, Ho-Hsiang and Gazit, Tiferet and Allamanis, Miltiadis and Brockschmidt, Marc}, journal={arXiv preprint arXiv:1909.09436}, year={2019} }</code></pre>
许可证:MIT许可证 编程语言:Python 版本:无可用信息 数据日期:CodeSearchNet(2020年6月——论文发布日期) 数据污染情况:极有可能存在污染 分词规格:采用标准分词器(TreeSitter) 本数据集源自CodeXGLUE,并使用其官方脚本完成预处理工作。 # 在Semeru平台中的获取路径 该数据集可于Semeru的/nfs/semeru/semeru_datasets/code_xglue/text-to-code/codesearchnet/python路径下获取。 # CodeXGLUE —— 代码搜索任务(AdvTest) ## 任务定义 给定一段自然语言,本任务旨在检索与之语义匹配的源代码。为测试模型的泛化能力,测试集中的函数名与变量均已替换为特殊标记(Token)。 ## 数据集概况 本数据集源自[CodeSearchNet](https://arxiv.org/pdf/1909.09436.pdf),并按照如下规则进行过滤预处理: - 移除无法被解析为抽象语法树(Abstract Syntax Tree)的样本 - 移除文档Token数量小于3或大于256的样本 - 移除文档中包含特殊标记的样本(例如<img ...>或https://格式的链接等) - 移除文档非英文的样本 此外,为进一步验证模型泛化能力,测试集中的函数名与变量同样会被替换为特殊标记(Token)。 ### 数据格式 完成预处理后,将得到三个.jsonl格式文件,分别为train.jsonl、valid.jsonl与test.jsonl。 每个文件的每一行均对应一个函数,下文将展示单条数据的格式示例: - **repo**:代码仓库的所有者/仓库名 - **path**:原始文件的完整路径 - **func_name**:函数或方法名称 - **original_string**:分词或解析前的原始字符串 - **language**:所用编程语言 - **code/function**:`original_string`中对应的代码部分 - **code_tokens/function_tokens**:`code`的分词结果 - **docstring**:原始字符串中的顶层注释或文档字符串(若存在) - **docstring_tokens**:`docstring`的分词结果 - **url**:该样本对应的自然语言查询链接(用于标识自然语言查询) - **idx**:代码的索引编号(用于标识代码样本) ### 数据统计 数据统计情况如下表所示: | | 样本数量 | | ----- | :-------: | | 训练集 | 251,820 | | 验证集 | 9,604 | | 测试集 | 19,210 | ### 样本示例 以evaluator/test.jsonl文本代码文件为例,以下为该文件的内容示例: json {"url": "url0", "docstring": "doc0","function": "fun0", "idx": 10} {"url": "url1", "docstring": "doc1","function": "fun1", "idx": 11} {"url": "url2", "docstring": "doc2","function": "fun2", "idx": 12} {"url": "url3", "docstring": "doc3","function": "fun3", "idx": 13} {"url": "url4", "docstring": "doc4","function": "fun4", "idx": 14} ### 预测输入格式 针对每个自然语言查询对应的url,需对候选代码按匹配度降序排序,并按顺序返回其idx编号。示例如下: json {"url": "url0", "answers": [10,11,12,13,14]} {"url": "url1", "answers": [10,12,11,13,14]} {"url": "url2", "answers": [13,11,12,10,14]} {"url": "url3", "answers": [10,14,12,13,11]} {"url": "url4", "answers": [10,11,12,13,14]} ## 参考文献 bibtex @article{husain2019codesearchnet, title={Codesearchnet challenge: Evaluating the state of semantic code search}, author={Husain, Hamel and Wu, Ho-Hsiang and Gazit, Tiferet and Allamanis, Miltiadis and Brockschmidt, Marc}, journal={arXiv preprint arXiv:1909.09436}, year={2019} }
数据集概述
数据集来源与处理
- 来源: 数据集来自CodeSearchNet。
- 处理: 使用CodeXGLUE的脚本进行预处理,包括移除无法解析为抽象语法树的代码示例,以及不符合特定token数量和语言要求的文档。
数据集内容
- 格式: 包含三个.jsonl文件:train.jsonl, valid.jsonl, test.jsonl。
- 结构: 每个文件的每行代表一个函数,包含repo, path, func_name, original_string, language, code/function, code_tokens/function_tokens, docstring, docstring_tokens, url, idx等字段。
数据集统计
| #Examples | |
|---|---|
| Train | 251,820 |
| Dev | 9,604 |
| Test | 19,210 |
任务定义
- 目标: 给定自然语言描述,搜索匹配的源代码。
- 测试: 为了测试模型的泛化能力,测试集中的函数名和变量被替换为特殊token。
数据集示例
- 文件: evaluator/test.jsonl
- 内容示例: 包含多个记录,每个记录有url, docstring, function, idx等字段。
输入预测
- 处理: 对每个自然语言的url,按降序排列候选代码并返回它们的idx。
- 示例: 返回的json格式包含url和对应的answers数组。




