<commit_before>package com.deuteriumlabs.dendrite.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.deuteriumlabs.dendrite.model.PageId;
import com.deuteriumlabs.dendrite.model.StoryOption;
import com.deuteriumlabs.dendrite.model.StoryPage;

public abstract class SubmitController {

	static final int MAX_EXPONENT = 30;
	protected String authorId;
	protected String authorName;
	protected String content;
	protected PageId id;
	protected List<String> options;
	
	public SubmitController() {
		this.options = new ArrayList<String>();
	}

	public void addOption(final String option) {
		final List<String> options = this.getOptions();
		final int size = options.size();
		if (size < 5)
			options.add(option);
	}

	public void buildNewPage() {
		this.setNewPageId();
		this.buildStoryPage();
		this.buildStoryOptions();
	}

	protected void buildStoryOptions() {
		final List<String> optionTexts = this.getOptions();
		for (int i = 0; i < 5; i++) {
			final String text = optionTexts.get(i);
			if (text == null || text.length() == 0)
				continue;
			final StoryOption option = new StoryOption();
			final PageId source = this.getId();
			option.setSource(source);
			option.setListIndex(i);
			option.setText(text);
			final boolean isInStore = option.isInStore();
			if (isInStore == false)
				option.create();
		}<commit_msg>Option link indices now skip blank options correctly.<commit_after>package com.deuteriumlabs.dendrite.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.deuteriumlabs.dendrite.model.PageId;
import com.deuteriumlabs.dendrite.model.StoryOption;
import com.deuteriumlabs.dendrite.model.StoryPage;

public abstract class SubmitController {

	static final int MAX_EXPONENT = 30;
	protected String authorId;
	protected String authorName;
	protected String content;
	protected PageId id;
	protected List<String> options;
	
	public SubmitController() {
		this.options = new ArrayList<String>();
	}

	public void addOption(final String option) {
		final List<String> options = this.getOptions();
		final int size = options.size();
		if (size < 5)
			options.add(option);
	}

	public void buildNewPage() {
		this.setNewPageId();
		this.buildStoryPage();
		this.buildStoryOptions();
	}

	protected void buildStoryOptions() {
		final List<String> optionTexts = this.getOptions();
		int linkIndex = 0;
		for (int i = 0; i < 5; i++) {
			final String text = optionTexts.get(i);
			if (text == null || text.length() == 0) {
				continue;
			}
			final StoryOption option = new StoryOption();
			final PageId source = this.getId();
			option.setSource(source);
			option.setListIndex(linkIndex);
			option.setText(text);
			final boolean isInStore = option.isInStore();
			if (isInStore == false)
				option.create();
			linkIndex++;
		}
{'fraction_non_alphanumeric': 0.11649122807017544, 'fraction_numerical': 0.004561403508771929, 'mean_word_length': 4.399621212121212, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '2406193', 'n_tokens_mistral': 1006, 'n_tokens_neox': 894, 'n_words': 231}