<commit_before>package org.ossmeter.severityclassifier.opennlptartarus.libsvm;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.ossmeter.metricprovider.trans.newsgroups.threads.model.ArticleData;
import org.ossmeter.platform.delta.communicationchannel.CommunicationChannelArticle;

import uk.ac.nactem.posstemmer.OpenNlpTartarusSingleton;
import uk.ac.nactem.posstemmer.Token;

public class ClassificationInstance {
	
	private String bugTrackerId;
	private String bugId;
	
	private String newsgroupName;
	private int threadId;
	private String subject;
	private List<List<Token>> tokenSentences;
	private List<List<Token>> cleanTokenSentences;

//	private String text;
//	private String cleanText;
	private String composedId;
	
	private Set<String> unigrams, bigrams, trigrams, quadgrams, 
						charTrigrams, charQuadgrams, charFivegrams;

	private List<String> sortedUnigrams, sortedBigrams, 
						 sortedTrigrams, sortedQuadgrams, 
						 sortedCharTrigrams, sortedCharQuadgrams, sortedCharFivegrams;
	
	public ClassificationInstance(ClassifierMessage classifierMessage) {
		initialiseNGrams();
		initialiseMetadata(classifierMessage);
		addText(classifierMessage.getText()); 
	}

	public ClassificationInstance(FeatureGenerator featureGenerator, 
								  ClassifierMessage classifierMessage,
								  FeatureIdCollection featureIdCollection) {
		initialiseNGrams();
		initialiseMetadata(classifierMessage);
		addText(classifierMessage.getText()); 
		updateFeatureIds(featureGenerator, featureIdCollection);
	}

	public ClassificationInstance(FeatureGenerator featureGenerator,
								  ArticleData articleData, 
								  int threadId,
								  FeatureIdCollection featureIdCollection) {
		initialiseNGrams();
		initialiseMetadata(articleData, threadId);
		updateFeatureIds(featureGenerator, featureIdCollection);
	}

	public ClassificationInstance(String url,
								  CommunicationChannelArticle deltaArticle, 
								  int threadId) {
		initialiseNGrams();
		initialiseMetadata(url, deltaArticle, threadId);
		addText(deltaArticle.getText());
	}


	public void update(ClassifierMessage classifierMessage) {
		addText(classifierMessage.getText()); 
	}

	public void update(FeatureGenerator featureGenerator,
					   FeatureIdCollection featureIdCollection) {
		updateFeatureIds(featureGenerator, featureIdCollection);
	}

	public void update(CommunicationChannelArticle deltaArticle) {
		addText(deltaArticle.getText()); 
	}

	private void initialiseMetadata(ClassifierMessage classifierMessage) {
		setBugTrackerId(classifierMessage.getBugTrackerId());
		setBugId(classifierMessage.getBugId());
		setNewsgroupName(classifierMessage.getNewsgroupName());
		setThreadId(classifierMessage.getThreadId());
		setSubject(classifierMessage.getSubject());
	}

	private void initialiseMetadata(ArticleData articleData, int threadId) {
		setNewsgroupName(articleData.getNewsgroupName());
		setThreadId(threadId);
		setSubject(articleData.getSubject());
	}

	private void initialiseMetadata(String newsgroupName, 
									CommunicationChannelArticle deltaArticle, 
									int threadId) {
		setNewsgroupName(newsgroupName);
		setThreadId(threadId);
		if (deltaArticle==null)
			System.err.println("deltaArticle==null");
		System.err.println("deltaArticle.getSubject() : " + deltaArticle.getSubject());
		setSubject(deltaArticle.getSubject());<commit_msg>correction in severity classifier mechanism<commit_after>package org.ossmeter.severityclassifier.opennlptartarus.libsvm;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.ossmeter.metricprovider.trans.newsgroups.threads.model.ArticleData;
import org.ossmeter.platform.delta.communicationchannel.CommunicationChannelArticle;

import uk.ac.nactem.posstemmer.OpenNlpTartarusSingleton;
import uk.ac.nactem.posstemmer.Token;

public class ClassificationInstance {
	
	private String bugTrackerId;
	private String bugId;
	
	private String newsgroupName;
	private int threadId;
	private String subject;
	private List<List<Token>> tokenSentences;
	private List<List<Token>> cleanTokenSentences;

//	private String text;
//	private String cleanText;
	private String composedId;
	
	private Set<String> unigrams, bigrams, trigrams, quadgrams, 
						charTrigrams, charQuadgrams, charFivegrams;

	private List<String> sortedUnigrams, sortedBigrams, 
						 sortedTrigrams, sortedQuadgrams, 
						 sortedCharTrigrams, sortedCharQuadgrams, sortedCharFivegrams;
	
	public ClassificationInstance(ClassifierMessage classifierMessage) {
		initialiseNGrams();
		initialiseMetadata(classifierMessage);
		addText(classifierMessage.getText()); 
	}

	public ClassificationInstance(FeatureGenerator featureGenerator, 
								  ClassifierMessage classifierMessage,
								  FeatureIdCollection featureIdCollection) {
		initialiseNGrams();
		initialiseMetadata(classifierMessage);
		addText(classifierMessage.getText()); 
		updateFeatureIds(featureGenerator, featureIdCollection);
	}

	public ClassificationInstance(FeatureGenerator featureGenerator,
								  ArticleData articleData, 
								  int threadId,
								  FeatureIdCollection featureIdCollection) {
		initialiseNGrams();
		initialiseMetadata(articleData, threadId);
		updateFeatureIds(featureGenerator, featureIdCollection);
	}

	public ClassificationInstance(String url,
								  CommunicationChannelArticle deltaArticle, 
								  int threadId) {
		initialiseNGrams();
		initialiseMetadata(url, deltaArticle, threadId);
		addText(deltaArticle.getText());
	}


	public void update(ClassifierMessage classifierMessage) {
		addText(classifierMessage.getText()); 
	}

	public void update(FeatureGenerator featureGenerator,
					   FeatureIdCollection featureIdCollection) {
		updateFeatureIds(featureGenerator, featureIdCollection);
	}

	public void update(CommunicationChannelArticle deltaArticle) {
		addText(deltaArticle.getText()); 
	}

	private void initialiseMetadata(ClassifierMessage classifierMessage) {
		setBugTrackerId(classifierMessage.getBugTrackerId());
		setBugId(classifierMessage.getBugId());
		setNewsgroupName(classifierMessage.getNewsgroupName());
		setThreadId(classifierMessage.getThreadId());
		setSubject(classifierMessage.getSubject());
	}

	private void initialiseMetadata(ArticleData articleData, int threadId) {
		setNewsgroupName(articleData.getNewsgroupName());
		setThreadId(threadId);
		setSubject(articleData.getSubject());
	}

	private void initialiseMetadata(String newsgroupName, 
									CommunicationChannelArticle deltaArticle, 
									int threadId) {
		setNewsgroupName(newsgroupName);
		setThreadId(threadId);
		if (deltaArticle!=null) {
			System.err.println("deltaArticle.getSubject() : " + deltaArticle.getSubject());
			setSubject(deltaArticle.getSubject());
		} else {
			setSubject("");
		}
{'fraction_non_alphanumeric': 0.08442966604019084, 'fraction_numerical': 0.0, 'mean_word_length': 5.959758551307847, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4946788', 'n_tokens_mistral': 2284, 'n_tokens_neox': 1863, 'n_words': 338}