<commit_before>

import static org.junit.Assert.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
import java.util.Scanner;

import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.DefaultTuple;
import org.apache.pig.data.Tuple;
import org.apache.pig.pigunit.PigTest;
import org.apache.pig.tools.parameters.ParseException;
import org.junit.Test;

import pl.edu.icm.coansys.disambiguation.author.pig.AproximateAND;
import pl.edu.icm.coansys.models.DocumentProtos.Author;
import pl.edu.icm.coansys.models.DocumentProtos.DocumentMetadata;

public class disambiguationTests {
	
	private final String testPath = "src/test/resources/";
	
	private String readTestToString( final String filePath ) throws FileNotFoundException {
		
		fileExist( filePath );
		StringBuffer ret = new StringBuffer();	
		File file = new File( filePath );
		Scanner in = new Scanner( file );
		
		while ( in.hasNext() ) {
			ret.append( in.nextLine() );
			ret.append("\n");
		}
		
		return ret.toString();
	}
	
	
	public void fileExist( String filePathString ) throws FileNotFoundException {
		File f = new File( filePathString );
		
		if( !f.exists() ) {
			String m = "Cannot find script for test or test case file: ";
			m += "\n\t relative path: " + filePathString;
			m += "\n\t absolut path: " + f.getAbsolutePath();
			
			throw new FileNotFoundException( m );
		}
	}

	
//	@Test
//	public void aproximateANDTest() throws IOException {
//		
//		/// Initialization (for add test case change n and look at next code block):
//		int n = 1;
//		int t = 0;
//		AproximateAND udf = new AproximateAND("-1.0","TitleDisambiguator#EX_TITLE#1#1,YearDisambiguator#EX_YEAR#1#1");
//		Tuple input[] = new DefaultTuple[n]; /// for udf singleAND
//		Tuple output[] = new DefaultTuple[n]; /// from udf singleAND
//		Tuple expected[] = new DefaultTuple[n];
//		String contributorsKeys[] = new String[n]; /// for compare output with expected result
//		
//		for ( int i = 0; i < n; i++ ) 
//			input[i] = new DefaultTuple();
//		
//		/// Adding new test cases (here edit for add test cases):		
//		/// # TEST 0
//			String strMetadata = readTestToString( testPath + "test1_metadata.in" );
//			contributorsKeys[ t ] = "<KEY>";
//			
//			DataByteArray dbaMetadata = new DataByteArray();
//			dbaMetadata.set( strMetadata );
//			
//			//shit happens (przeklejona wywalajaca linijka z SingleAND):
//			DocumentMetadata metadata = DocumentMetadata.parseFrom( dbaMetadata.get() );
//
//		/*	
//		// ciag dalszy, jesli naprawimy powyzsze:
//			input[ t ].append( dbaMetadata );
//			input[ t ].append( 0 ); //position of contributor in metadata's author list
//		
//			
//		/// Compute and check
//		for ( int i = 0; i < n; i++ ) {
//			expected[i] = new DefaultTuple();
//			/// for 'single' contributors UUID should equal authorKey
//			expected[i].append( contributorsKeys[i] );
//			expected[i].append( contributorsKeys[i] );
//			
//			//output[i] = 
//			udf.exec( input[i] );
//		}*/
//		
//		
//		//assertArrayEquals( expected, output );	
//	}
//
	@Test
	public void newDisambiguation() throws IOException, ParseException {<commit_msg>test turn off<commit_after>

import static org.junit.Assert.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
import java.util.Scanner;

import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.DefaultTuple;
import org.apache.pig.data.Tuple;
import org.apache.pig.pigunit.PigTest;
import org.apache.pig.tools.parameters.ParseException;
import org.junit.Test;

import pl.edu.icm.coansys.disambiguation.author.pig.AproximateAND;
import pl.edu.icm.coansys.models.DocumentProtos.Author;
import pl.edu.icm.coansys.models.DocumentProtos.DocumentMetadata;

public class disambiguationTests {
	
	private final String testPath = "src/test/resources/";
	
	private String readTestToString( final String filePath ) throws FileNotFoundException {
		
		fileExist( filePath );
		StringBuffer ret = new StringBuffer();	
		File file = new File( filePath );
		Scanner in = new Scanner( file );
		
		while ( in.hasNext() ) {
			ret.append( in.nextLine() );
			ret.append("\n");
		}
		
		return ret.toString();
	}
	
	
	public void fileExist( String filePathString ) throws FileNotFoundException {
		File f = new File( filePathString );
		
		if( !f.exists() ) {
			String m = "Cannot find script for test or test case file: ";
			m += "\n\t relative path: " + filePathString;
			m += "\n\t absolut path: " + f.getAbsolutePath();
			
			throw new FileNotFoundException( m );
		}
	}

	
//	@Test
//	public void aproximateANDTest() throws IOException {
//		
//		/// Initialization (for add test case change n and look at next code block):
//		int n = 1;
//		int t = 0;
//		AproximateAND udf = new AproximateAND("-1.0","TitleDisambiguator#EX_TITLE#1#1,YearDisambiguator#EX_YEAR#1#1");
//		Tuple input[] = new DefaultTuple[n]; /// for udf singleAND
//		Tuple output[] = new DefaultTuple[n]; /// from udf singleAND
//		Tuple expected[] = new DefaultTuple[n];
//		String contributorsKeys[] = new String[n]; /// for compare output with expected result
//		
//		for ( int i = 0; i < n; i++ ) 
//			input[i] = new DefaultTuple();
//		
//		/// Adding new test cases (here edit for add test cases):		
//		/// # TEST 0
//			String strMetadata = readTestToString( testPath + "test1_metadata.in" );
//			contributorsKeys[ t ] = "<KEY>";
//			
//			DataByteArray dbaMetadata = new DataByteArray();
//			dbaMetadata.set( strMetadata );
//			
//			//shit happens (przeklejona wywalajaca linijka z SingleAND):
//			DocumentMetadata metadata = DocumentMetadata.parseFrom( dbaMetadata.get() );
//
//		/*	
//		// <NAME>, <NAME>yzsze:
//			input[ t ].append( dbaMetadata );
//			input[ t ].append( 0 ); //position of contributor in metadata's author list
//		
//			
//		/// Compute and check
//		for ( int i = 0; i < n; i++ ) {
//			expected[i] = new DefaultTuple();
//			/// for 'single' contributors UUID should equal authorKey
//			expected[i].append( contributorsKeys[i] );
//			expected[i].append( contributorsKeys[i] );
//			
//			//output[i] = 
//			udf.exec( input[i] );
//		}*/
//		
//		
//		//assertArrayEquals( expected, output );	
//	}
//
//	@Test
	public void newDisambiguation() throws IOException, ParseException {
{'fraction_non_alphanumeric': 0.15151515151515152, 'fraction_numerical': 0.004103535353535354, 'mean_word_length': 3.1364229765013056, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '7587995', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2129, 'n_words': 543}