diff --git a/.yarnclean b/.yarnclean new file mode 100644 index 0000000..b591611 --- /dev/null +++ b/.yarnclean @@ -0,0 +1,45 @@ +# test directories +__tests__ +test +tests +powered-test + +# asset directories +docs +doc +website +images +assets + +# examples +example +examples + +# code coverage directories +coverage +.nyc_output + +# build scripts +Makefile +Gulpfile.js +Gruntfile.js + +# configs +appveyor.yml +circle.yml +codeship-services.yml +codeship-steps.yml +wercker.yml +.tern-project +.gitattributes +.editorconfig +.*ignore +.eslintrc +.jshintrc +.flowconfig +.documentup.json +.yarn-metadata.json +.travis.yml + +# misc +*.md diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 436d00a..f63b79a 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -102,4 +102,5 @@ export const getRecentlyImportedComicBooks = (options) => async (dispatch) => { export const fetchComicVineMatches = (searchPayload, options) => (dispatch) => { console.log(searchPayload); + tokenize(searchPayload); }; diff --git a/src/client/shared/utils/nlp.utils.ts b/src/client/shared/utils/nlp.utils.ts index db31cde..f7b5248 100644 --- a/src/client/shared/utils/nlp.utils.ts +++ b/src/client/shared/utils/nlp.utils.ts @@ -13,15 +13,36 @@ nlp.extend(dates); * @function * @param {string} inputString - The string used to search against CV, Shortboxed, and other APIs. */ -export const tokenize = (inputString) => { +export const tokenize = (searchCriteriaPayload) => { + const { inputString } = searchCriteriaPayload; const doc = nlp(inputString); const sentence = doc.sentences().json(); const number = doc.numbers().fractions(); + + // regexes to match constituent parts of the search string + // and isolate the search terms const chapters = inputString.match(/ch(a?p?t?e?r?)(\W?)(\_?)(\#?)(\d)/gi); - const volumes = inputString.match(/v(o?l?u?m?e?)(\W?)(\_?)(\s?)(\d+)/gi); + const volumes = inputString.match( + /(\b(vo?l?u?m?e?)\.?)(\s*-|\s*_)?(\s*[0-9]+[.0-9a-z]*)/gi, + ); + const pageCounts = inputString.match( + /\b[.,]?\s*\d+\s*(p|pg|pgs|pages)\b\s*/gi, + ); + + const parantheses = inputString.match(/\([^\(]*?\)/gi); + const curlyBraces = inputString.match(/\{[^\{]*?\}/gi); + const squareBrackets = inputString.match(/\[[^\[]*?\]/gi); + const genericNumericRange = inputString.match( + /([^\d]+)(\s*(of|de|di|von|van|z)\s*#*\d+)/gi, + ); + const hyphenatedNumericRange = inputString.match(/([^\d])?(-\d+)/gi); + const readingListIndicators = inputString.match( + /^\s*\d+(\.\s+?|\s*-?\s*)/gim, + ); + const issues = inputString.match(/issue(\W?)(\_?)(\d+)/gi); const issueHashes = inputString.match(/\#\d/gi); - const yearMatches = inputString.match(/\d{4}/g); + const yearMatches = inputString.match(/\d{4}/gi); const sentenceToProcess = sentence[0].normal.replace(/_/g, " "); const normalizedSentence = nlp(sentenceToProcess) diff --git a/yarn.lock b/yarn.lock index b905003..3837762 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12339,7 +12339,7 @@ text-table@^0.2.0, text-table@~0.2.0: threetwo-ui-typings@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/threetwo-ui-typings/-/threetwo-ui-typings-1.0.1.tgz#5e1c4aca9342e1655ef471fe2e50752bb844b788" + resolved "https://registry.npmjs.org/threetwo-ui-typings/-/threetwo-ui-typings-1.0.1.tgz" integrity sha512-g5FWa069AT1WfUHHEVFOQ1q6cfK+9UOzewfKblheuDBSsGN/e89MJMEVfuInBaHgxHM32/P+mNUFBqnBoeRSLQ== dependencies: typescript "^4.3.2"