<commit_before>package org.gedcomx.examples;

import org.gedcomx.Gedcomx;
import org.gedcomx.agent.Agent;
import org.gedcomx.common.Attribution;
import org.gedcomx.common.ResourceReference;
import org.gedcomx.common.TextValue;
import org.gedcomx.common.URI;
import org.gedcomx.conclusion.*;
import org.gedcomx.rt.SerializationUtil;
import org.gedcomx.source.SourceCitation;
import org.gedcomx.source.SourceDescription;
import org.gedcomx.source.SourceReference;
import org.gedcomx.types.FactType;
import org.gedcomx.types.GenderType;
import org.gedcomx.types.NamePartType;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author <NAME>
 */
@Test
public class GeorgeMarthaWashingtonExampleTest {

  public void testExample() throws Exception {
    PlaceDescription popesCreek = createPopesCreek();
    PlaceDescription mountVernon = createMountVernon();
    PlaceDescription chestnutGrove = createChestnutGrove();
    Person george = createGeorge(popesCreek, mountVernon);
    Person martha = createMartha(chestnutGrove, mountVernon);
    Relationship marriage = createMarriage(george, martha);
    List<SourceDescription> sources = citeGeorgeMarthaAndMarriage(george, martha, marriage);
    Agent contributor = createContributor();
    Gedcomx gx = new Gedcomx();
    gx.setPersons(Arrays.asList(george, martha));
    gx.setRelationships(Arrays.asList(marriage));
    gx.setSourceDescriptions(sources);
    gx.setAgents(Arrays.asList(contributor));
    gx.setAttribution(new Attribution());
    gx.getAttribution().setContributor(new ResourceReference());
    gx.getAttribution().getContributor().setResource(URI.create("#" + contributor.getId()));
    gx.setPlaces(Arrays.asList(popesCreek, mountVernon, chestnutGrove));

    SerializationUtil.processThroughXml(gx);
    SerializationUtil.processThroughJson(gx);
  }

  private PlaceDescription createPopesCreek() {<commit_msg>shared places example test<commit_after>package org.gedcomx.examples;

import org.gedcomx.Gedcomx;
import org.gedcomx.agent.Agent;
import org.gedcomx.common.Attribution;
import org.gedcomx.common.ResourceReference;
import org.gedcomx.common.TextValue;
import org.gedcomx.common.URI;
import org.gedcomx.conclusion.*;
import org.gedcomx.rt.SerializationUtil;
import org.gedcomx.source.SourceCitation;
import org.gedcomx.source.SourceDescription;
import org.gedcomx.source.SourceReference;
import org.gedcomx.types.FactType;
import org.gedcomx.types.GenderType;
import org.gedcomx.types.NamePartType;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author <NAME>
 */
@Test
public class GeorgeMarthaWashingtonExampleTest {

//  public void testEventsOnPlaces() throws Exception {
//    PlaceDescription place = new PlaceDescription().id("P1").name("Family Farm in Scandinavia");
//    Event event1 = new Event().id("E1").place(new PlaceReference().description(place));
//    Event event2 = new Event().id("E2").place(new PlaceReference().description(place));
//    Event event3 = new Event().id("E3").place(new PlaceReference().description(place));
//    Gedcomx gx = new Gedcomx();
//    gx.place(place).event(event1).event(event2).event(event3);
//
//    byte[] bytes = SerializationUtil.toJsonStream(gx);
//    System.out.println(new String(bytes, "UTF-8"));
//  }
//
  public void testExample() throws Exception {
    PlaceDescription popesCreek = createPopesCreek();
    PlaceDescription mountVernon = createMountVernon();
    PlaceDescription chestnutGrove = createChestnutGrove();
    Person george = createGeorge(popesCreek, mountVernon);
    Person martha = createMartha(chestnutGrove, mountVernon);
    Relationship marriage = createMarriage(george, martha);
    List<SourceDescription> sources = citeGeorgeMarthaAndMarriage(george, martha, marriage);
    Agent contributor = createContributor();
    Gedcomx gx = new Gedcomx();
    gx.setPersons(Arrays.asList(george, martha));
    gx.setRelationships(Arrays.asList(marriage));
    gx.setSourceDescriptions(sources);
    gx.setAgents(Arrays.asList(contributor));
    gx.setAttribution(new Attribution());
    gx.getAttribution().setContributor(new ResourceReference());
    gx.getAttribution().getContributor().setResource(URI.create("#" + contributor.getId()));
    gx.setPlaces(Arrays.asList(popesCreek, mountVernon, chestnutGrove));

    SerializationUtil.processThroughXml(gx);
    SerializationUtil.processThroughJson(gx);
  }

  private PlaceDescription createPopesCreek() {
{'fraction_non_alphanumeric': 0.12187637001315213, 'fraction_numerical': 0.0024112231477422183, 'mean_word_length': 5.603473227206947, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6206962', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1435, 'n_words': 243}