From c6b1cb34e2698afd8ac487c3c8f843268eea6e3d Mon Sep 17 00:00:00 2001 From: Bradley Erickson Date: Fri, 13 Mar 2026 11:40:37 -0400 Subject: [PATCH] added local lorem file and removed dependency --- VERSION | 2 +- learning_observer/VERSION | 2 +- learning_observer/learning_observer/lorem.py | 33 +++++++++++++++++++ .../synthetic_student_data.py | 10 ++---- modules/lo_gpt/lo_gpt/gpt.py | 4 +-- modules/writing_observer/VERSION | 2 +- .../writing_observer/sample_essays.py | 5 +-- requirements.txt | 1 - scripts/stream_writing.py | 7 ++-- 9 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 learning_observer/learning_observer/lorem.py diff --git a/VERSION b/VERSION index 42ec10d5..d9248354 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0+2026.03.06T16.07.48.997Z.0bfff3a0.berickson.20260303.copy.paste.reducer +0.1.0+2026.03.13T15.40.37.391Z.377c68ef.berickson.20260313.local.loremipsum diff --git a/learning_observer/VERSION b/learning_observer/VERSION index 20ad2997..d9248354 100644 --- a/learning_observer/VERSION +++ b/learning_observer/VERSION @@ -1 +1 @@ -0.1.0+2026.02.27T21.25.37.849Z.3207a114.berickson.20260220.dami.portfolio.pr +0.1.0+2026.03.13T15.40.37.391Z.377c68ef.berickson.20260313.local.loremipsum diff --git a/learning_observer/learning_observer/lorem.py b/learning_observer/learning_observer/lorem.py new file mode 100644 index 00000000..04723296 --- /dev/null +++ b/learning_observer/learning_observer/lorem.py @@ -0,0 +1,33 @@ +"""Simple local lorem ipsum text generation utilities.""" + +from itertools import cycle, islice + +_LOREM_SENTENCES = [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", + "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", + "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + "Integer nec odio praesent libero sed cursus ante dapibus diam.", + "Nam dui ligula fringilla a euismod sodales sollicitudin vel wisi.", + "Aenean fermentum risus id tortor fusce tellus odio dapibus id fermentum quis suscipit id erat.", + "Etiam posuere lacus quis dolor pellentesque egestas.", + "Curabitur vitae diam non enim vestibulum interdum.", +] + + +def _paragraph(sentence_count=5, offset=0): + sentences = islice(cycle(_LOREM_SENTENCES), offset, offset + sentence_count) + return " ".join(sentences) + + +def get_paragraphs(paragraph_count, sentence_count=5): + """Return a list of lorem ipsum paragraphs. + + Args: + paragraph_count (int): Number of paragraphs to generate. + sentence_count (int): Number of sentences per paragraph. + """ + paragraph_count = max(0, int(paragraph_count)) + sentence_count = max(1, int(sentence_count)) + return [_paragraph(sentence_count=sentence_count, offset=i) for i in range(paragraph_count)] diff --git a/learning_observer/learning_observer/synthetic_student_data.py b/learning_observer/learning_observer/synthetic_student_data.py index 8bec4771..52aae3d4 100644 --- a/learning_observer/learning_observer/synthetic_student_data.py +++ b/learning_observer/learning_observer/synthetic_student_data.py @@ -1,9 +1,5 @@ ''' -Note that current loremipsum in `pip` is not Python 3 -compatible. If you are getting b'' in your text, the -patch is at: - -`https://github.com/monkeython/loremipsum/issues/10` +Synthetic student payload helpers used for mock-up UX data. ''' import random @@ -11,10 +7,10 @@ import numpy import numpy.random -import loremipsum import names import learning_observer.util as util +from learning_observer.lorem import get_paragraphs def synthetic_student_data(student_id): @@ -22,7 +18,7 @@ def synthetic_student_data(student_id): Create fake student data for mock-up UX for one student ''' name = names.get_first_name() - essay = "\n".join(loremipsum.get_paragraphs(5)) + essay = "\n".join(get_paragraphs(5)) return { 'id': student_id, 'name': name, diff --git a/modules/lo_gpt/lo_gpt/gpt.py b/modules/lo_gpt/lo_gpt/gpt.py index b3eac508..f778a61f 100644 --- a/modules/lo_gpt/lo_gpt/gpt.py +++ b/modules/lo_gpt/lo_gpt/gpt.py @@ -14,11 +14,11 @@ import aiohttp import asyncio import json -import loremipsum import os import random from learning_observer.log_event import debug_log +from learning_observer.lorem import get_paragraphs import learning_observer.prestartup import learning_observer.settings @@ -151,7 +151,7 @@ def __init__(self, **kwargs): async def chat_completion(self, prompt, system_prompt): async with LLM_SEMAPHOR['stub']: await asyncio.sleep(random.randint(5, 15)) - return "\n".join(loremipsum.get_paragraphs(1)) + return "\n".join(get_paragraphs(1)) GPT_RESPONDERS = { diff --git a/modules/writing_observer/VERSION b/modules/writing_observer/VERSION index 42ec10d5..d9248354 100644 --- a/modules/writing_observer/VERSION +++ b/modules/writing_observer/VERSION @@ -1 +1 @@ -0.1.0+2026.03.06T16.07.48.997Z.0bfff3a0.berickson.20260303.copy.paste.reducer +0.1.0+2026.03.13T15.40.37.391Z.377c68ef.berickson.20260313.local.loremipsum diff --git a/modules/writing_observer/writing_observer/sample_essays.py b/modules/writing_observer/writing_observer/sample_essays.py index 8afafdfe..9a2403c3 100644 --- a/modules/writing_observer/writing_observer/sample_essays.py +++ b/modules/writing_observer/writing_observer/sample_essays.py @@ -8,9 +8,10 @@ import os.path import random -import loremipsum import wikipedia +from learning_observer.lorem import get_paragraphs + TextTypes = Enum('TextTypes', [ "SHORT_STORY", "ARGUMENTATIVE", "LOREM", "WIKI_SCIENCE", "WIKI_HISTORY" @@ -105,7 +106,7 @@ def lorem(paragraphs=5): ''' Generate lorem ipsum test text. ''' - return "\n\n".join(loremipsum.get_paragraphs(paragraphs)) + return "\n\n".join(get_paragraphs(paragraphs)) CACHE_PATH = os.path.join(os.path.dirname(__file__), "data") diff --git a/requirements.txt b/requirements.txt index ad7eb08c..9f4a5afb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,6 @@ dash_renderjson docopt dash-bootstrap-components tsvx @ git+https://github.com/pmitros/tsvx.git@09bf7f33107f66413d929075a8b54c36ca581dae#egg=tsvx -loremipsum @ git+https://github.com/testlabauto/loremipsum.git@b7bd71a6651207ef88993045cd755f20747f2a1e#egg=loremipsum ipython ipykernel jsonschema diff --git a/scripts/stream_writing.py b/scripts/stream_writing.py index 8e08e7a2..87a98262 100644 --- a/scripts/stream_writing.py +++ b/scripts/stream_writing.py @@ -31,12 +31,12 @@ import asyncio import docopt import json -import loremipsum import names import random import sys import time +from learning_observer.lorem import get_paragraphs ARGS = docopt.docopt(__doc__) print(ARGS) @@ -97,7 +97,7 @@ def argument_list(argument, default): # TODO what is `source_files` supposed to be? # when running this script for the workshop, we should either # 1) move gpt3 texts out of writing observer (dependency hell) OR -# 2) avoid using `--gpt3` parameter and use loremipsum instead +# 2) avoid using `--gpt3` parameter and use local lorem generator instead source_files = None if ARGS["--gpt3"] is not None: @@ -105,7 +105,8 @@ def argument_list(argument, default): TEXT = writing_observer.sample_essays.GPT3_TEXTS[ARGS["--gpt3"]] STREAMS = len(TEXT) elif source_files is None: - TEXT = ["\n".join(loremipsum.get_paragraphs(int(ARGS.get("--text-length", 5)))) for i in range(STREAMS)] + TEXT = ["\n".join(get_paragraphs(int(ARGS.get("--text-length", 5)))) for i in range(STREAMS)] + print(TEXT) else: TEXT = [open(filename).read() for filename in source_files]