Skip to content

Commit

Permalink
Add push script
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Dec 5, 2024
1 parent 0bd90ab commit d516313
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 502 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Licensed under MIT 2023. */
/* Licensed under MIT 2023-2024. */
package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy;

import java.util.ArrayList;
Expand Down Expand Up @@ -83,16 +83,16 @@ private static ImmutableList<ModelInstance> initCodeInstances(CodeModel codeMode
}

private static void fillPackages(Collection<? extends CodePackage> packages, List<ModelInstance> instances) {
for (var modelElement : packages) {
String path = modelElement.getName();
for (var modelElement : packages) {
StringBuilder path = new StringBuilder(modelElement.getName());
CodeModule parent = modelElement.getParent();
while (parent != null) {
path = parent.getName() + "/" + path;
path.insert(0, parent.getName() + "/");
parent = parent.getParent();
}
// Ensure that package is handled as directory
path += "/";
instances.add(new ModelInstanceImpl(modelElement.getName(), "Package", path));
path.append("/");
instances.add(new ModelInstanceImpl(modelElement.getName(), "Package", path.toString()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public List<String> getParentPackageNames() {
while (parent.hasParent()) {
parent = parent.getParent();
if (parent instanceof CodePackage) {
parents.add(0, parent.getName());
parents.addFirst(parent.getName());
}
}
return parents;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
/* Licensed under MIT 2021-2023. */
/* Licensed under MIT 2021-2024. */
package edu.kit.kastel.mcse.ardoco.core.api.stage.textextraction;

/**
* The mapping type of a mapping state defines whether the mapping is a name or a type.
*/
public enum MappingKind {

/**
* A noun mapping can be identified as an identifier {@link #NAME}, a potential type {@link #TYPE}
*/
NAME,
/**
* A noun mapping can be identified as an identifier {@link #NAME}, a potential type {@link #TYPE}
*/
TYPE

NAME, TYPE
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* Licensed under MIT 2024. */
package edu.kit.kastel.mcse.ardoco.core.api.tracelink;

import java.util.ArrayList;
Expand Down Expand Up @@ -80,10 +81,4 @@ public boolean equals(Object obj) {
}
return Objects.equals(this.allLinks, other.allLinks);
}

@Override
public String toString() {
return this.asPair().toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,4 @@ public boolean equals(Object obj) {
}
return Objects.equals(this.asPair(), other.asPair());
}

@Override
public String toString() {
return this.asPair().toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Licensed under MIT 2023. */
/* Licensed under MIT 2023-2024. */
package edu.kit.kastel.mcse.ardoco.core.common;

import java.io.File;
Expand Down Expand Up @@ -35,7 +35,7 @@ public static boolean shallowCloneRepository(String repositoryLink, String desir
List<RevCommit> commits = new ArrayList<>();
git.log().setMaxCount(1).call().forEach(commits::add);
assert commits.size() == 1;
if (commits.get(0).getId().startsWith(AbbreviatedObjectId.fromString(desiredHash))) {
if (commits.getFirst().getId().startsWith(AbbreviatedObjectId.fromString(desiredHash))) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public double getSimilarity(ComparisonContext ctx) {
try {
return this.compareVectors(ctx.firstTerm(), ctx.secondTerm());
} catch (RetrieveVectorException e) {
LOGGER.error("Failed to compare glove vectors: " + ctx, e);
LOGGER.error("Failed to compare glove vectors: {}", ctx, e);
return Double.NaN;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public double getSimilarity(ComparisonContext ctx) {
try {
similarity = this.getDataSource().getSimilarity(ctx.firstTerm(), ctx.secondTerm()).orElse(Double.NaN);
} catch (SQLException e) {
LOGGER.error("Failed to query the SEWordSim database for word comparison: " + ctx, e);
LOGGER.error("Failed to query the SEWordSim database for word comparison: {}", ctx, e);
}
return similarity; // words are probably missing from the database
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Licensed under MIT 2022-2023. */
/* Licensed under MIT 2022-2024. */
package edu.kit.kastel.mcse.ardoco.core.common.similarity.wordsim.vector;

import java.util.Objects;
Expand Down Expand Up @@ -76,10 +76,6 @@ public static double cosineSimilarity(float[] firstVec, float[] secondVec) {
public static boolean isZero(double[] vector) {
Objects.requireNonNull(vector);

if (vector.length == 0) {
return true;
}

for (double entry : vector) {
if (entry != 0.0) {
return false;
Expand All @@ -98,10 +94,6 @@ public static boolean isZero(double[] vector) {
public static boolean isZero(float[] vector) {
Objects.requireNonNull(vector);

if (vector.length <= 0) {
return true;
}

for (float entry : vector) {
if (entry != 0.0f) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Licensed under MIT 2022-2024. */
package edu.kit.kastel.mcse.ardoco.core.data;

import java.io.Serial;
import java.util.SortedMap;

import edu.kit.kastel.mcse.ardoco.core.configuration.AbstractConfigurable;
Expand All @@ -10,6 +11,7 @@
*/
public abstract class AbstractState extends AbstractConfigurable implements PipelineStepData {

@Serial
private static final long serialVersionUID = -3318799425973820663L;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ protected final void preparePipelineSteps() {
*/
@Override
protected void before() {
//Nothing by default
// Nothing by default
}

/**
* Called after all agents
*/
@Override
protected void after() {
//Nothing by default
// Nothing by default
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* This class represents a pipeline agent that calculates some results for an {@link AbstractExecutionStage} execution stage}.
*
* <p>
* Implementing classes need to override. Additionally, sub-classes are free to override {@link #initializeState()} to execute code at the beginning of the
* initialization before the main processing.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Phrase parseConstituencyTree(String constituencyTree, List<Word> wordsOfS
if (wordsOfSentence.isEmpty()) {
throw new NotConvertableException("Constituency tree does not match words of sentence");
}
words.add(wordsOfSentence.remove(0));
words.add(wordsOfSentence.removeFirst());
} else {
subPhrases.add(parseConstituencyTree(subtree, wordsOfSentence));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Licensed under MIT 2023. */
/* Licensed under MIT 2023-2024. */
package edu.kit.kastel.mcse.ardoco.core.textproviderjson.converter;

import java.io.IOException;
Expand Down Expand Up @@ -116,22 +116,22 @@ private String convertToSubtree(Phrase phrase) {
while (!words.isEmpty() || !subphrases.isEmpty()) {
if (subphrases.isEmpty()) {
// word next
Word word = words.remove(0);
Word word = words.removeFirst();
constituencyTree.append(TREE_SEPARATOR).append(convertWordToTree(word));
} else if (words.isEmpty()) {
// phrase next
Phrase subphrase = subphrases.remove(0);
Phrase subphrase = subphrases.removeFirst();
constituencyTree.append(TREE_SEPARATOR).append(convertToSubtree(subphrase));
} else {
int wordIndex = words.get(0).getPosition();
List<Integer> phraseWordIndices = subphrases.get(0).getContainedWords().toList().stream().map(Word::getPosition).toList();
int wordIndex = words.getFirst().getPosition();
List<Integer> phraseWordIndices = subphrases.getFirst().getContainedWords().toList().stream().map(Word::getPosition).toList();
if (wordIndex < Collections.min(phraseWordIndices)) {
// word next
Word word = words.remove(0);
Word word = words.removeFirst();
constituencyTree.append(TREE_SEPARATOR).append(convertWordToTree(word));
} else {
// phrase next
Phrase subphrase = subphrases.remove(0);
Phrase subphrase = subphrases.removeFirst();
constituencyTree.append(TREE_SEPARATOR).append(convertToSubtree(subphrase));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Licensed under MIT 2022-2023. */
/* Licensed under MIT 2022-2024. */
package edu.kit.kastel.mcse.ardoco.core.textproviderjson.textobject;

import java.util.List;
Expand Down Expand Up @@ -118,7 +118,7 @@ private Phrase loadPhrase() {
var currentPhrase = getSentence().getPhrases().toList().stream().filter(p -> p.getContainedWords().contains(this)).findFirst().orElseThrow();
var subPhrases = List.of(currentPhrase);
while (!subPhrases.isEmpty()) {
currentPhrase = subPhrases.get(0);
currentPhrase = subPhrases.getFirst();
subPhrases = currentPhrase.getSubPhrases().toList().stream().filter(p -> p.getContainedWords().contains(this)).toList();
}
return currentPhrase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Licensed under MIT 2023. */
/* Licensed under MIT 2023-2024. */
package edu.kit.kastel.mcse.ardoco.core.textproviderjson.converter;

import java.util.ArrayList;
Expand All @@ -24,7 +24,7 @@ class TreeParserTest {
POSTag.VERB_SINGULAR_PRESENT_THIRD_PERSON, null, null, null), new WordImpl(null, 2, 0, "me", POSTag.PRONOUN_PERSONAL, null, null, null),
new WordImpl(null, 3, 0, ".", POSTag.CLOSER, null, null, null)));
Phrase subsubphrase = new PhraseImpl(Lists.immutable.of(words.get(2)), PhraseType.NP, new ArrayList<>());
List<Phrase> subphrases = List.of(new PhraseImpl(Lists.immutable.of(words.get(0)), PhraseType.NP, new ArrayList<>()), new PhraseImpl(Lists.immutable.of(
List<Phrase> subphrases = List.of(new PhraseImpl(Lists.immutable.of(words.getFirst()), PhraseType.NP, new ArrayList<>()), new PhraseImpl(Lists.immutable.of(
words.get(1)), PhraseType.VP, List.of(subsubphrase)));
Phrase phrase = new PhraseImpl(Lists.immutable.of(words.get(3)), PhraseType.S, subphrases);
Phrase expectedPhrase = new PhraseImpl(Lists.immutable.empty(), PhraseType.ROOT, List.of(phrase));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import edu.kit.kastel.mcse.ardoco.core.api.entity.ArchitectureEntity;
import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel;
import edu.kit.kastel.mcse.ardoco.core.api.models.ModelStates;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.Model;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionState;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit;
Expand Down
Loading

0 comments on commit d516313

Please sign in to comment.