From ee9acef9e9323a1a97b121058d74a048250cd0d6 Mon Sep 17 00:00:00 2001 From: jzonthemtn Date: Tue, 19 Nov 2024 18:01:44 -0500 Subject: [PATCH] #163: Changing the line width separator to be a space. --- .../services/split/LineWidthSplitService.java | 2 +- .../services/split/LineWidthSplitServiceTest.java | 13 +++++++++++-- .../src/test/resources/simple-test.txt | 4 +--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/phileas-services/phileas-services-split/src/main/java/ai/philterd/phileas/services/split/LineWidthSplitService.java b/phileas-services/phileas-services-split/src/main/java/ai/philterd/phileas/services/split/LineWidthSplitService.java index 637ebdc23..3f4332f37 100644 --- a/phileas-services/phileas-services-split/src/main/java/ai/philterd/phileas/services/split/LineWidthSplitService.java +++ b/phileas-services/phileas-services-split/src/main/java/ai/philterd/phileas/services/split/LineWidthSplitService.java @@ -27,7 +27,7 @@ public class LineWidthSplitService extends AbstractSplitService implements Split private static final Logger LOGGER = LogManager.getLogger(LineWidthSplitService.class); - private static final String SEPARATOR = System.lineSeparator(); + private static final String SEPARATOR = " "; final int lineWidth; diff --git a/phileas-services/phileas-services-split/src/test/java/ai/philterd/test/phileas/services/split/LineWidthSplitServiceTest.java b/phileas-services/phileas-services-split/src/test/java/ai/philterd/test/phileas/services/split/LineWidthSplitServiceTest.java index 49e79d315..64a0cff91 100644 --- a/phileas-services/phileas-services-split/src/test/java/ai/philterd/test/phileas/services/split/LineWidthSplitServiceTest.java +++ b/phileas-services/phileas-services-split/src/test/java/ai/philterd/test/phileas/services/split/LineWidthSplitServiceTest.java @@ -37,20 +37,29 @@ public class LineWidthSplitServiceTest { @Test public void split0() throws IOException { + final int splitLength = 384; + final File file = new File("src/test/resources/simple-test.txt"); final String input = FileUtils.readFileToString(file, Charset.defaultCharset()); Assertions.assertNotNull(input); LOGGER.info("Input text length = {}", input.length()); - final SplitService splitService = new LineWidthSplitService(500); + final SplitService splitService = new LineWidthSplitService(splitLength); final List splits = splitService.split(input); for(final String split : splits) { LOGGER.info("{} - {}", split.length(), split); - Assertions.assertTrue(split.length() < 500); + Assertions.assertTrue(split.length() <= splitLength); } + final StringBuilder sb = new StringBuilder(); + for(final String split : splits) { + sb.append(split).append(splitService.getSeparator()); + } + + Assertions.assertEquals(input, sb.toString().trim()); + } } diff --git a/phileas-services/phileas-services-split/src/test/resources/simple-test.txt b/phileas-services/phileas-services-split/src/test/resources/simple-test.txt index 41fc19442..9692c8e01 100644 --- a/phileas-services/phileas-services-split/src/test/resources/simple-test.txt +++ b/phileas-services/phileas-services-split/src/test/resources/simple-test.txt @@ -1,3 +1 @@ - Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?' - - So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her. \ No newline at end of file +George Washington was a Founding Father of the United States, military officer, and farmer who served as the first president of the United States from 1789 to 1797. Appointed by the Second Continental Congress as commander of the Continental Army in 1775, Washington led Patriot forces to victory in the American Revolutionary War. He then served as president of the Constitutional Convention in 1787, which drafted the current Constitution of the United States. Washington has thus become commonly known as the Father of his Country. Washingtons first public office, from 1749 to 1750, was as surveyor of Culpeper County in the Colony of Virginia. In 1752, he received military training and was granted the rank of major in the Virginia Regiment. During the French and Indian War, Washington was promoted to lieutenant colonel in 1754 and subsequently became head of the Virginia Regiment in 1755. He was later elected to the Virginia House of Burgesses and was named a delegate to the Continental Congress in Philadelphia, which appointed him commander-in-chief of the Continental Army. Washington led American forces to a decisive victory over the British in the Revolutionary War, leading the British to sign the Treaty of Paris, which acknowledged the sovereignty and independence of the United States. He resigned his commission in 1783 after the conclusion of the Revolutionary War. Washington played an indispensable role in the drafting of the Constitution, which replaced the Articles of Confederation in 1789. He was then twice elected president unanimously by the Electoral College in 1788 and 1792. As the first U.S. president, Washington implemented a strong, well-financed national government while remaining impartial in a fierce rivalry that emerged between cabinet members Thomas Jefferson and Alexander Hamilton. During the French Revolution, he proclaimed a policy of neutrality while additionally sanctioning the Jay Treaty. He set enduring precedents for the office of president, including republicanism, a peaceful transfer of power, the use of the title Mr. President, and the two-term tradition. His 1796 farewell address became a preeminent statement on republicanism in which he wrote about the importance of national unity and the dangers that regionalism, partisanship, and foreign influence pose to it. As a planter of tobacco and wheat, Washington owned many slaves. He grew to oppose slavery near the end of his life, and provided in his will for the manumission of his slaves. Washingtons image is an icon of American culture. He has been memorialized by monuments, a federal holiday, various media depictions, geographical locations including the national capital, the State of Washington, stamps, and currency. In 1976, Washington was posthumously promoted to the rank of general of the Armies, the highest rank in the U.S. Army. Washington consistently ranks in both popular and scholarly polls as one of the greatest presidents in American history. Abraham Lincoln was also president. \ No newline at end of file