Skip to content

Commit 956719b

Browse files
added local lorem file and removed dependency (ArgLab#280)
1 parent 377c68e commit 956719b

9 files changed

Lines changed: 48 additions & 18 deletions

File tree

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0+2026.03.06T16.07.48.997Z.0bfff3a0.berickson.20260303.copy.paste.reducer
1+
0.1.0+2026.03.13T15.40.37.391Z.377c68ef.berickson.20260313.local.loremipsum

‎learning_observer/VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0+2026.02.27T21.25.37.849Z.3207a114.berickson.20260220.dami.portfolio.pr
1+
0.1.0+2026.03.13T15.40.37.391Z.377c68ef.berickson.20260313.local.loremipsum
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Simple local lorem ipsum text generation utilities."""
2+
3+
from itertools import cycle, islice
4+
5+
_LOREM_SENTENCES = [
6+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
7+
"Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
8+
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
9+
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
10+
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
11+
"Integer nec odio praesent libero sed cursus ante dapibus diam.",
12+
"Nam dui ligula fringilla a euismod sodales sollicitudin vel wisi.",
13+
"Aenean fermentum risus id tortor fusce tellus odio dapibus id fermentum quis suscipit id erat.",
14+
"Etiam posuere lacus quis dolor pellentesque egestas.",
15+
"Curabitur vitae diam non enim vestibulum interdum.",
16+
]
17+
18+
19+
def _paragraph(sentence_count=5, offset=0):
20+
sentences = islice(cycle(_LOREM_SENTENCES), offset, offset + sentence_count)
21+
return " ".join(sentences)
22+
23+
24+
def get_paragraphs(paragraph_count, sentence_count=5):
25+
"""Return a list of lorem ipsum paragraphs.
26+
27+
Args:
28+
paragraph_count (int): Number of paragraphs to generate.
29+
sentence_count (int): Number of sentences per paragraph.
30+
"""
31+
paragraph_count = max(0, int(paragraph_count))
32+
sentence_count = max(1, int(sentence_count))
33+
return [_paragraph(sentence_count=sentence_count, offset=i) for i in range(paragraph_count)]

‎learning_observer/learning_observer/synthetic_student_data.py‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
'''
2-
Note that current loremipsum in `pip` is not Python 3
3-
compatible. If you are getting b'' in your text, the
4-
patch is at:
5-
6-
`https://github.com/monkeython/loremipsum/issues/10`
2+
Synthetic student payload helpers used for mock-up UX data.
73
'''
84

95
import random
106

117
import numpy
128
import numpy.random
139

14-
import loremipsum
1510
import names
1611

1712
import learning_observer.util as util
13+
from learning_observer.lorem import get_paragraphs
1814

1915

2016
def synthetic_student_data(student_id):
2117
'''
2218
Create fake student data for mock-up UX for one student
2319
'''
2420
name = names.get_first_name()
25-
essay = "\n".join(loremipsum.get_paragraphs(5))
21+
essay = "\n".join(get_paragraphs(5))
2622
return {
2723
'id': student_id,
2824
'name': name,

‎modules/lo_gpt/lo_gpt/gpt.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import aiohttp
1515
import asyncio
1616
import json
17-
import loremipsum
1817
import os
1918
import random
2019

2120
from learning_observer.log_event import debug_log
21+
from learning_observer.lorem import get_paragraphs
2222
import learning_observer.prestartup
2323
import learning_observer.settings
2424

@@ -151,7 +151,7 @@ def __init__(self, **kwargs):
151151
async def chat_completion(self, prompt, system_prompt):
152152
async with LLM_SEMAPHOR['stub']:
153153
await asyncio.sleep(random.randint(5, 15))
154-
return "\n".join(loremipsum.get_paragraphs(1))
154+
return "\n".join(get_paragraphs(1))
155155

156156

157157
GPT_RESPONDERS = {

‎modules/writing_observer/VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0+2026.03.06T16.07.48.997Z.0bfff3a0.berickson.20260303.copy.paste.reducer
1+
0.1.0+2026.03.13T15.40.37.391Z.377c68ef.berickson.20260313.local.loremipsum

‎modules/writing_observer/writing_observer/sample_essays.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
import os.path
99
import random
1010

11-
import loremipsum
1211
import wikipedia
1312

13+
from learning_observer.lorem import get_paragraphs
14+
1415

1516
TextTypes = Enum('TextTypes', [
1617
"SHORT_STORY", "ARGUMENTATIVE", "LOREM", "WIKI_SCIENCE", "WIKI_HISTORY"
@@ -105,7 +106,7 @@ def lorem(paragraphs=5):
105106
'''
106107
Generate lorem ipsum test text.
107108
'''
108-
return "\n\n".join(loremipsum.get_paragraphs(paragraphs))
109+
return "\n\n".join(get_paragraphs(paragraphs))
109110

110111

111112
CACHE_PATH = os.path.join(os.path.dirname(__file__), "data")

‎requirements.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ dash_renderjson
1212
docopt
1313
dash-bootstrap-components
1414
tsvx @ git+https://github.com/pmitros/tsvx.git@09bf7f33107f66413d929075a8b54c36ca581dae#egg=tsvx
15-
loremipsum @ git+https://github.com/testlabauto/loremipsum.git@b7bd71a6651207ef88993045cd755f20747f2a1e#egg=loremipsum
1615
ipython
1716
ipykernel
1817
jsonschema

‎scripts/stream_writing.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
import asyncio
3232
import docopt
3333
import json
34-
import loremipsum
3534
import names
3635
import random
3736
import sys
3837
import time
3938

39+
from learning_observer.lorem import get_paragraphs
4040

4141
ARGS = docopt.docopt(__doc__)
4242
print(ARGS)
@@ -97,15 +97,16 @@ def argument_list(argument, default):
9797
# TODO what is `source_files` supposed to be?
9898
# when running this script for the workshop, we should either
9999
# 1) move gpt3 texts out of writing observer (dependency hell) OR
100-
# 2) avoid using `--gpt3` parameter and use loremipsum instead
100+
# 2) avoid using `--gpt3` parameter and use local lorem generator instead
101101
source_files = None
102102

103103
if ARGS["--gpt3"] is not None:
104104
import writing_observer.sample_essays
105105
TEXT = writing_observer.sample_essays.GPT3_TEXTS[ARGS["--gpt3"]]
106106
STREAMS = len(TEXT)
107107
elif source_files is None:
108-
TEXT = ["\n".join(loremipsum.get_paragraphs(int(ARGS.get("--text-length", 5)))) for i in range(STREAMS)]
108+
TEXT = ["\n".join(get_paragraphs(int(ARGS.get("--text-length", 5)))) for i in range(STREAMS)]
109+
print(TEXT)
109110
else:
110111
TEXT = [open(filename).read() for filename in source_files]
111112

0 commit comments

Comments
 (0)