From acac35037bd54349e86676990434b41f5c119424 Mon Sep 17 00:00:00 2001 From: potados99 Date: Sun, 14 Nov 2021 02:38:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8B=9D=EB=8B=A8=20=ED=8F=AC=EB=A7=B7?= =?UTF-8?q?=20=EA=B7=9C=EA=B2=A9=EC=9D=84=20=EC=A4=80=EC=88=98=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EB=AA=BB=ED=95=98=EB=8A=94=20=EC=A0=95=EA=B7=9C?= =?UTF-8?q?=ED=91=9C=ED=98=84=EC=8B=9D=20=EC=88=98=EC=A0=95:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기타 정보는 * 1개 이상 + 0개 이상의 공백 문자로 시작하는 줄에만 해당하도록 함 --- .../menu/parser/stage2/MenuTokenizer.spec.ts | 34 +++++++++++++++++++ .../menu/parser/stage2/helper/Extractor.ts | 8 ++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/lib/application/menu/parser/stage2/MenuTokenizer.spec.ts b/lib/application/menu/parser/stage2/MenuTokenizer.spec.ts index 3a7e9918..5ec96d74 100644 --- a/lib/application/menu/parser/stage2/MenuTokenizer.spec.ts +++ b/lib/application/menu/parser/stage2/MenuTokenizer.spec.ts @@ -40,4 +40,38 @@ describe('새로 바뀐 메뉴 파싱', () => { console.log(result); }); + + it('2021-11-15 학생식당 중식(일품)의 일부', async () => { + const raw = + '양파크리미돈까스\n' + + '시찌미주먹밥\n' + + '모닝빵*딸기잼\n' + + '오이피클\n' + + '우동국물\n' + + '\n' + + '4,000원670kcal\n' + + '\n' + + '*11:30~소진시'; + + const result = parse(raw); + + console.log(result); + }); + + it('엑스트라에 별 여러개와 공백 여러개', async () => { + const raw = + '양파크리미돈까스\n' + + '시찌미주먹밥\n' + + '모닝빵*딸기잼\n' + + '오이피클\n' + + '우동국물\n' + + '\n' + + '4,000원670kcal\n' + + '\n' + + '**** 11:30~소진시'; + + const result = parse(raw); + + console.log(result); + }); }); diff --git a/lib/application/menu/parser/stage2/helper/Extractor.ts b/lib/application/menu/parser/stage2/helper/Extractor.ts index 1c17f48a..ad968335 100644 --- a/lib/application/menu/parser/stage2/helper/Extractor.ts +++ b/lib/application/menu/parser/stage2/helper/Extractor.ts @@ -26,10 +26,10 @@ import LineClassifier, {RegexResult} from './LineClassifier'; */ export default class Extractor { private classifiers = { - extras: new LineClassifier(/\*(?.+)/), - foods: new LineClassifier(/(?.+)/), - prices: new LineClassifier(/(?[0-9,]+)원/), - calories: new LineClassifier(/(?[0-9,]+)[Kk]cal/), + extras: new LineClassifier(/^\*+\s*(?.+)$/), + foods: new LineClassifier(/^(?.+)$/), + prices: new LineClassifier(/^(?[0-9,]+)원$/), + calories: new LineClassifier(/^(?[0-9,]+)[Kk]cal$/), }; constructor(private readonly text: string) {