First commit

This commit is contained in:
2021-04-15 15:08:54 -07:00
commit 2ccebf13b8
39 changed files with 26887 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
export interface IFolderResponse {
data: Array<IFolderData>;
}
export interface IComicVineSearchMatch {
description: string;
id: number;
volumes: string;
}
export interface IFolderData {
name: string;
extension: string;
containedIn: string;
isFile: boolean;
isLink: boolean;
}

View File

@@ -0,0 +1,19 @@
import axios from "axios";
import { IFolderData } from "../interfaces/comicinfo.interfaces";
import { FOLDERUTIL_URI } from "../../constants/endpoints";
export async function folderWalk(): Promise<Array<IFolderData>> {
return axios
.request<Array<IFolderData>>({
url: FOLDERUTIL_URI,
transformResponse: (r: string) => JSON.parse(r),
})
.then((response) => {
const { data } = response;
return data;
});
}
export async function foo() {
return { as: "af" };
}

View File

@@ -0,0 +1,57 @@
import { default as nlp } from "compromise";
import { default as dates } from "compromise-dates";
import { default as sentences } from "compromise-sentences";
import { default as numbers } from "compromise-numbers";
import _ from "lodash";
nlp.extend(sentences);
nlp.extend(numbers);
nlp.extend(dates);
export function tokenize(inputString) {
const doc = nlp(inputString);
const sentence = doc.sentences().json();
const number = doc.numbers().fractions();
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 issues = inputString.match(/issue(\W?)(\_?)(\d+)/gi);
const issueHashes = inputString.match(/\#\d/gi);
const yearMatches = inputString.match(/\d{4}/g);
const sentenceToProcess = sentence[0].normal.replace(/_/g, " ");
const normalizedSentence = nlp(sentenceToProcess)
.text("normal")
.trim()
.split(" ");
const queryObject = {
comicbook_identifiers: {
issues,
issueHashes,
chapters,
volumes,
issueRanges: number,
},
years: {
yearMatches,
},
sentences: {
detailed: sentence,
normalized: normalizedSentence,
},
};
return queryObject;
}
export function refineQuery(queryString) {
let queryObj = tokenize(queryString);
let removedYears = _.xor(
queryObj.sentences.normalized,
queryObj.years.yearMatches,
);
return {
tokenized: removedYears,
normalized: removedYears.join(" "),
meta: queryObj,
};
}

View File

@@ -0,0 +1,35 @@
/*
MIT License
Copyright (c) 2021 Rishi Ghan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import _ from "lodash";
import { IFolderData } from "../interfaces/comicinfo.interfaces";
import stringSimilarity from "string-similarity";
import { logger } from "../utils/log.utils";
export const autoMatcher = (query, matches) => {
}