Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d03eaec
Renamed Profile to Procfile
Apr 7, 2017
aee1c1a
Adds more screenshot for wiki
Apr 7, 2017
3700ef6
Added test to coverall all files search and refactored class Inverted…
Apr 8, 2017
df12b74
Refactored the Inverted index class by removing unwanted part of the …
Apr 8, 2017
4f60e10
Updated the README file to include thelink to wiki
Apr 9, 2017
532e8ac
Adds codeclimate configuration file and modifies the application home…
Apr 9, 2017
d3f1837
Remove the default Procfile and App.json so the app can use the defau…
Apr 10, 2017
c759871
Updates the server.js to serve the index.html
Apr 10, 2017
d36cd89
Modified the server.js tp serve the javascript file
Apr 10, 2017
4d2a824
Modifies codeclimate configuration file
Apr 10, 2017
cc1d6d4
Updated codeclimate configuration file
Apr 10, 2017
741c47e
Updates the codeclimate config file to exclude images and jasmine dep…
Apr 10, 2017
816e73b
Adds test for words not found in search index and heroku app.json con…
Apr 10, 2017
d35e282
Modifies houndci configurations
Apr 10, 2017
d2ade4d
Renamed the eslint configuration file and modified the houndci config…
Apr 10, 2017
620a020
Adds test specs and inverted index class modified to correct houndci'…
Apr 10, 2017
20a1e60
renamed invertedindex.js to InvertedIndex.js using Pascal case and mo…
Apr 12, 2017
63f7b74
Corrected JSDOC comment for readfile method
Apr 12, 2017
a448fd7
Created bundle using browserify and modifies gulp to build on start
Apr 13, 2017
502afb9
Updates eslint config file, added browserify to bundle application, m…
Apr 13, 2017
77ba367
Refactored InvertedIndex class
Apr 15, 2017
226e490
Updates the JSDOC of the InvertedIndex class file
Apr 15, 2017
bb870c8
Refactored InvertedIndex class by modifying variable names
Apr 15, 2017
3693d9c
Modified the jasmine configuration file, changed the test specs filename
Apr 15, 2017
f440817
Modifies the eslint ignore config file
Apr 15, 2017
c6c7d88
Modifies InvertedIndex class and test spec to include changes like te…
Apr 17, 2017
de2d505
Modified InvertedIndex class and InvertedIndex test specs
Apr 17, 2017
b8b0720
Modifies InvertedIndex class
Apr 17, 2017
c128075
Modifies the InvertedIndex test spec
Apr 17, 2017
7011454
Updates InvertedIndex class and InvertedIndex test spec
Apr 18, 2017
0fd96e3
Controls table overflow, Corrects typo errors in test specs, includes…
Apr 18, 2017
435916b
updates coverall badge
Apr 18, 2017
b10f134
updated the readme file to reflect the new badge
Apr 18, 2017
6fca590
Updated the coverall badge
Apr 18, 2017
d586adf
Updates the InvertedIndex test spec
Apr 19, 2017
c3dc52b
Added InvertedIndex test spec
Apr 19, 2017
cc14b1e
Updated the test spec
Apr 19, 2017
3ed238c
Updated the InvertedIndex class test spec
Apr 19, 2017
8414503
Adds more sample books and modifies the InvertedIndex test spec
Apr 19, 2017
dd07287
Added Procfile and modified gitignore
Apr 19, 2017
f669ede
Added profile
Apr 19, 2017
9e83c02
Restructured files to correct heroku's application errors
Apr 19, 2017
b505061
Updated the index.html file
Apr 19, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
47 changes: 47 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
engines:
eslint:
enabled: true
duplication:
enabled: true
config:
languages:
- javascript
csslint:
enabled: false
# ... CONFIG CONTENT ...
checks:
comma-dangle:
enabled: false
import/no-unresolved:
enabled: false
no-console:
enabled: false
strict:
enabled: false
no-unused-vars:
enabled: false
no-undef:
enabled: false
class-methods-use-this:
enabled: false
no-param-reassign:
enabled: false
array-callback-return:
enabled: false
fixme:
enabled: true
ratings:
paths:
- "src/invertedindex.js"
exclude_paths:
- "samples/*"
- "*.json"
- "src/app.js"
- "src/module.js"
- "css/*"
- "index.html"
- "specs/*"
- .travis.yml
- .eslintrc.json
- "spec/*"
- "images/*"
File renamed without changes.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ It can also be used locally by following the steps below
- The application can not be distinguished between plural and singular words. It also does not distinguish between the past tense form of a verb. It does not identify synonyms and sees numbers as string

