<commit_before>/*
 *  The MIT License (MIT)
 *
 *  View the full license at:
 *  https://github.com/hendrixjoseph/FamilyTree/blob/master/LICENSE.md
 *
 *  Copyright (c) 2015 <NAME>
 *
 *  Hosted on GitHub at https://github.com/hendrixjoseph/FamilyTree
 *
 */
package edu.wright.hendrix11.familyTree.importer;

import edu.wright.hendrix11.familyTree.entity.Marriage;
import edu.wright.hendrix11.familyTree.entity.Person;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.LineNumberReader;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class GedcomImporter extends Importer
{

    private static final Logger LOG = Logger.getLogger(GedcomImporter.class.getName());

    private static final DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");

    // Just here to allow compilation til I'm done.
    Scanner in;

    private static final String INDI_LINE = "0 @I";

    private static final String NAME_LINE = "1 NAME ";
    private static final String GENDER_LINE = "1 SEX ";
    private static final String BIRTH_LINE = "1 BIRT";
    private static final String DEATH_LINE = "1 DEAT";
    private static final String DATE_LINE = "2 DATE ";
    private static final String PLAC_LINE = "2 PLAC ";

    private static final String FAM_LINE = "0 @F";

    private static final String HUSB_LINE = "1 HUSB";
    private static final String WIFE_LINE = "1 WIFE";
    private static final String CHIL_LINE = "1 CHIL";
    private static final String MARR_LINE = "1 MARR";

    private enum Mode 
    { 
        PERSON("0 @I"), FAMILY("0 @F"), MARRIAGE("1 MARR"), NONE("NONE");
        
        private final String string;

        /**
         * @param string
         */
        private Mode(final String string)
        {
            this.string = string;
        }
        
        public static Mode getMode(String string)
        {
            for(Mode mode : Mode.values())
            {
                if(mode.contains(string))
                    return mode;
            }
            
            return this;
        }
        
        private boolean contains(String string)
        {
            return string.contains(this.string);
        }
    }
    
    private enum LineType 
    { 
		NAME("1 NAME "),
		GENDER("1 SEX "),
		BIRTH("1 BIRT"),
		DEATH("1 DEAT"),
		DATE("2 DATE "),
		PLACE("2 PLAC "),	
		HUSB("1 HUSB"),
		WIFE("1 WIFE"),
		CHILD("1 CHIL"),
		MARR("1 MARR");
        
        private final String string;

        /**
         * @param string
         */
        private LineType(final String string)
        {
            this.string = string;
        }
        
        public LineType getLineType(String string)
        {
            for(LineType lineType : LineType.values())
            {
                if(lineType.contains(string))
                    return lineType;
            }
            
            return null;
        }
        
        private boolean contains(String string)
        {
            return string.contains(this.string);
        }
    }

    private boolean insertPersonMode;
    private boolean insertFamilyMode;
    private boolean insertMarriageMode;
    private boolean insertBirthMode;
    private boolean insertDeathMode;

    private HashMap<String, Person> entry = new HashMap<>();
    private HashMap<Person, String> reverseEntry = new HashMap<>();

    public GedcomImporter(String fileName) throws FileNotFoundException
    {
        super(fileName);
    }

    {
        processData();
    }

    /**
     *
     *
     */
    @Override
    protected void processData()
    {
        try(LineNumberReader in = new LineNumberReader(file))
        {
            while(!in.readLine().contains(INDI_LINE))
            {
            }

            String nextLine;
            Mode mode = Mode.NONE;
            
            while((nextLine = in.readLine()) != null)
            {
                mode = mode.getMode(nextLine);
    
                switch(mode)
                {
                    case PERSON:
    
                        break;
                    case FAMILY:
    
                        break;
                    case MARRIAGE:
    
                        break;
                    default:
                        // Do nothing
                }
            }
        }
        catch (IOException e)
        {
            LOG.log(Level.SEVERE, e.getClass().getName(), e);
        }

        LOG.log(Level.INFO, "Done!");
    }

    private void temp()
    {
        setAllModes(false);

        String nextLine = "";
<commit_msg>static method is no longer static<commit_after>/*
 *  The MIT License (MIT)
 *
 *  View the full license at:
 *  https://github.com/hendrixjoseph/FamilyTree/blob/master/LICENSE.md
 *
 *  Copyright (c) 2015 <NAME>
 *
 *  Hosted on GitHub at https://github.com/hendrixjoseph/FamilyTree
 *
 */
package edu.wright.hendrix11.familyTree.importer;

import edu.wright.hendrix11.familyTree.entity.Marriage;
import edu.wright.hendrix11.familyTree.entity.Person;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.LineNumberReader;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
public class GedcomImporter extends Importer
{

    private static final Logger LOG = Logger.getLogger(GedcomImporter.class.getName());

    private static final DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");

    // Just here to allow compilation til I'm done.
    Scanner in;

    private static final String INDI_LINE = "0 @I";

    private static final String NAME_LINE = "1 NAME ";
    private static final String GENDER_LINE = "1 SEX ";
    private static final String BIRTH_LINE = "1 BIRT";
    private static final String DEATH_LINE = "1 DEAT";
    private static final String DATE_LINE = "2 DATE ";
    private static final String PLAC_LINE = "2 PLAC ";

    private static final String FAM_LINE = "0 @F";

    private static final String HUSB_LINE = "1 HUSB";
    private static final String WIFE_LINE = "1 WIFE";
    private static final String CHIL_LINE = "1 CHIL";
    private static final String MARR_LINE = "1 MARR";

    private enum Mode
    {
        PERSON("0 @I"), FAMILY("0 @F"), MARRIAGE("1 MARR"), NONE("NONE");

        private final String string;

        /**
         * @param string
         */
        private Mode(final String string)
        {
            this.string = string;
        }

        public Mode getMode(String string)
        {
            for(Mode mode : Mode.values())
            {
                if(mode.contains(string))
                    return mode;
            }

            return this;
        }

        private boolean contains(String string)
        {
            return string.contains(this.string);
        }
    }

    private enum LineType
    {
		NAME("1 NAME "),
		GENDER("1 SEX "),
		BIRTH("1 BIRT"),
		DEATH("1 DEAT"),
		DATE("2 DATE "),
		PLACE("2 PLAC "),
		HUSB("1 HUSB"),
		WIFE("1 WIFE"),
		CHILD("1 CHIL"),
		MARR("1 MARR");

        private final String string;

        /**
         * @param string
         */
        private LineType(final String string)
        {
            this.string = string;
        }

        public LineType getLineType(String string)
        {
            for(LineType lineType : LineType.values())
            {
                if(lineType.contains(string))
                    return lineType;
            }

            return null;
        }

        private boolean contains(String string)
        {
            return string.contains(this.string);
        }
    }

    private boolean insertPersonMode;
    private boolean insertFamilyMode;
    private boolean insertMarriageMode;
    private boolean insertBirthMode;
    private boolean insertDeathMode;

    private HashMap<String, Person> entry = new HashMap<>();
    private HashMap<Person, String> reverseEntry = new HashMap<>();

    public GedcomImporter(String fileName) throws FileNotFoundException
    {
        super(fileName);
    }

    {
        processData();
    }

    /**
     *
     *
     */
    @Override
    protected void processData()
    {
        try(LineNumberReader in = new LineNumberReader(file))
        {
            while(!in.readLine().contains(INDI_LINE))
            {
            }

            String nextLine;
            Mode mode = Mode.NONE;

            while((nextLine = in.readLine()) != null)
            {
                mode = mode.getMode(nextLine);

                switch(mode)
                {
                    case PERSON:

                        break;
                    case FAMILY:

                        break;
                    case MARRIAGE:

                        break;
                    default:
                        // Do nothing
                }
            }
        }
        catch (IOException e)
        {
            LOG.log(Level.SEVERE, e.getClass().getName(), e);
        }

        LOG.log(Level.INFO, "Done!");
    }

    private void temp()
    {
        setAllModes(false);

        String nextLine = "";

{'fraction_non_alphanumeric': 0.09968782518210198, 'fraction_numerical': 0.007284079084287201, 'mean_word_length': 1.7971478463329453, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 4, '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': '6963167', 'n_tokens_mistral': 2812, 'n_tokens_neox': 2643, 'n_words': 690}