<commit_before>package net.sf.jabref.imports;

import java.util.List;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.IOException;

/**
 * Importer for the MS Office 2007 XML bibliography format
 * By <NAME>
 *
 * ...
 */
public class MsBibImporter extends ImportFormat {

    public boolean isRecognizedFormat(InputStream in) throws IOException {

        /*
            This method is available for checking if a file can be of the MSBib type.
            The effect of this method is primarily to avoid unnecessary processing of
            files when searching for a suitable import format. If this method returns
            false, the import routine will move on to the next import format.

            The correct behaviour is to return false if it is certain that the file is
            not of the MsBib type, and true otherwise. Returning true is the safe choice
            if not certain.
         */

        return true;
    }

    public List importEntries(InputStream in) throws IOException {

        System.out.println("Hello world MsBibImporter");

        List entries = new ArrayList();
        /*
            This method should read the input stream until the end, and add any entries
            found to a List which is returned. If the stream doesn't contain any useful
            data (is of the wrong format?) you can return null to signal that this is the
            wrong import filter.
         */

        return null;
        //return entries;
    }

    public String getFormatName() {
        // This method should return the name of this import format.
        return "MSBib";
    }

}
<commit_msg>Added funtionality for import.<commit_after>package net.sf.jabref.imports;

import java.util.List;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.IOException;
import net.sf.jabref.msbib.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;


/**
 * Importer for the MS Office 2007 XML bibliography format
 * By <NAME>
 *
 * ...
 */
public class MsBibImporter extends ImportFormat {

    public boolean isRecognizedFormat(InputStream in) throws IOException {

        /*
            This method is available for checking if a file can be of the MSBib type.
            The effect of this method is primarily to avoid unnecessary processing of
            files when searching for a suitable import format. If this method returns
            false, the import routine will move on to the next import format.

            The correct behaviour is to return false if it is certain that the file is
            not of the MsBib type, and true otherwise. Returning true is the safe choice
            if not certain.
         */
    	Document docin = null;
    	try {
    	DocumentBuilder dbuild = DocumentBuilderFactory.
    								newInstance().
    								newDocumentBuilder();
   		docin = dbuild.parse(in);   		
    	} catch (Exception e) {
	   		return false;
    	}
    	if(docin!= null && docin.getDocumentElement().getTagName().contains("Sources") == false)
    		return false;
//   		NodeList rootLst = docin.getElementsByTagName("b:Sources");
//   		if(rootLst.getLength()==0)
//   			rootLst = docin.getElementsByTagName("Sources");
//   		if(rootLst.getLength()==0)
//   			return false;
    	// System.out.println(docin.getDocumentElement().getTagName());
        return true;
    }

    /**
	 * String used to identify this import filter on the command line.
	 * 
	 * @override
	 * @return "msbib"
	 */
	public String getCLIid() {
		return "msbib";
	}

    public List importEntries(InputStream in) throws IOException {

        MSBibDatabase dbase = new MSBibDatabase();

        List entries = dbase.importEntries(in);

        return entries;
    }

    public String getFormatName() {
        // This method should return the name of this import format.
        return "MSBib";
    }

}

{'fraction_non_alphanumeric': 0.07700231779551893, 'fraction_numerical': 0.0028328611898017, 'mean_word_length': 2.3862249346120312, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '819695', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1005, 'n_words': 403}