Class MachineLearningServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.MachineLearningServiceImpl
-
- All Implemented Interfaces:
MachineLearningService
@Service public class MachineLearningServiceImpl extends java.lang.Object implements MachineLearningService
-
-
Field Summary
Fields Modifier and Type Field Description private CommonProperties
commonProperties
private static int
HTTP_REQUEST_TIMEOUT
private LanguageRepository
languageRepository
private MachineLearningProperties
mlProperties
private MongoStorageService
mongoStorageService
private SKURepository
skuRepository
private TranslationService
translationService
-
Constructor Summary
Constructors Constructor Description MachineLearningServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
generateDatasetForAwsComprehend(java.lang.String filePath, java.lang.String langCode, java.lang.String targetDb, java.lang.String targetCollection, java.lang.Boolean isAbsolutePath)
This method automatically generate a dataset from existing list of termsvoid
generateTranslationsForLanguage(java.lang.String fromLangIsoCode, java.lang.String toLangIsoCode)
This method generates new database entities for new language.private java.lang.String
getBlockText(com.amazonaws.services.textract.model.Block block, java.util.List<com.amazonaws.services.textract.model.Block> blocks)
private java.lang.String
getCellBlockValue(java.lang.Integer fromIndex, java.util.List<com.amazonaws.services.textract.model.Block> blocks)
private java.lang.String
getDatasetItemDescription(java.util.List<java.lang.String> searchTerms, java.lang.String snippet)
private java.lang.String
getKeyBlockValue(com.amazonaws.services.textract.model.Block block, java.util.List<com.amazonaws.services.textract.model.Block> blocks)
private java.util.Set<java.lang.String>
getSkuId(java.lang.String line, com.amazonaws.services.comprehend.AmazonComprehend comprehendClient)
private java.util.List<com.google.api.services.customsearch.v1.model.Result>
googleCustomSearch(java.lang.String keyword, java.lang.String langCode)
java.util.Map<java.lang.String,java.lang.Object>
recognizeAttributesForSellerSku(java.util.ArrayList<java.lang.String> urls, java.lang.String sellerSkuType, java.lang.Boolean isAbsolutePath)
This method is working with AWS and it automatically does a recognition a seller sku object from filesprivate java.util.Map<java.lang.String,java.lang.Object>
recognizeSellerSku(java.util.List<com.amazonaws.services.textract.model.Block> blocks, com.amazonaws.services.comprehend.AmazonComprehend comprehendClient)
void
translateDatabaseForLanguage(java.lang.String fromLangIsoCode, java.lang.String toLangIsoCode, java.lang.String targetDb, java.lang.String targetCollection, java.util.ArrayList<java.lang.String> fieldNames)
This method generates new database entities for new language.
-
-
-
Field Detail
-
commonProperties
@Autowired private CommonProperties commonProperties
-
mlProperties
@Autowired private MachineLearningProperties mlProperties
-
skuRepository
@Autowired private SKURepository skuRepository
-
languageRepository
@Autowired private LanguageRepository languageRepository
-
translationService
@Autowired private TranslationService translationService
-
mongoStorageService
@Autowired private MongoStorageService mongoStorageService
-
HTTP_REQUEST_TIMEOUT
private static final int HTTP_REQUEST_TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
recognizeAttributesForSellerSku
public java.util.Map<java.lang.String,java.lang.Object> recognizeAttributesForSellerSku(java.util.ArrayList<java.lang.String> urls, java.lang.String sellerSkuType, java.lang.Boolean isAbsolutePath)
Description copied from interface:MachineLearningService
This method is working with AWS and it automatically does a recognition a seller sku object from files- Specified by:
recognizeAttributesForSellerSku
in interfaceMachineLearningService
- Parameters:
urls
- path of file which will be parsedsellerSkuType
- type of SellerSKUisAbsolutePath
- this is a switcher for the url construction- Returns:
- it returns a SellerSKU
-
generateDatasetForAwsComprehend
public void generateDatasetForAwsComprehend(java.lang.String filePath, java.lang.String langCode, java.lang.String targetDb, java.lang.String targetCollection, java.lang.Boolean isAbsolutePath)
Description copied from interface:MachineLearningService
This method automatically generate a dataset from existing list of terms- Specified by:
generateDatasetForAwsComprehend
in interfaceMachineLearningService
- Parameters:
filePath
- the text file with the list of termslangCode
- language codetargetDb
- the database which will be used to save a datasettargetCollection
- the collection which will be used to save a datasetisAbsolutePath
- this is a switcher for the url construction
-
generateTranslationsForLanguage
@Transactional @Async("asyncTaskExecutor") public void generateTranslationsForLanguage(java.lang.String fromLangIsoCode, java.lang.String toLangIsoCode)
Description copied from interface:MachineLearningService
This method generates new database entities for new language.- Specified by:
generateTranslationsForLanguage
in interfaceMachineLearningService
- Parameters:
fromLangIsoCode
- the language id which will be used as referencetoLangIsoCode
- the language id which will be used for translation entity generation
-
translateDatabaseForLanguage
@Transactional @Async("asyncTaskExecutor") public void translateDatabaseForLanguage(java.lang.String fromLangIsoCode, java.lang.String toLangIsoCode, java.lang.String targetDb, java.lang.String targetCollection, java.util.ArrayList<java.lang.String> fieldNames)
Description copied from interface:MachineLearningService
This method generates new database entities for new language.- Specified by:
translateDatabaseForLanguage
in interfaceMachineLearningService
- Parameters:
fromLangIsoCode
- the language id which will be used as referencetoLangIsoCode
- the language id which will be used for translation entity generationtargetDb
- the database which will be used to translatetargetCollection
- the collection which will be used to translatefieldNames
- the list of fields which should be translated
-
googleCustomSearch
private java.util.List<com.google.api.services.customsearch.v1.model.Result> googleCustomSearch(java.lang.String keyword, java.lang.String langCode)
-
getDatasetItemDescription
private java.lang.String getDatasetItemDescription(java.util.List<java.lang.String> searchTerms, java.lang.String snippet)
-
recognizeSellerSku
private java.util.Map<java.lang.String,java.lang.Object> recognizeSellerSku(java.util.List<com.amazonaws.services.textract.model.Block> blocks, com.amazonaws.services.comprehend.AmazonComprehend comprehendClient)
-
getBlockText
private java.lang.String getBlockText(com.amazonaws.services.textract.model.Block block, java.util.List<com.amazonaws.services.textract.model.Block> blocks)
-
getKeyBlockValue
private java.lang.String getKeyBlockValue(com.amazonaws.services.textract.model.Block block, java.util.List<com.amazonaws.services.textract.model.Block> blocks)
-
getCellBlockValue
private java.lang.String getCellBlockValue(java.lang.Integer fromIndex, java.util.List<com.amazonaws.services.textract.model.Block> blocks)
-
getSkuId
private java.util.Set<java.lang.String> getSkuId(java.lang.String line, com.amazonaws.services.comprehend.AmazonComprehend comprehendClient)
-
-