package de.visone.nlpext.network;

import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.swing.JOptionPane;

import de.visone.base.Network;
import de.visone.ext.NetworkUtil;
import de.visone.ext.nlp.NLPTextPane;
import de.visone.ext.nlp.TextNetworkUtil;
import edu.stanford.nlp.ling.HasWord;

public class CreateAttributes extends TextNetwork {
	public CreateAttributes(final Network network) {
		super(false);
		myNetwork = network;
	}

	@Override
	protected void processSentence(final List<? extends HasWord> sentence,
			final int sentenceIndex) {
		return;
	}

	@Override
	protected void finalizeCreation() {
		return;
	}

	@Override
	protected String getDescription() {
		return NetworkUtil.getNetworkAttribute(myNetwork,
				TextNetwork.ATTR_NAME_DESCR);
	}

	@Override
	protected void createNetworkFromTransportGraph() {
		return;
	}

	@Override
	public void buildNetwork(final File file) throws IOException {
		// retrieve text from Network
		final String text = TextNetworkUtil.getText(myNetwork);
		if (text == null) {
			JOptionPane.showMessageDialog(null, NLPTextPane.NO_TEXT_ATTR,
					NLPTextPane.ERROR_TITLE, JOptionPane.ERROR_MESSAGE);
			return;
		}

		buildNetwork(text);
	}
}
