An open API service indexing awesome lists of open source software.

https://github.com/loehnertz/semantic-coupling

A library to compute the semantic coupling between source code files
https://github.com/loehnertz/semantic-coupling

kotlin nlp semantic-analysis semantic-coupling semantic-similarity

Last synced: about 1 year ago
JSON representation

A library to compute the semantic coupling between source code files

Awesome Lists containing this project

README

          

[![](https://jitpack.io/v/loehnertz/semantic-coupling.svg)](https://jitpack.io/#loehnertz/semantic-coupling)

# semantic-coupling
A library to compute the semantic coupling between source code files (e.g. classes)

## Participation
**The library currently only supports source code written in Java and the English language.**
I am very happy to pull other sets of programming and natural languages into this library, just open a PR for them.

## Usage
- Add this library to your own project: https://jitpack.io/#loehnertz/semantic-coupling/rc4
- If you are using Kotlin as well, just go ahead and instantiate the main class:
```
val files: List = retrieveFiles()
val fileContentsMap: Map = files.map { convertFileNameToIdentifier(it.absolutePath) to it.readText() }.toMap() // A map of file name to raw file contents
val semanticCouplingCalculator = SemanticCouplingCalculator(
files = fileContentsMap,
programmingLanguage = ProgrammingLanguage.JAVA,
naturalLanguage = NaturalLanguage.EN
)
val semanticCouplings: List = semanticCouplingCalculator.calculate()
```
- If you are using Java, you can do pretty much the same:
```
SemanticCouplingCalculator semanticCouplingCalculator = new SemanticCouplingCalculator(fileContentsMap, ProgrammingLanguage.JAVA, NaturalLanguage.EN);
List semanticCouplings = semanticCouplingCalculator.calculate();
```

If you have any further questions, just open an issue or send me an e-mail.