一句话:提出交互式代码搜索技术 ALICE,用主动归纳逻辑编程从用户正负反馈中推断并精化逻辑查询。
现代代码搜索技术难以高效利用人工反馈,也难以表达代码的结构或语义属性。ALICE 将代码结构与语义建模为逻辑事实,并设计查询语言:给定带标注的代码示例,它从重要代码特征中自动抽取逻辑查询。用户把示例标为期望(正例)或不相关(负例),ALICE 便通过主动归纳逻辑编程推断能区分正负例的新查询,迭代精化搜索。模拟实验表明,ALICE 能快速消除大量假阳性,且对标注错误鲁棒;利用正负例并以嵌套程序结构作归纳偏置,有效提升查询精化。与已有交互式搜索技术相比,它无需手工构造搜索模式,却以更少迭代达到相近精确率与召回率;开发者案例研究显示其易用且能表达复杂模式。
Modern search techniques either cannot efficiently incorporate human feedback to refine search results or cannot express structural or semantic properties of desired code. The key insight of our interactive code search technique ALICE is that user feedback can be actively incorporated to allow users to easily express and refine search queries. We design a query language to model the structure and semantics of code as logic facts. Given a code example with user annotations, ALICE automatically extracts a logic query from code features that are tagged as important. Users can refine the search query by labeling one or more examples as desired (positive) or irrelevant (negative). ALICE then infers a new logic query that separates positive examples from negative examples via active inductive logic programming. Our comprehensive simulation experiment shows that ALICE removes a large number of false positives quickly by actively incorporating user feedback. Its search algorithm is also robust to user labeling mistakes. Our choice of leveraging both positive and negative examples and using nested program structure as an inductive bias is effective in refining search queries. Compared with an existing interactive code search technique, ALICE does not require a user to manually construct a search pattern and yet achieves comparable precision and recall with much fewer search iterations. A case study with real developers shows that ALICE is easy to use and helps express complex code patterns.