Skip to content

Commit

Permalink
removed deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
StevaneticS authored and StevaneticS committed Nov 21, 2023
1 parent 3d448ca commit 67db423
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ public interface TranslationService {
*/
boolean isSupported(String srcLang, String trgLang);

@Deprecated
/**
* Use the method translate(List<TranslationObj> translationObjs).
* Translate multiple texts
*
* @param texts to translate
* @param targetLanguage language into which the texts are translated
* @return translations of the provided texts
* @throws TranslationException when there is a problem sending the translation request
*/
List<String> translate(List<String> texts, String targetLanguage) throws TranslationException;

/**
* Translates a list of texts from a list of TranslationObj and saves the results back to the objects.
* @param translationObjs
Expand All @@ -48,21 +36,6 @@ public interface TranslationService {

void detectLanguages(List<TranslationObj> translationObjs) throws TranslationException;

@Deprecated
/**
* Use the method translate(List<TranslationObj> translationObjs).
* Translate multiple texts.
*
* @param texts to translate
* @param targetLanguage language into which the texts are translated
* @param sourceLanguage source language of the texts to be translated
* @return translations of the provided texts
* @throws TranslationException when there is a problem sending the translation request
*/
List<String> translate(List<String> texts, String targetLanguage, String sourceLanguage)
throws TranslationException;


/**
* to close the engine
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ public class DummyGTranslateService extends GoogleTranslationService {
public DummyGTranslateService(GoogleTranslationServiceClientWrapper clientWrapperBean) {
super(GoogleTranslationServiceClientWrapper.MOCK_CLIENT_PROJ_ID, clientWrapperBean);
}

@Override
public List<String> translate(List<String> text, String targetLanguage, String sourceLanguage)
throws TranslationException {
return translate(text, null);
}

@Override
public List<String> translate(List<String> text, String targetLanguage)
throws TranslationException {
return text;
}

@Override
public void translate(List<TranslationObj> translationObjs, boolean detectLanguages) throws TranslationException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package eu.europeana.api.translation.service.google;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -45,16 +44,6 @@ public void init(GoogleTranslationServiceClientWrapper clientWrapper) {
this.locationName = LocationName.of(getGoogleProjectId(), "global");
}

@Deprecated
/**
* Use the method translate(List<TranslationObj> translationObjs).
*/
@Override
public List<String> translate(List<String> text, String targetLanguage)
throws TranslationException {
return translate(text, targetLanguage, null);
}

@Override
public void translate(List<TranslationObj> translationObjs, boolean detectLanguages) throws TranslationException {
try {
Expand Down Expand Up @@ -105,37 +94,6 @@ public void translate(List<TranslationObj> translationObjs, boolean detectLangua

}

@Deprecated
/**
* Use the method translate(List<TranslationObj> translationObjs).
*/
@Override
public List<String> translate(List<String> text, String targetLanguage, String sourceLanguage) throws TranslationException {
try {
List<String> result = new ArrayList<>();
if(text.isEmpty()) {
return result;
}

Builder requestBuilder = TranslateTextRequest.newBuilder().setParent(locationName.toString())
.setMimeType(MIME_TYPE_TEXT).setTargetLanguageCode(targetLanguage).addAllContents(text);
if (sourceLanguage != null) {
requestBuilder.setSourceLanguageCode(sourceLanguage);
}
TranslateTextRequest request = requestBuilder.build();

TranslateTextResponse response = this.clientWrapper.getClient().translateText(request);

for (Translation t : response.getTranslationsList()) {
result.add(t.getTranslatedText());
}
return result;
} catch (ApiException ex) {
final int remoteStatusCode = ex.getStatusCode().getCode().getHttpStatusCode();
throw new TranslationException("Exception occured during Google translation!", remoteStatusCode, ex);
}
}

@Override
public boolean isSupported(String srcLang, String targetLanguage) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ public class DummyPangTranslationService extends PangeanicTranslationService{
public DummyPangTranslationService() {
super(null, null);
}

@Override
public List<String> translate(List<String> text, String targetLanguage, String sourceLanguage)
throws TranslationException {
return translate(text, null);
}

@Override
public List<String> translate(List<String> text, String targetLanguage)
throws TranslationException {
return text;
}

@Override
public void translate(List<TranslationObj> translationObjs, boolean detectLanguages) throws TranslationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ public void translate(List<TranslationObj> translationObjs, boolean detectLangua
}
}

@Deprecated
/**
* Use the method translate(List<TranslationObj> translationObjs).
*/
@Override
public List<String> translate(List<String> texts, String targetLanguage)
throws TranslationException {
return translate(texts, targetLanguage, null);
}

private void computeTranslations(List<TranslationObj> translationObjs) throws JSONException, TranslationException {
List<String> analyzedLangs = new ArrayList<String>();
for(int i=0;i<translationObjs.size();i++) {
Expand Down Expand Up @@ -283,11 +273,4 @@ public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}


@Override
public List<String> translate(List<String> texts, String targetLanguage, String sourceLanguage)
throws TranslationException {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public boolean isSupported(String srcLang, String trgLang) {
return true;
}

@Override
public List<String> translate(List<String> texts, String targetLanguage) throws TranslationException {
return null;
}

@Override
public void translate(List<TranslationObj> translationObjs, boolean detectLanguages) throws TranslationException {
//first detect languages for the texts that do not have it using the pangeanic lang detect
Expand All @@ -62,11 +57,6 @@ public void translate(List<TranslationObj> translationObjs, boolean detectLangua
redisCacheService.saveRedisCache(translationObjs);
}

@Override
public List<String> translate(List<String> texts, String targetLanguage, String sourceLanguage) throws TranslationException {
return null;
}

@Override
public void close() {
}
Expand Down

0 comments on commit 67db423

Please sign in to comment.