Skip to content

Commit

Permalink
fix: 식단 포맷 규격을 준수하지 못하는 정규표현식 수정:
Browse files Browse the repository at this point in the history
기타 정보는 * 1개 이상 + 0개 이상의 공백 문자로 시작하는 줄에만 해당하도록 함
  • Loading branch information
potados99 committed Nov 13, 2021
1 parent b321aa6 commit acac350
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
34 changes: 34 additions & 0 deletions lib/application/menu/parser/stage2/MenuTokenizer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
8 changes: 4 additions & 4 deletions lib/application/menu/parser/stage2/helper/Extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import LineClassifier, {RegexResult} from './LineClassifier';
*/
export default class Extractor {
private classifiers = {
extras: new LineClassifier(/\*(?<EXTRA>.+)/),
foods: new LineClassifier(/(?<FOOD>.+)/),
prices: new LineClassifier(/(?<PRICE>[0-9,]+)원/),
calories: new LineClassifier(/(?<CALORIE>[0-9,]+)[Kk]cal/),
extras: new LineClassifier(/^\*+\s*(?<EXTRA>.+)$/),
foods: new LineClassifier(/^(?<FOOD>.+)$/),
prices: new LineClassifier(/^(?<PRICE>[0-9,]+)원$/),
calories: new LineClassifier(/^(?<CALORIE>[0-9,]+)[Kk]cal$/),
};

constructor(private readonly text: string) {
Expand Down

0 comments on commit acac350

Please sign in to comment.