<commit_before>var cheerio = require('cheerio');
require('./parserUtil');

module.exports.parse = function(html, callback) {

    var $ = cheerio.load(html);

    var menu = [];
    var todayStr = global.todaysDate.format("D.M.YYYY");

    $('.daily-menu-for-day').each(function() {
        if ($(this).children("header").first().text().indexOf(todayStr) !== -1)
        {
            menu = parseMenu($(this));            
            return false;
        }
    });

    callback(menu);

    function parseMenu(elem) {
        var arr = [];
        var haveSoupAlready = false;

        elem.find('header.rm').each(function() {//Albatros puts soup in header
            var text = normalize($(this).children("h3").first().text());
            if(text === "")
                return;
            var priceMatch = /(\d+[\.,]\d+) ?€/.exec($(this).children(".price").first().text().replace(",", "."));
            var price = priceMatch ? parseFloat(priceMatch[1]) : NaN;
            arr.push({ isSoup: true, text: text, price: price });
            haveSoupAlready = true;
        });

        elem.find('li').each(function() {
            var text = normalize($(this).children(".name").first().text());
            var priceMatch = /(\d+[\.,]\d+) ?€/.exec($(this).children(".price").first().text().replace(",", "."));
            var price = priceMatch ? parseFloat(priceMatch[1]) : NaN;
            var isSoup = false;
            if(!haveSoupAlready && !/ menu/.test(text))
            {
                haveSoupAlready = true;
                isSoup = true;
            }
            arr.push({ isSoup: isSoup, text: text, price: price });
        });
        return arr;
    }

    function normalize(str) {
        return str.normalizeWhitespace()<commit_msg>Alfa soup fix<commit_after>var cheerio = require('cheerio');
require('./parserUtil');

module.exports.parse = function(html, callback) {

    var $ = cheerio.load(html);

    var menu = [];
    var todayStr = global.todaysDate.format("D.M.YYYY");

    $('.daily-menu-for-day').each(function() {
        if ($(this).children("header").first().text().indexOf(todayStr) !== -1)
        {
            menu = parseMenu($(this));            
            return false;
        }
    });

    callback(menu);

    function parseMenu(elem) {
        var arr = [];
        var haveSoupAlready = false;

        elem.find('header.rm').each(function() {//Albatros puts soup in header
            var text = normalize($(this).children("h3").first().text());
            if(text === "" || $(this).children('.price').text()==='')
                return;
            var priceMatch = /(\d+[\.,]\d+) ?€/.exec($(this).children(".price").first().text().replace(",", "."));
            var price = priceMatch ? parseFloat(priceMatch[1]) : NaN;
            arr.push({ isSoup: true, text: text, price: price });
            haveSoupAlready = true;
        });

        elem.find('li').each(function() {
            var text = normalize($(this).children(".name").first().text());
            var priceMatch = /(\d+[\.,]\d+) ?€/.exec($(this).children(".price").first().text().replace(",", "."));
            var price = priceMatch ? parseFloat(priceMatch[1]) : NaN;
            var isSoup = false;
            if(!haveSoupAlready && !/ menu/.test(text))
            {
                haveSoupAlready = true;
                isSoup = true;
            }
            arr.push({ isSoup: isSoup, text: text, price: price });
        });
        return arr;
    }

    function normalize(str) {
        return str.normalizeWhitespace()
{'fraction_non_alphanumeric': 0.19355742296918768, 'fraction_numerical': 0.002240896358543417, 'mean_word_length': 2.005892255892256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3470924', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1024, 'n_words': 190}