<commit_before>

package com.hustunique.jianguo.parsingplayer.parser.extractor;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.hustunique.jianguo.parsingplayer.parser.entity.VideoInfo;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by JianGuo on 1/16/17.
 * Interface for extracting video info from websites
 */

public abstract class Extractor implements Callback {
    private ExtractCallback mCallback;
    public interface ExtractCallback {
        void onSuccess(VideoInfo videoInfo);
        void onError(Throwable e);
    }
    /**
     * Extract videoinfo from given url,
     * call {@link ExtractCallback#onSuccess(VideoInfo)}
     * when succeed.
     * @param url the given url
     * @param callback the callback, see {@link ExtractCallback} for details
     */
    public void extract(@NonNull String url, @Nullable final ExtractCallback callback) {
        OkHttpClient client = buildClient();
        String baseUrl = constructBasicUrl(url);
        final Request request = buildRequest(baseUrl);
        client.newCall(request).enqueue(this);
        mCallback = callback;
    }

    abstract String constructBasicUrl(@NonNull String url);

    @Nullable
    abstract VideoInfo createInfo(@NonNull Response response) throws IOException;

    @NonNull
    abstract OkHttpClient buildClient();

    @NonNull
    abstract Request buildRequest(@NonNull String baseUrl);

    @Override
    public void onFailure(Call call, IOException e) {
        if (mCallback != null) mCallback.onError(e);<commit_msg>use single instance of okhttp client<commit_after>

package com.hustunique.jianguo.parsingplayer.parser.extractor;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.hustunique.jianguo.parsingplayer.parser.entity.VideoInfo;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by JianGuo on 1/16/17.
 * Interface for extracting video info from websites
 */

public abstract class Extractor implements Callback {
    private ExtractCallback mCallback;
    private OkHttpClient mClient;
    public interface ExtractCallback {
        void onSuccess(VideoInfo videoInfo);
        void onError(Throwable e);
    }

    public Extractor() {
        mClient = new OkHttpClient();
    }

    /**
     * Extract videoinfo from given url,
     * call {@link ExtractCallback#onSuccess(VideoInfo)}
     * when succeed.
     * @param url the given url
     * @param callback the callback, see {@link ExtractCallback} for details
     */
    public void extract(@NonNull String url, @Nullable final ExtractCallback callback) {
        String baseUrl = constructBasicUrl(url);
        final Request request = buildRequest(baseUrl);
        mClient.newCall(request).enqueue(this);
        mCallback = callback;
    }

    abstract String constructBasicUrl(@NonNull String url);

    @Nullable
    abstract VideoInfo createInfo(@NonNull Response response) throws IOException;
    @NonNull
    abstract Request buildRequest(@NonNull String baseUrl);

    @Override
    public void onFailure(Call call, IOException e) {
        if (mCallback != null) mCallback.onError(e);
{'fraction_non_alphanumeric': 0.08235638921453693, 'fraction_numerical': 0.005861664712778429, 'mean_word_length': 3.707586206896552, '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': '2502908', 'n_tokens_mistral': 929, 'n_tokens_neox': 906, 'n_words': 267}