-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add entity functions for fuzzy match entity extraction. Closes #10.
- Loading branch information
1 parent
ad7e375
commit 5356230
Showing
12 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Licensed Materials - Property of IBM | ||
* (C) Copyright IBM Corp. 2016. All Rights Reserved. | ||
* US Government Users Restricted Rights - Use, duplication or | ||
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. | ||
*/ | ||
'use strict'; | ||
|
||
const cf = require('hubot-cf-convenience'); | ||
const ic = require('./ic'); | ||
const nlcconfig = require('hubot-ibmcloud-cognitive-lib').nlcconfig; | ||
|
||
const NAMESPACE = 'IBMcloudContainerManagment'; | ||
const PARAM_CONTAINERNAME = 'containername'; | ||
const PARAM_CONTAINERGROUPNAME = 'containergroupname'; | ||
|
||
var functionsRegistered = false; | ||
|
||
|
||
function buildGlobalName(parameterName) { | ||
return NAMESPACE + '_' + parameterName; | ||
} | ||
function buildGlobalFuncName(parameterName) { | ||
return NAMESPACE + '_func' + parameterName; | ||
} | ||
|
||
function registerEntityFunctions() { | ||
if (!functionsRegistered) { | ||
nlcconfig.setGlobalEntityFunction(buildGlobalFuncName(PARAM_CONTAINERNAME), getContainerNames); | ||
nlcconfig.setGlobalEntityFunction(buildGlobalFuncName(PARAM_CONTAINERGROUPNAME), getContainerGroupNames); | ||
functionsRegistered = true; | ||
} | ||
} | ||
|
||
function getContainerNames(robot, res, parameterName, parameters) { | ||
return new Promise(function(resolve, reject) { | ||
const spaceGuid = cf.activeSpace(robot, res).guid; | ||
ic.containers.getContainers(spaceGuid).then((result) => { | ||
let resultJson = JSON.parse(result); | ||
var containerNames = resultJson.map(function(container){ | ||
return container.Name; | ||
}); | ||
nlcconfig.updateGlobalParameterValues(buildGlobalName(PARAM_CONTAINERNAME), containerNames); | ||
resolve(containerNames); | ||
}).catch(function(err) { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
function getContainerGroupNames(robot, res, parameterName, parameters) { | ||
return new Promise(function(resolve, reject) { | ||
const spaceGuid = cf.activeSpace(robot, res).guid; | ||
const containerGroups = new ic.ContainerGroups(); | ||
containerGroups.getContainerGroups(spaceGuid).then((result) => { | ||
let resultJson = JSON.parse(result); | ||
var containerGroupNames = resultJson.map(function(containergroup){ | ||
return containergroup.Name; | ||
}); | ||
nlcconfig.updateGlobalParameterValues(buildGlobalName(PARAM_CONTAINERGROUPNAME), containerGroupNames); | ||
resolve(containerGroupNames); | ||
}).catch(function(err) { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports.registerEntityFunctions = registerEntityFunctions; | ||
module.exports.getContainerNames = getContainerNames; | ||
module.exports.getContainerGroupNames = getContainerGroupNames; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters