code similarity

code similarity detection, calculate program similarity

License

License

GroupId

GroupId

com.zhixiangli
ArtifactId

ArtifactId

code-similarity
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

code similarity
code similarity detection, calculate program similarity
Project URL

Project URL

https://github.com/zhixiangli/code-similarity
Source Code Management

Source Code Management

https://github.com/zhixiangli/code-similarity

Download code-similarity

How to add to project

<!-- https://jarcasting.com/artifacts/com.zhixiangli/code-similarity/ -->
<dependency>
    <groupId>com.zhixiangli</groupId>
    <artifactId>code-similarity</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.zhixiangli/code-similarity/
implementation 'com.zhixiangli:code-similarity:0.0.2'
// https://jarcasting.com/artifacts/com.zhixiangli/code-similarity/
implementation ("com.zhixiangli:code-similarity:0.0.2")
'com.zhixiangli:code-similarity:jar:0.0.2'
<dependency org="com.zhixiangli" name="code-similarity" rev="0.0.2">
  <artifact name="code-similarity" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.zhixiangli', module='code-similarity', version='0.0.2')
)
libraryDependencies += "com.zhixiangli" % "code-similarity" % "0.0.2"
[com.zhixiangli/code-similarity "0.0.2"]

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.5
org.apache.commons : commons-collections4 jar 4.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

code-similarity

Code Similarity provides some implementations of similarity detection algorithm, including Longest Common Subsequence & Cosine Distance

It used to work on data structure courses & exam code check.

Environmental Requirements

JDK 1.8+

Instructions

Add Dependency

<dependency>
	<groupId>com.zhixiangli</groupId>
	<artifactId>code-similarity</artifactId>
	<version>0.0.2</version>
</dependency>

Example

String a = "public static void main(String[] args) {System.out.println(1);}";
String b = "public static void main(String[] args) {System.out.println(2);}";

// default algorithm is Longest Common Subsequence.
CodeSimilarity codeSimilarity = new CodeSimilarity();
System.out.println(codeSimilarity.get(a, b));

// change similarity algorithm to Cosine Distance.
CodeSimilarity cosineSimilarity = new CodeSimilarity(new CosineSimilarity());
System.out.println(cosineSimilarity.get(a, b));

Versions

Version
0.0.2
0.0.1