## More information
- [DPlex Wiki](https://github.com/andela-aonifade/dplex/wiki)
- [Inverted Index - Wikipedia](https://en.wikipedia.org/wiki/Inverted_index)
- [Inverted Index](https://www.elastic.co/guide/en/elasticsearch/guide/current/inverted-index.html)
Binary file added images/empty_text_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/search_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- Latest compiled and minified JavaScript -->
<link rel="stylesheet" href="https://bootswatch.com/darkly/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/angular-toastr/dist/angular-toastr.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="css/style.css">
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ const connect = require('connect');
const serveStatic = require('serve-static');

const port = process.env.PORT || 3000;
connect().use(serveStatic('./src')).listen(port);
connect().use(serveStatic('./')).listen(port);
24 changes: 23 additions & 1 deletion spec/dplex-test-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

describe('InvertedIndex class', () => {
beforeEach(() => {
beforeAll(() => {
this.indexInstance = new InvertedIndex();
this.validBook = [{ title: 'Welcome to Test Environment',
text: 'Enjoy this file' }];
Expand Down Expand Up @@ -100,6 +100,10 @@ describe('InvertedIndex class', () => {
const term = { t1: 'Welcome home', text: 'This is really home' };
expect(this.indexInstance.createIndex(term, 'term')).toBeFalsy();
});
it('should return false for file with no content', () => {
const term = {};
expect(this.indexInstance.createIndex(term, 'term')).toBeFalsy();
});
});
describe('Search Index', () => {
it('should search through single files that are indexed', () => {
Expand All @@ -118,6 +122,24 @@ describe('InvertedIndex class', () => {
expect(this.indexInstance.searchIndex(term, 'books'))
.toBeFalsy();
});
it('should return an empty object for an words not found', () => {
const term = 'Aeroplane';
const expectedOutput = this.indexInstance.searchIndex(term, 'books');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple spaces found before 'this' no-multi-spaces

expect(expectedOutput[0].indexes).toEqual({ });
});
it('should return an array of objects if filename is all', () => {
const books1 = [{title: 'Alice in Wonderland too',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required after '{' object-curly-spacing

text: 'Alice adventure in the wonderland was full of drama and action'}];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

this.indexInstance.createIndex(books, 'books');
this.indexInstance.createIndex(books1, 'books1');
const expectedOutput = [{ indexes: { alice: [0], wonderland: [0] },
searchedFile: 'books',
documents: [0, 1, 2] },
{ indexes: { alice: [0], wonderland: [0] },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 6 spaces but found 8 indent

searchedFile: 'books1',
documents: [0] }];
expect(this.indexInstance.searchIndex('Alice Wonderland', 'all')).toEqual(expectedOutput);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 6 spaces but found 8 indent

});
});

describe('Tokenize words', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/invertedindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let instance = null;
/**
* @class InvertedIndex class
* Contains methods for InvertedIndex
* Only allows single instance of the object to be created
*/
class InvertedIndex {
/**
Expand Down Expand Up @@ -72,7 +73,7 @@ class InvertedIndex {
let documentNum = 0;
try {
if (Object.keys(inputData).length < 1) {
this.handleError(filename, 'File contains no document', true);
this.handleError(filename, 'File contains no document', true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces not allowed no-trailing-spaces

}
Object.keys(inputData).forEach((eachIndex) => {
if (!this.validateFile(inputData[eachIndex])) {
Expand All @@ -84,6 +85,7 @@ class InvertedIndex {
this.filesIndexed[filename].numOfDocs = documentNum;
this.filesIndexed[filename].index = this.constructIndex(words);
return true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces not allowed no-trailing-spaces

} catch (err) {
if (this.error.status) {
return false;
Expand Down Expand Up @@ -178,7 +180,6 @@ class InvertedIndex {
*/
searchIndex(searchTerm, filename) {
if ((typeof searchTerm === 'string' && searchTerm.trim() === '') ||
(typeof searchTerm === 'object' && searchTerm.length === 0) ||
searchTerm === undefined) {
return false;
}
Expand Down
File renamed without changes.