Skip to content

Commit

Permalink
Minor SCA-based code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Apr 10, 2024
1 parent 40f7026 commit 29e0c67
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package cz.cvut.kbss.textanalysis.lemmatizer;

import cz.cvut.kbss.textanalysis.lemmatizer.model.LemmatizerResult;
import cz.cvut.kbss.textanalysis.lemmatizer.model.SingleLemmaResult;
import java.util.List;

public interface LemmatizerApi {

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version "0.0.1"

def revision = "git rev-list --count HEAD".execute().text.trim()
def hash = "git rev-parse --short HEAD".execute().text.trim()
version = "0.0.1.r${revision}.${hash}";
version = "0.0.1.r${revision}.${hash}"

ext {
junitVersion = "5.9.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public interface ChunkAnnotationService {
/**
* Accepts a plain-text chunk and returns a stream of words
*
* @param textChunk
* @return
* @param textChunk Chunk to annotate
* @return array of words extracted from the chunk
*/
Word[] process(final String textChunk) ;
}

This file was deleted.

24 changes: 0 additions & 24 deletions core/src/main/java/cz/cvut/kbss/textanalysis/service/Services.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,8 @@
*/
package cz.cvut.kbss.service.textanalysis;

import static org.junit.jupiter.api.Assertions.assertEquals;


import cz.cvut.kbss.textanalysis.dto.TextAnalysisInput;
import cz.cvut.kbss.textanalysis.service.HtmlAnnotationException;
import cz.cvut.kbss.textanalysis.service.HtmlAnnotationService;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.junit.jupiter.api.Test;
Expand All @@ -38,6 +30,13 @@
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest(classes = {HtmlAnnotationService.class, FileOntologyService.class})
@Import(ServiceTestConfiguration.class)
@ActiveProfiles("test")
Expand All @@ -47,8 +46,7 @@ public class AnnotationIntegrationTest {
private HtmlAnnotationService sut;

@Test
public void testAnnotateQuotedStrings()
throws IOException, HtmlAnnotationException {
public void testAnnotateQuotedStrings() throws IOException {

final TextAnalysisInput input = new TextAnalysisInput()
.setVocabularyRepository(URI.create("https://slovník.gov.cz/generický/testovaci-slovnik"))
Expand All @@ -66,8 +64,7 @@ public void testAnnotateQuotedStrings()

@ParameterizedTest
@MethodSource("getIdempotentTexts")
public void testAnnotateIsIdempotent(final String file)
throws IOException, HtmlAnnotationException {
public void testAnnotateIsIdempotent(final String file) throws IOException {

final String content = Jsoup
.parse(new File(HtmlAnnotationService.class.getResource("/" + file).getFile()),"utf-8").toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public class HTMLParserTest {
@BeforeEach
public void init() {
TestChunkFactory.createTestChunks().forEach(
(cText,cAnnotation) -> {
lenient().when(chunkAnnotationService.process(cText)).thenReturn(cAnnotation);
}
(cText,cAnnotation) -> lenient().when(chunkAnnotationService.process(cText)).thenReturn(cAnnotation)
);
}

Expand All @@ -77,9 +75,7 @@ public void init() {
}

@Test public void testParseInvalidInputFail() {
Assertions.assertThrows(Exception.class, () -> {
sut.annotate(chunkAnnotationService,null,"cs");
});
Assertions.assertThrows(Exception.class, () -> sut.annotate(chunkAnnotationService, null, "cs"));
}

@Test public void testAnnotateMetropolitanPlanSuccessfully()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import cz.cvut.kbss.annotace.configuration.KerConf;
import cz.cvut.kbss.textanalysis.keywordextractor.KeywordExtractorAPI;
import cz.cvut.kbss.textanalysis.keywordextractor.model.KeywordExtractorResult;

import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -56,7 +58,7 @@ public KeywordExtractorResult process(final String chunks) {
final File file;
try {
file = File.createTempFile("ker-input","");
Files.write(Paths.get(file.toURI()), chunks.getBytes("utf-8"));
Files.write(Paths.get(file.toURI()), chunks.getBytes(StandardCharsets.UTF_8));

Resource fileResource = new FileSystemResource(file);
HttpHeaders headers = new HttpHeaders();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,11 @@ public void init() {
})
void check(final String val) {
final List<LemmatizerResult> results = new ArrayList<>();
Arrays.stream(lemmatizers).forEach(l -> {
results.add(l.process(val, "cs"));
});
Arrays.stream(lemmatizers).forEach(l -> results.add(l.process(val, "cs")));
results.forEach(r -> {
System.out.println(r.getLemmatizer());
r.getResult().forEach(l -> {
l.forEach(x -> {
System.out.print(String.format("%1$" + 30 + "s", x.getLemma()));
});
l.forEach(x -> System.out.printf("%1$" + 30 + "s", x.getLemma()));
System.out.println();
});
});
Expand Down

0 comments on commit 29e0c67

Please sign in to comment.