💬 Adding regexes for string matching
This commit is contained in:
45
.yarnclean
Normal file
45
.yarnclean
Normal file
@@ -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
|
||||
@@ -102,4 +102,5 @@ export const getRecentlyImportedComicBooks = (options) => async (dispatch) => {
|
||||
|
||||
export const fetchComicVineMatches = (searchPayload, options) => (dispatch) => {
|
||||
console.log(searchPayload);
|
||||
tokenize(searchPayload);
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user