Skip to content
This repository has been archived by the owner on Jul 20, 2019. It is now read-only.

Commit

Permalink
Add feature switcher (#61)
Browse files Browse the repository at this point in the history
* Add feature switcher

* Still can't use Object.values with phantomjs

* Change structure of questions for feature switching

* Change collection names + constants structure to match features

* Update data upload README and upgrade pip

* Change from RELEVANCY to TRAINED

* Add TrainingContainer, pull out reused components, cleanup naming

* Save training question annotation for later

* Fix python flake8 style issues

* Fix python tests

* Fix up unit tests for relevancy switcher addition

* Add training container tests

* Rename total_questions to question_count

* Add polyfill for findIndex for phantomjs

* Update credentials

* Add wait in integration tests

* Fix comments

* Update README for passages collection

* Rename parameters passed to server
  • Loading branch information
maniax89 committed Aug 31, 2017
1 parent fab1825 commit 34203fa
Show file tree
Hide file tree
Showing 50 changed files with 1,582 additions and 492 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
DISCOVERY_URL=https://gateway.watsonplatform.net/discovery/api
DISCOVERY_USERNAME=
DISCOVERY_PASSWORD=
DISCOVERY_PASSAGES_COLLECTION_NAME=knowledge_base_regular
DISCOVERY_REGULAR_COLLECTION_NAME=knowledge_base_regular
DISCOVERY_ENRICHED_COLLECTION_NAME=knowledge_base_enriched
DISCOVERY_TRAINED_COLLECTION_NAME=knowledge_base_trained
DISCOVERY_QUESTION_COUNT=5000

#NATURAL LANGUAGE UNDERSTANDING (NLU) Credentials
Expand Down
Binary file modified .env.staging.enc
Binary file not shown.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ You may use the [Watson Discovery Tooling](https://discovery-tooling.mybluemix.n

Or if you prefer using python scripts aided by markdown-formatted explanation (known as [Jupyter Notebooks](http://jupyter.readthedocs.io/en/latest/index.html)), you can use the steps found in `notebooks/Setup_Discovery.ipynb` of this repo. The `notebook` section can be run locally by doing `pip install -r server/requirements/dev.txt` followed by `jupyter notebook` which will prompt you to open your browser to follow the steps in the interactive code guide. Each script can be run independently as each step is located in the `notebooks/scripts` directory.

1. Create 2 collections in the Watson Discovery Service. Make sure to store the names in the `.env` file and add them to the environment variables in your deployment configuration. By default, they are set to:
1. Create 2 collections in the Watson Discovery Service. Make sure to store the names in the `.env` file and add them to the environment variables in your deployment configuration. In case you want a different collection for the passage search feature, you may provide one (otherwise it is the same as the "regular" collection). By default, they are set to:
```
DISCOVERY_PASSAGES_COLLECTION_NAME=knowledge_base_regular
DISCOVERY_REGULAR_COLLECTION_NAME=knowledge_base_regular
DISCOVERY_ENRICHED_COLLECTION_NAME=knowledge_base_enriched
DISCOVERY_TRAINED_COLLECTION_NAME=knowledge_base_trained
```
1. Upload sample documents to the collections you created by dragging and dropping files from the `data/sample` directory into each collection created in the Watson Discovery Tooling UI

Expand Down
2 changes: 2 additions & 0 deletions client/knowledge_base_search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"classnames": "^2.2.5",
"node-sass-chokidar": "0.0.3",
"prop-types": "^15.5.10",
"react": "15.6.0",
Expand All @@ -22,6 +23,7 @@
"enzyme": "^2.8.2",
"npm-run-all": "^4.1.1",
"phantomjs-polyfill-find": "0.0.1",
"phantomjs-polyfill-find-index": "^1.0.1",
"react-scripts": "0.9.5",
"react-test-renderer": "^15.5.4"
},
Expand Down
46 changes: 28 additions & 18 deletions client/knowledge_base_search/spec/scenarios/home_page.itest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,40 @@ casper.test.begin('Knowledge Base Search', (test) => {
});

casper.then(() => {
test.assertElementCount(
'.question_bar_button--button',
4,
'4 Preset Questions shown on initial load'
);
casper.click('.question_bar_button--button:first-child');
casper.capture(`${casper.screenshots_dir}/search_clicked.png`);

casper.waitForSelector('.result_container--div',
casper.waitForSelector('.question_bar_button--button',
() => {
// wait for transition
casper.wait(5000, () => {
casper.capture(`${casper.screenshots_dir}/results_exist.png`);
test.assertElementCount(
'.result_container--div',
6,
'6 Results exist when a search is clicked');
});
casper.capture(`${casper.screenshots_dir}/questions_exist.png`);
test.assertElementCount(
'.question_bar_button--button',
4,
'4 Preset Questions shown on initial load'
);
casper.click('.question_bar_button--button:first-child');
casper.capture(`${casper.screenshots_dir}/search_clicked.png`);

casper.waitForSelector('.result_container--div',
() => {
// wait for transition
casper.wait(5000, () => {
casper.capture(`${casper.screenshots_dir}/results_exist.png`);
test.assertElementCount(
'.result_container--div',
6,
'6 Passage results exist when a search is clicked');
});
},
() => {
casper.capture(`${casper.screenshots_dir}/results_failure.png`);
test.fail();
}
);
},
() => {
casper.capture(`${casper.screenshots_dir}/results_failure.png`);
casper.capture(`${casper.screenshots_dir}/questions_failure.png`);
test.fail();
}
);

});

casper.run(() => {
Expand Down
2 changes: 2 additions & 0 deletions client/knowledge_base_search/spec/support/setup_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ casper.options.logLevel = 'error';
casper.options.waitTimeout = 10000;
// add array.find polyfill
casper.options.clientScripts.push('./node_modules/phantomjs-polyfill-find/find-polyfill.js');
// add array.findIndex polyfill
casper.options.clientScripts.push('./node_modules/phantomjs-polyfill-find-index/findIndex-polyfill.js');

casper.test.setUp((done) => {
let server = spawn('python', [ '../../server/python/server.py' ]);
Expand Down
Loading

0 comments on commit 34203fa

Please sign in to comment.