Showing
2 changed files
with
14 additions
and
5 deletions
1 | -[{"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 | ... | \ No newline at end of file |
1 | +[{"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 | ... | \ No newline at end of file | ... | ... |
... | @@ -5,24 +5,33 @@ const db = require('../model/db'); | ... | @@ -5,24 +5,33 @@ const db = require('../model/db'); |
5 | const {calcDistance} = require('../service/calcDistance'); | 5 | const {calcDistance} = require('../service/calcDistance'); |
6 | const {getProfanity} = require('../service/query'); | 6 | const {getProfanity} = require('../service/query'); |
7 | const {standardize, removeSpecial} = require('../service/standardization'); | 7 | const {standardize, removeSpecial} = require('../service/standardization'); |
8 | - | 8 | +const Hangul = require('hangul-js'); |
9 | 9 | ||
10 | exports.calcDistance = async (req, res, next) => { | 10 | exports.calcDistance = async (req, res, next) => { |
11 | const { word } = req.body; | 11 | const { word } = req.body; |
12 | 12 | ||
13 | const profanityList = await getProfanity(); | 13 | const profanityList = await getProfanity(); |
14 | - | 14 | + |
15 | + let rare = word; | ||
15 | let specialRemoved = removeSpecial(word); | 16 | let specialRemoved = removeSpecial(word); |
17 | + let specialRemovedRare = specialRemoved; | ||
16 | let specialNotRemoved = word; | 18 | let specialNotRemoved = word; |
19 | + | ||
20 | + rare = Hangul.disassemble(rare); | ||
21 | + rare = rare.join(''); | ||
17 | 22 | ||
23 | + specialRemovedRare = Hangul.disassemble(specialRemovedRare); | ||
24 | + specialRemovedRare = specialRemovedRare.join(''); | ||
25 | + | ||
18 | specialRemoved = standardize(specialRemoved); | 26 | specialRemoved = standardize(specialRemoved); |
19 | specialNotRemoved = standardize(specialNotRemoved); | 27 | specialNotRemoved = standardize(specialNotRemoved); |
20 | 28 | ||
21 | - const rareResult = calcDistance(word, profanityList); | 29 | + const rareResult = calcDistance(rare, profanityList); |
30 | + const specialRemovedRareResult = calcDistance(specialRemovedRare, profanityList); | ||
22 | const specialRemovedResult = calcDistance(specialRemoved, profanityList); | 31 | const specialRemovedResult = calcDistance(specialRemoved, profanityList); |
23 | const specialNotRemovedResult = calcDistance(specialNotRemoved, profanityList); | 32 | const specialNotRemovedResult = calcDistance(specialNotRemoved, profanityList); |
24 | 33 | ||
25 | - const minResult = Math.min(rareResult, specialRemovedResult, specialNotRemovedResult); | 34 | + const minResult = Math.min(rareResult, specialRemovedRareResult, specialRemovedResult, specialNotRemovedResult); |
26 | 35 | ||
27 | if (minResult <= 1){ | 36 | if (minResult <= 1){ |
28 | res.status(200).json({success : true, isProfanity : "욕설"}); | 37 | res.status(200).json({success : true, isProfanity : "욕설"}); | ... | ... |
-
Please register or login to post a comment