<commit_before>
/*
 * Carrot2 project.
 *
 * Copyright (C) 2002-2006, <NAME>, <NAME>.
 * Portions (C) Contributors listed in "carrot2.CONTRIBUTORS" file.
 * All rights reserved.
 *
 * Refer to the full license file "carrot2.LICENSE"
 * in the root folder of the repository checkout or at:
 * http://www.carrot2.org/carrot2.LICENSE
 */

package org.carrot2.input.yahooapi;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

import org.carrot2.util.httpform.*;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;


/**
 * A Yahoo search service descriptor.
 * 
 * @author <NAME>
 */
public class YahooSearchServiceDescriptor {
    private FormActionInfo formActionInfo;
    private FormParameters formParameters;

    /**
     * Creates an empty descriptor. Initialize it using
     * {@link #initializeFromXML(InputStream)}.
     */
    public YahooSearchServiceDescriptor() {
    }

    /**
     * Creates a descriptor based on the provided specification.
     */
    public YahooSearchServiceDescriptor(FormActionInfo formActionInfo, 
            FormParameters formParameters) {
        this.formActionInfo = formActionInfo;
        this.formParameters = formParameters;
    }

    /**
     * Initializes the descriptor from an XML file. See the unit tests
     * for examples.
     * 
     * Any previous content is erased.
     *  
     * @throws IOException  
     */
    public void initializeFromXML(InputStream xmlStream) throws IOException {
        Document doc;
        final SAXReader reader = new SAXReader(false);
        try {
            doc = reader.read(xmlStream);
        } catch (DocumentException e) {
            throw new IOException("Description parsing error: " + e.toString());
        }

        final Element configuration = doc.getRootElement();

        FormActionInfo formActionInfo = new FormActionInfo(configuration);
        FormParameters formParameters = new FormParameters(configuration.element("parameters"));

        this.formActionInfo = formActionInfo;
        this.formParameters = formParameters;
    }

    /**
     * Returns form action info associated with this service.
     */
    public FormActionInfo getFormActionInfo() {
        return formActionInfo;
    }
    
    /**
     * Returns form parameters used in this service. Certain form
     * parameters may require mappings to real values 
     * (see {@link HTTPFormSubmitter#submit(FormParameters, Map, String)}).
     */
    public FormParameters getFormParameters() {
        return formParameters;
    }

    /**
     * Returns maximum results per query. Currently hardcoded at 50.
     */
    public int getMaxResultsPerQuery() {
        return 50;
    }
}<commit_msg>Increased the single-query limit to 100 (it seems to work now).<commit_after>
/*
 * Carrot2 project.
 *
 * Copyright (C) 2002-2006, <NAME>, <NAME>.
 * Portions (C) Contributors listed in "carrot2.CONTRIBUTORS" file.
 * All rights reserved.
 *
 * Refer to the full license file "carrot2.LICENSE"
 * in the root folder of the repository checkout or at:
 * http://www.carrot2.org/carrot2.LICENSE
 */

package org.carrot2.input.yahooapi;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

import org.carrot2.util.httpform.*;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;


/**
 * A Yahoo search service descriptor.
 * 
 * @author <NAME>
 */
public class YahooSearchServiceDescriptor {
    private FormActionInfo formActionInfo;
    private FormParameters formParameters;

    /**
     * Creates an empty descriptor. Initialize it using
     * {@link #initializeFromXML(InputStream)}.
     */
    public YahooSearchServiceDescriptor() {
    }

    /**
     * Creates a descriptor based on the provided specification.
     */
    public YahooSearchServiceDescriptor(FormActionInfo formActionInfo, 
            FormParameters formParameters) {
        this.formActionInfo = formActionInfo;
        this.formParameters = formParameters;
    }

    /**
     * Initializes the descriptor from an XML file. See the unit tests
     * for examples.
     * 
     * Any previous content is erased.
     *  
     * @throws IOException  
     */
    public void initializeFromXML(InputStream xmlStream) throws IOException {
        Document doc;
        final SAXReader reader = new SAXReader(false);
        try {
            doc = reader.read(xmlStream);
        } catch (DocumentException e) {
            throw new IOException("Description parsing error: " + e.toString());
        }

        final Element configuration = doc.getRootElement();

        FormActionInfo formActionInfo = new FormActionInfo(configuration);
        FormParameters formParameters = new FormParameters(configuration.element("parameters"));

        this.formActionInfo = formActionInfo;
        this.formParameters = formParameters;
    }

    /**
     * Returns form action info associated with this service.
     */
    public FormActionInfo getFormActionInfo() {
        return formActionInfo;
    }
    
    /**
     * Returns form parameters used in this service. Certain form
     * parameters may require mappings to real values 
     * (see {@link HTTPFormSubmitter#submit(FormParameters, Map, String)}).
     */
    public FormParameters getFormParameters() {
        return formParameters;
    }

    /**
     * Returns maximum results per query. Currently hardcoded at 50.
     */
    public int getMaxResultsPerQuery() {
        return 100;
    }
}
{'fraction_non_alphanumeric': 0.0895628902765388, 'fraction_numerical': 0.008920606601248885, 'mean_word_length': 2.8110129163834126, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, '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': '3529230', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1456, 'n_words': 434}