import { Microservices } from '../configs/microservices';
import rp from 'request-promise';

export default {
    name: 'nlp',
    // At least one of the CRUD methods is Required
    read: (req, resource, params, config, callback) => {

        if(resource === 'nlp.recommendedTags'){

            // TODO: request these params to be default in nlp-service
            let queryParams = 'performTitleBoost=true&titleBoostWithFixedFactor=-1&titleBoostlimitToFrequencyOfMostFrequentWord=true&minFrequencyOfTermOrEntityToBeConsidered=2&minCharLengthForTag=3&maxNumberOfWordsForNEsWhenNoLinkAvailable=4&maxEntriesToReturnTagRecommendation=20';
            let uri = `${Microservices.nlp.uri}/nlp/tagRecommendations/${params.selector.id}?${queryParams}`;
            rp.get({
                uri: uri,
                json: true,
            }).then((res) => {
                callback(null, {
                    selector: params.selector, 
                    recommendedTags: res
                });
            }).catch((err) => {
                callback(err);
            });
        }
    }
};

@@ -370,23 +370,176 @@
 let 
-queryParams = '
+uri = %60$%7BMicroservices.nlp.uri%7D/nlp/tagRecommendations/$%7Bparams.selector.id%7D%60;%0A            rp.get(%7B%0A                uri: uri,%0A                qs: %7B%0A                    
 perf
@@ -551,22 +551,45 @@
 tleBoost
-=
+: 
 true
-&
+, %0A                    
 titleBoo
@@ -609,12 +609,35 @@
 ctor
-=-1&
+: -1, %0A                    
 titl
@@ -680,14 +680,37 @@
 Word
-=
+: 
 true
-&
+, %0A                    
 minF
@@ -749,248 +749,324 @@
 ered
-=2&minCharLengthForTag=3&maxNumberOfWordsForNEsWhenNoLinkAvailable=4&maxEntriesToReturnTagRecommendation=20';%0A            let uri = %60$%7BMicroservices.nlp.uri%7D/nlp/tagRecommendations/$%7Bparams.selector.id%7D?$%7BqueryParams%7D%60;%0A            rp.get(%7B
+: 2, %0A                    applyMinFrequencyOfTermOnlyAfterTitleBoost: true, %0A                    minCharLengthForTag: 3, %0A                    maxNumberOfWordsForNEsWhenNoLinkAvailable: 4, %0A                    tfidfMinDocsToPerformLanguageDependent: 100, %0A                    maxEntriesToReturnTagRecommendation: 20, 
 %0A   
@@ -1074,32 +1074,25 @@
             
-uri: uri
+%7D
 ,%0A          

Fix nlp-service request for suggested tags