diff --git a/config/index.js b/config/index.js index fce97d5..a173ae5 100644 --- a/config/index.js +++ b/config/index.js @@ -16,8 +16,7 @@ config.scoreManager = { // similar-title-plugin pulls file.name from file and tasks[].name from tasks[] itself 'similar-file-title-task-title': { use: 'similar-context-plugin', - inputs: ['file.name', 'tasks[].name'], - params: { 'fileType': 'file.type' } + inputs: ['file.name', 'tasks[].name'] }, // timestamp comparison defaults to 600 sec 'context-file-timestamp-tasks-timestamp': { diff --git a/lib/plugins/similar-context-plugin.js b/lib/plugins/similar-context-plugin.js index 7448c2b..0de79de 100644 --- a/lib/plugins/similar-context-plugin.js +++ b/lib/plugins/similar-context-plugin.js @@ -7,24 +7,15 @@ const utils = require('../utils.js') * Returns a comparing score of two strings based on Dice's Coefficient using the stringSimilarity module. * * If param 'extractKeywords' is true: first uses the keyword-extractor to get the keywords, then compares the keywords with stringSimilarity to get a context score - - * Param 'fileType' by default false: - * No cutting of the file extension before the scoring - * - * If param 'fileType' is given as string: - * Cutting the file extension given by this param * * @param sString1 - first string for comparison * @param sString2 - second string for comparison * @param params - object with attribute: * 'extractKeywords' as parameter for extracting the keywords (true - extract keyword before calculating similarity score, false - whithout extraction) - * 'fileType' as parameter for the filetype of the file to cut the file extension */ function similarityPlugin (sString1, sString2, params) { let extractKeywords = (params && params['extractKeywords']) || false - let fileType = (params && params['fileType']) || false - if ((typeof sString1 === 'undefined') || (typeof sString2 === 'undefined')) { throw new Error(`Two Strings as input are needed.`) } @@ -32,11 +23,6 @@ function similarityPlugin (sString1, sString2, params) { utils.isValidString(sString1) utils.isValidString(sString2) - if (fileType !== false) { - sString1 = utils.basename(sString1, fileType) - sString2 = utils.basename(sString2, fileType) - } - if (typeof extractKeywords !== 'boolean') { throw new Error(`Boolean expected, found ${extractKeywords}`) } diff --git a/lib/utils.js b/lib/utils.js index 1a7ade2..15d080f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,15 +1,3 @@ -/** - * Returns the basename without extension of filename. If the filename does not - * contain any dots it will be returned as is, otherwise the extension is - * stripped and the basename is returned. - * - * @param filename - name of a file basename.ext - */ -function basename (filename, filetype) { - let typePosition = filename.lastIndexOf('.' + filetype) - return typePosition === -1 ? filename : filename.substring(0, typePosition) -} - /** * Returns a copy of the given object. The object must be serializable to * JSON, thus cloning will only work on primitive objects. @@ -63,4 +51,4 @@ function isTimestamp (timest) { } } -module.exports = { basename, cloneObject, isValidString, isInRange, isInteger, isTimestamp } +module.exports = { cloneObject, isValidString, isInRange, isInteger, isTimestamp } diff --git a/test/plugins/similar-context-test.js b/test/plugins/similar-context-test.js index 45aeddf..cf941d7 100644 --- a/test/plugins/similar-context-test.js +++ b/test/plugins/similar-context-test.js @@ -84,30 +84,18 @@ buster.testCase('similar-context-plugin', { }, 'should return 0.0 when there is no match at all ignoring the file extension': function () { - let file = { title: '123.jpeg' } + let file = { title: '123' } let task = { title: 'location' } - let fileType = { fileType: 'jpeg' } - let result = plugin(file.title, task.title, fileType) + let result = plugin(file.title, task.title) buster.assert.equals(result, 0.0) }, 'should return 1.0 when there is a total match ignoring the file extension': function () { - let file = { title: 'location.png' } + let file = { title: 'location' } let task = { title: 'location' } - let fileType = { fileType: 'png' } - let result = plugin(file.title, task.title, fileType) - buster.assert.equals(result, 1.0) - }, - - 'should return 1.0 when there is a total match ignoring the file extension': function () { - let file = { title: 'location.png' } - let task = { title: 'location' } - let fileType = { fileType: 'png' } - - let result = plugin(file.title, task.title, fileType) + let result = plugin(file.title, task.title) buster.assert.equals(result, 1.0) } - })