<commit_before>package org.icij.task;

import org.icij.time.HumanDuration;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.List;
import java.util.LinkedList;
import java.util.Collection;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;

public class DefaultOption implements Option<DefaultOption, String, String> {

	private static class DefaultSupplier implements Supplier<List<String>> {

		private final List<String> values = new LinkedList<>();

		@Override
		public List<String> get() {
			return values;
		}
	}

	private final String name;
	private Character code = null;
	private String description = null;
	private String parameter = null;

	protected Supplier<List<String>> values = new DefaultSupplier();

	private DefaultOption(final String name) {
		this.name = name;
	}

	@Override
	public Optional<Duration> asDuration() {
		return value(HumanDuration::parse);
	}

	@Override
	public Optional<Path> asPath() {
		return value(Paths::get);
	}

	@Override
	public Optional<Integer> asInteger() {
		return value(Integer::valueOf);
	}

	@Override
	public Optional<Boolean> asBoolean() {
		return value(Boolean::valueOf);
	}

	@Override
	public boolean on() {
		final Optional<Boolean> toggle = asBoolean();

		return toggle.isPresent() && toggle.get();
	}

	@Override
	public boolean off() {
		final Optional<Boolean> toggle = asBoolean();

		return toggle.isPresent() && !toggle.get();
	}

	@Override
	public <E extends Enum<E>> Optional<E> asEnum(final Function<String, E> valueOf) {
		return value(valueOf);
	}

	@Override
	public DefaultOption code(final Character code) {
		this.code = code;
		return this;
	}<commit_msg>Support more boolean option values: on, yes, 1 and true are all converted to true<commit_after>package org.icij.task;

import org.icij.time.HumanDuration;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.*;
import java.util.function.Function;
import java.util.function.Supplier;

public class DefaultOption implements Option<DefaultOption, String, String> {

	private static class DefaultSupplier implements Supplier<List<String>> {

		private final List<String> values = new LinkedList<>();

		@Override
		public List<String> get() {
			return values;
		}
	}

	private final String name;
	private Character code = null;
	private String description = null;
	private String parameter = null;

	protected Supplier<List<String>> values = new DefaultSupplier();

	private DefaultOption(final String name) {
		this.name = name;
	}

	@Override
	public Optional<Duration> asDuration() {
		return value(HumanDuration::parse);
	}

	@Override
	public Optional<Path> asPath() {
		return value(Paths::get);
	}

	@Override
	public Optional<Integer> asInteger() {
		return value(Integer::valueOf);
	}

	@Override
	public Optional<Boolean> asBoolean() {
		return value((value)-> {
			value = value.toLowerCase(Locale.ROOT);
			if (value.equals("yes") || value.equals("on") || value.equals("true") || value.equals("1")) {
				return Boolean.TRUE;
			}

			return Boolean.FALSE;
		});
	}

	@Override
	public boolean on() {
		final Optional<Boolean> toggle = asBoolean();

		return toggle.isPresent() && toggle.get();
	}

	@Override
	public boolean off() {
		final Optional<Boolean> toggle = asBoolean();

		return toggle.isPresent() && !toggle.get();
	}

	@Override
	public <E extends Enum<E>> Optional<E> asEnum(final Function<String, E> valueOf) {
		return value(valueOf);
	}

	@Override
	public DefaultOption code(final Character code) {
		this.code = code;
		return this;
	}
{'fraction_non_alphanumeric': 0.12290653700702323, 'fraction_numerical': 0.0005402485143165856, 'mean_word_length': 4.714506172839506, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 40, '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': '362696', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1105, 'n_words': 307}