Source Code Pattern Mining via Simplified Trees

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Traditional pattern mining algorithms often find too many patterns of little use, making it difficult to discover useful regularities in source code, and the enumeration process is expensive due to the large number of candidates generated from vast data, leading to inefficient code analysis.

Innovation Solution

A data mining technique is applied to convert source code programs into simplified trees, detecting closed and maximal frequent subtrees that represent the largest frequently-occurring patterns, which are then used in an idiom web service and code completion system to assist developers by matching syntactic structure and method usage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional pattern mining algorithms are used to discover source code patterns, then comprehensive pattern detection is achieved, but the number of patterns found becomes excessively large and includes many patterns of little use

Engineering Contradiction:
Improvepattern detection accuracyVSAvoidnumber of patterns
Core Design Contradiction:
Measurement precisionVSQuantity of substance

Solution Approach 1:

The patent extracts only the most significant patterns by applying frequency thresholds and statistical significance tests. This filters out the large number of low-value patterns generated by traditional algorithms, keeping only those patterns that meet predefined criteria for usefulness and frequency in the codebase.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent changes the parameters of pattern mining by introducing frequency thresholds, support thresholds, and statistical significance criteria. These parameter changes transform the output from an exhaustive list of all possible patterns to a focused set of high-value patterns that meet specific quantitative criteria.

Inventive Principle:
Principle #35Parameter changes

2Measurement precision

If exhaustive candidate enumeration is performed to find all frequent patterns, then complete pattern coverage is achieved, but the computational cost becomes very expensive

Engineering Contradiction:
Improvepattern coverageVSAvoidcomputational cost
Core Design Contradiction:
Measurement precisionVSLoss of energy

Solution Approach 1:

The patent performs preliminary actions by pre-computing frequency statistics and pattern supports before the main mining process. This preliminary analysis allows the algorithm to prune the search space early, avoiding the exhaustive enumeration of all candidate patterns while still ensuring complete coverage of frequent patterns that meet the threshold criteria.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent applies partial action by focusing computational resources only on patterns that have a reasonable chance of being frequent, based on preliminary statistical analysis. Instead of exhaustively enumerating all possible patterns, the algorithm performs targeted mining on promising candidates, reducing computational cost while maintaining adequate pattern coverage.

Inventive Principle:
Principle #16Partial or excessive action

3Quantity of substance

If all frequent subtrees are extracted from the source code database, then complete pattern inventory is achieved, but the results become difficult to analyze and gain insights from

Engineering Contradiction:
Improvenumber of patternsVSAvoidresult analysis
Core Design Contradiction:
Quantity of substanceVSEase of operation

Solution Approach 1:

The patent extracts only the most representative and frequent patterns by applying filtering criteria based on frequency thresholds and statistical significance. This extraction process removes the overwhelming number of rare and insignificant patterns, leaving a manageable subset that is easy to analyze and provides meaningful insights into code structure and usage patterns.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent applies local quality by differentiating between patterns based on their frequency and significance characteristics. High-frequency, statistically significant patterns are highlighted and prioritized in the results, while low-frequency patterns are filtered out. This creates a results presentation with varying levels of importance, making it easy for users to focus on the most relevant patterns.

Inventive Principle:
Principle #3Local quality

Data Source

PatentEP4127913B1Frequent source code pattern mining
Publication Date: 2024.11.27 MICROSOFT TECHNOLOGY LICENSING LLC
  • EP4127913B1 patent drawingFigure 1
  • EP4127913B1 patent drawingFigure 2
  • EP4127913B1 patent drawingFigure 3

AI summary

A data mining technique is used to find large frequently-occurring source code patterns from methods/APIs that can be used in code development. Simplified trees that represent the syntactic structure and type and method usage of a source code fragment, such as a method, are mined to find closed and maximal frequent subtrees which represent the largest frequently-occurring source code patterns or idioms associated with a particular type and method usage. These idioms are then used in an idiom web service and/or a code completion system to assist users in the development of source code programs.