All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.learnlib.api.oracle.SymbolQueryOracle Maven / Gradle / Ivy

There is a newer version: 0.17.0
Show newest version
/* Copyright (C) 2013-2020 TU Dortmund
 * This file is part of LearnLib, http://www.learnlib.de/.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.learnlib.api.oracle;

import java.util.Collection;

import de.learnlib.api.query.Query;
import net.automatalib.words.Word;
import net.automatalib.words.WordBuilder;

/**
 * Symbol query interface. Semantically similar to {@link MembershipOracle.MealyMembershipOracle}, but allows to pose
 * queries symbol-wise.
 *
 * @param 
 *         input alphabet type
 * @param 
 *         output alphabet type
 *
 * @author frohme
 */
public interface SymbolQueryOracle extends MembershipOracle.MealyMembershipOracle {

    /**
     * Query the system under learning for a new symbol. This is a stateful operation.
     *
     * @param i
     *         the symbol to query
     *
     * @return the observed output
     */
    O query(I i);

    /**
     * Reset the system under learning.
     */
    void reset();

    @Override
    default void processQueries(Collection>> queries) {

        final WordBuilder wb = new WordBuilder<>();

        for (final Query> q : queries) {
            reset();

            for (final I i : q.getPrefix()) {
                query(i);
            }

            for (final I i : q.getSuffix()) {
                wb.append(query(i));
            }

            q.answer(wb.toWord());
            wb.clear();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy