<commit_before>import { Component, EventEmitter, Output } from "@angular/core";

import { ConfigurationService } from "../configuration.service";
import { I18nService } from "../i18n.service";
import { GastroQuery } from "../model/gastro-query";
import { GastroTag, getGastroTags } from "../model/gastro-tag";
import { ShoppingQuery } from "../model/shopping-query";
import { ShoppingTag, getShoppingTags } from "../model/shopping-tag";
import { getVeganCategories } from "../model/vegan-category";

@Component({
    selector: "app-search",
    templateUrl: "./search.component.html",
    styleUrls: [ "./search.component.scss" ],
})
export class SearchComponent {

    constructor(
        readonly configurationService: ConfigurationService,
        private readonly i18nService: I18nService,
    ) { }

    @Output() readonly queryChange = new EventEmitter<GastroQuery | ShoppingQuery>();
    @Output() readonly coordinatesHighlightRequest = new EventEmitter<void>();

    readonly i18n = this.i18nService.getI18n();
    readonly veganCategories = getVeganCategories();
    tags: (GastroTag | ShoppingTag)[];
    query: GastroQuery | ShoppingQuery;
    isGastro: boolean;

    init(query: GastroQuery | ShoppingQuery) {
        if (query instanceof GastroQuery) {
            this.tags = getGastroTags();
            this.isGastro = true;
        } else {
            this.tags = getShoppingTags();
            this.isGastro = false;
        }
        this.query = query;
    }

    onQueryChange() {
        this.queryChange.emit(this.query);
    }

    onCoordinatesChange(coordinates: Coordinates | null) {
        if (!coordinates) {
            this.query.distance.enabled = false;
        }
        this.query.distance.coordinates = coordinates;
        this.queryChange.emit(this.query);
    }

    getFeatureList1(): string[] {
        return this.isGastro ?
            ["organic", "breakfast", "dog", "handicappedAccessible", "delivery", "wlan"]
            :
            ["organic", "handicappedAccessible", "delivery"];
    }

    getFeatureList2(): string[] {
        return this.isGastro ?
            ["glutenFree", "brunch", "childChair", "handicappedAccessibleWc", "catering", "review"]
            :
            ["review"];
    }
}
<commit_msg>Refactoring<commit_after>import { Component, EventEmitter, Output } from "@angular/core";

import { ConfigurationService } from "../configuration.service";
import { I18nService } from "../i18n.service";
import { GastroQuery } from "../model/gastro-query";
import { GastroTag, getGastroTags } from "../model/gastro-tag";
import { ShoppingQuery } from "../model/shopping-query";
import { ShoppingTag, getShoppingTags } from "../model/shopping-tag";
import { getVeganCategories } from "../model/vegan-category";

@Component({
    selector: "app-search",
    templateUrl: "./search.component.html",
    styleUrls: [ "./search.component.scss" ],
})
export class SearchComponent {

    constructor(
        readonly configurationService: ConfigurationService,
        private readonly i18nService: I18nService,
    ) { }

    @Output() readonly queryChange = new EventEmitter<GastroQuery | ShoppingQuery>();
    @Output() readonly coordinatesHighlightRequest = new EventEmitter<void>();

    readonly i18n = this.i18nService.getI18n();
    readonly veganCategories = getVeganCategories();
    tags: (GastroTag | ShoppingTag)[];
    query: GastroQuery | ShoppingQuery;

    // In template, there is no instanceof.
    get isGastro(): boolean {
        return this.query instanceof GastroQuery;
    }

    init(query: GastroQuery | ShoppingQuery) {
        this.tags = query instanceof GastroQuery ? getGastroTags() : getShoppingTags();
        this.query = query;
    }

    onQueryChange() {
        this.queryChange.emit(this.query);
    }

    onCoordinatesChange(coordinates: Coordinates | null) {
        if (!coordinates) {
            this.query.distance.enabled = false;
        }
        this.query.distance.coordinates = coordinates;
        this.queryChange.emit(this.query);
    }

    getFeatureList1(): string[] {
        return this.isGastro ?
            ["organic", "breakfast", "dog", "handicappedAccessible", "delivery", "wlan"]
            :
            ["organic", "handicappedAccessible", "delivery"];
    }

    getFeatureList2(): string[] {
        return this.isGastro ?
            ["glutenFree", "brunch", "childChair", "handicappedAccessibleWc", "catering", "review"]
            :
            ["review"];
    }
}

{'fraction_non_alphanumeric': 0.13377777777777777, 'fraction_numerical': 0.0071111111111111115, 'mean_word_length': 2.95171202809482, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6634876', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1276, 'n_words': 270}