implement randomly collect sentences from files
This commit is contained in:
parent
a20c845005
commit
40ec084c6a
|
@ -8,10 +8,10 @@ made after seeing [https://asteine8.github.io/projects/pronoun-dressing-room/dre
|
|||
copy it into your gemini directory and make it executable of course
|
||||
|
||||
## TODO
|
||||
* randomly collect sentences from files [opened: 2022-03-14T16:45:30Z]
|
||||
* [ ] add a lot of sentences
|
||||
* [ ] make the program select a random selection (like 3 or 4 of them)
|
||||
* [ ] make that optional
|
||||
* randomly collect sentences from files [opened: 2022-03-14T16:45:30Z; closed: 2022-09-18T14:02:00Z]
|
||||
* [X] add a lot of sentences
|
||||
* [X] make the program select a random selection (like 3 or 4 of them)
|
||||
* [X] make that optional
|
||||
|
||||
* more flexibility [opened: 2022-05-30T14:14:00Z; closed: 2022-05-31T13:13:30Z]
|
||||
* [X] add another file for pronouns instead of having them hardcoded.
|
||||
|
@ -36,3 +36,4 @@ copy it into your gemini directory and make it executable of course
|
|||
* 2022-09-18: provide link to repository
|
||||
* 2022-09-18: unhardcode plural grammar
|
||||
* 2022-09-18: fix orthographic mistakes
|
||||
* 2022-09-18: implement randomly collect sentences from files
|
||||
|
|
21
index.gmi
21
index.gmi
|
@ -2,6 +2,9 @@
|
|||
|
||||
_link="https://tildegit.org/konomo/gem-pd"
|
||||
readonly _link
|
||||
_runthru=1 # whether or not a random selection of sentences should be taken
|
||||
readonly _runthru
|
||||
_sentences=6 # how many sentences are displayed
|
||||
|
||||
if [[ -z "$QUERY_STRING" ]]; then
|
||||
printf "10 Please enter your name. You may add ; and your preferred pronoun\r\n"
|
||||
|
@ -24,6 +27,24 @@ printf "# Pronoun Dressing Room for %s" "$name"
|
|||
while read sentence; do
|
||||
sentences+=("${sentence}"); done < sentences
|
||||
|
||||
if [[ "${_runthru}" -eq 1 ]]; then
|
||||
prevs=()
|
||||
sentarr=()
|
||||
for (( i = 0; i < ${_sentences}; i++ )); do
|
||||
while
|
||||
ran=$(( RANDOM % ${_sentences} + 0))
|
||||
[[ "${prevs[@]}" =~ "${ran}" ]] # generate new random numbers until it isn't already in array
|
||||
do true; done
|
||||
|
||||
prevs+=(${ran})
|
||||
sentarr+=("${sentences[${ran}]}")
|
||||
done
|
||||
|
||||
prevs=() # prevs is no longer needed
|
||||
sentences=() # empty original array
|
||||
sentences=("${sentarr[@]}")
|
||||
fi
|
||||
|
||||
pr_sub=( $(tail -n +2 pronouns.csv | cut -d ',' -f1) )
|
||||
pr_obj=( $(tail -n +2 pronouns.csv | cut -d ',' -f2) )
|
||||
pr_psd=( $(tail -n +2 pronouns.csv | cut -d ',' -f3) )
|
||||
|
|
Loading…
Reference in New Issue