장준영

refactor : 프로젝트 최종 완성

[{"D:\\JJY\\4-2\\2015104216\\client\\src\\index.js":"1","D:\\JJY\\4-2\\2015104216\\client\\src\\App.js":"2","D:\\JJY\\4-2\\2015104216\\client\\src\\reportWebVitals.js":"3","D:\\JJY\\4-2\\2015104216\\client\\src\\components\\header\\header.jsx":"4","D:\\JJY\\4-2\\2015104216\\client\\src\\components\\inputBox\\inputBox.jsx":"5","D:\\JJY\\4-2\\2015104216\\client\\src\\components\\resultBox\\resultBox.jsx":"6"},{"size":500,"mtime":499162500000,"results":"7","hashOfConfig":"8"},{"size":546,"mtime":1607869406913,"results":"9","hashOfConfig":"8"},{"size":362,"mtime":499162500000,"results":"10","hashOfConfig":"8"},{"size":367,"mtime":1607866466638,"results":"11","hashOfConfig":"8"},{"size":655,"mtime":1607869355111,"results":"12","hashOfConfig":"8"},{"size":869,"mtime":1607872379349,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},"1f1vq1t",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"D:\\JJY\\4-2\\2015104216\\client\\src\\index.js",[],["27","28"],"D:\\JJY\\4-2\\2015104216\\client\\src\\App.js",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\reportWebVitals.js",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\components\\header\\header.jsx",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\components\\inputBox\\inputBox.jsx",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\components\\resultBox\\resultBox.jsx",[],{"ruleId":"29","replacedBy":"30"},{"ruleId":"31","replacedBy":"32"},"no-native-reassign",["33"],"no-negated-in-lhs",["34"],"no-global-assign","no-unsafe-negation"]
\ No newline at end of file
[{"D:\\JJY\\4-2\\2015104216\\client\\src\\index.js":"1","D:\\JJY\\4-2\\2015104216\\client\\src\\App.js":"2","D:\\JJY\\4-2\\2015104216\\client\\src\\reportWebVitals.js":"3","D:\\JJY\\4-2\\2015104216\\client\\src\\components\\header\\header.jsx":"4","D:\\JJY\\4-2\\2015104216\\client\\src\\components\\inputBox\\inputBox.jsx":"5","D:\\JJY\\4-2\\2015104216\\client\\src\\components\\resultBox\\resultBox.jsx":"6"},{"size":500,"mtime":499162500000,"results":"7","hashOfConfig":"8"},{"size":546,"mtime":1607869406913,"results":"9","hashOfConfig":"8"},{"size":362,"mtime":499162500000,"results":"10","hashOfConfig":"8"},{"size":367,"mtime":1607866466638,"results":"11","hashOfConfig":"8"},{"size":655,"mtime":1607869355111,"results":"12","hashOfConfig":"8"},{"size":869,"mtime":1607872379349,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},"1f1vq1t",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"27"},"D:\\JJY\\4-2\\2015104216\\client\\src\\index.js",[],["28","29"],"D:\\JJY\\4-2\\2015104216\\client\\src\\App.js",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\reportWebVitals.js",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\components\\header\\header.jsx",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\components\\inputBox\\inputBox.jsx",[],"D:\\JJY\\4-2\\2015104216\\client\\src\\components\\resultBox\\resultBox.jsx",[],["30","31"],{"ruleId":"32","replacedBy":"33"},{"ruleId":"34","replacedBy":"35"},{"ruleId":"32","replacedBy":"36"},{"ruleId":"34","replacedBy":"37"},"no-native-reassign",["38"],"no-negated-in-lhs",["39"],["38"],["39"],"no-global-assign","no-unsafe-negation"]
\ No newline at end of file
......
......@@ -5,24 +5,33 @@ const db = require('../model/db');
const {calcDistance} = require('../service/calcDistance');
const {getProfanity} = require('../service/query');
const {standardize, removeSpecial} = require('../service/standardization');
const Hangul = require('hangul-js');
exports.calcDistance = async (req, res, next) => {
const { word } = req.body;
const profanityList = await getProfanity();
let rare = word;
let specialRemoved = removeSpecial(word);
let specialRemovedRare = specialRemoved;
let specialNotRemoved = word;
rare = Hangul.disassemble(rare);
rare = rare.join('');
specialRemovedRare = Hangul.disassemble(specialRemovedRare);
specialRemovedRare = specialRemovedRare.join('');
specialRemoved = standardize(specialRemoved);
specialNotRemoved = standardize(specialNotRemoved);
const rareResult = calcDistance(word, profanityList);
const rareResult = calcDistance(rare, profanityList);
const specialRemovedRareResult = calcDistance(specialRemovedRare, profanityList);
const specialRemovedResult = calcDistance(specialRemoved, profanityList);
const specialNotRemovedResult = calcDistance(specialNotRemoved, profanityList);
const minResult = Math.min(rareResult, specialRemovedResult, specialNotRemovedResult);
const minResult = Math.min(rareResult, specialRemovedRareResult, specialRemovedResult, specialNotRemovedResult);
if (minResult <= 1){
res.status(200).json({success : true, isProfanity : "욕설"});
......