use of com.redhat.devtools.alizer.api.Language in project jbosstools-openshift by jbosstools.
the class LanguageRecognizerTest method checkLanguageRecognizerOnEmptyFolder.
@Test
public void checkLanguageRecognizerOnEmptyFolder() throws IOException {
LanguageRecognizer recognize = new RecognizerFactory().createLanguageRecognizer();
List<Language> languages = recognize.analyze(folder.newFolder().getAbsolutePath());
assertTrue(languages.isEmpty());
}
use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.
the class HubItemScore method computeScore.
private int computeScore(HubItem hubItem) {
int score = 0;
ResourceData resourceData = hubItem.getResource();
ResourceVersionData resourceVersionData = resourceData.getLatestVersion();
for (int i = 0; i < languages.size(); i++) {
Language language = languages.get(i);
int multiplier = i >= LANGUAGES_MULTIPLIER.length ? LANGUAGES_MULTIPLIER[LANGUAGES_MULTIPLIER.length - 1] : LANGUAGES_MULTIPLIER[i];
if (matches(resourceData.getName(), language)) {
score += NAME_WEIGHT * multiplier;
}
if (resourceVersionData != null && matches(resourceVersionData.getDescription(), language)) {
score += DESCRIPTION_WEIGHT * multiplier;
}
List<String> tags = resourceData.getTags().stream().map(c -> c.getName()).collect(Collectors.toList());
if (resourceData.getTags().contains(language.getName()) || matches(tags, language)) {
score += TAG_WEIGHT * multiplier;
}
}
return score;
}
use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.
the class HubItemScoreTest method Compare_2HubItems_VerifyCalculatedScoreWithOnlyName.
@Test
public void Compare_2HubItems_VerifyCalculatedScoreWithOnlyName() {
Language lang = new Language("First", Collections.emptyList(), 99.0, false);
Language lang2 = new Language("Second", Collections.emptyList(), 1.0, false);
List<Language> languages = Arrays.asList(lang, lang2);
HubItem hubItem1 = buildHubItem("Second", "", Collections.emptyList());
HubItem hubItem2 = buildHubItem("First", "", Collections.emptyList());
HubItemScore hubItemScore = new HubItemScore(languages);
assertEquals(-20, hubItemScore.compare(hubItem1, hubItem2));
}
use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.
the class HubItemScoreTest method Compare_1HubItemAndValue_VerifyCalculatedScoreWithAliases.
@Test
public void Compare_1HubItemAndValue_VerifyCalculatedScoreWithAliases() {
Language lang = new Language("First", Arrays.asList("alias1", "alias2"), 99.0, false);
Language lang2 = new Language("Second", Arrays.asList("alias3", "alias4"), 1.0, false);
List<Language> languages = Arrays.asList(lang, lang2);
HubItem hubItem1 = buildHubItem("alias1", "", Collections.emptyList());
HubItemScore hubItemScore = new HubItemScore(languages);
assertEquals(39, hubItemScore.compare(hubItem1, 1));
}
use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.
the class HubItemScoreTest method Compare_1HubItemAndValue_VerifyCalculatedScoreWithDescription.
@Test
public void Compare_1HubItemAndValue_VerifyCalculatedScoreWithDescription() {
Language lang = new Language("First", Arrays.asList("alias1", "alias2"), 99.0, Arrays.asList("framework1"), Collections.emptyList(), false);
Language lang2 = new Language("Second", Arrays.asList("alias3", "alias4"), 1.0, Arrays.asList("framework2"), Collections.emptyList(), false);
List<Language> languages = Arrays.asList(lang, lang2);
HubItem hubItem1 = buildHubItem("name", "this is the first item for the first language", Collections.emptyList());
HubItemScore hubItemScore = new HubItemScore(languages);
assertEquals(11, hubItemScore.compare(hubItem1, 1));
}
Aggregations