1
0
Fork 0
mirror of https://github.com/Findus23/nonsense.git synced 2024-09-19 16:03:50 +02:00

Erster Commit

This commit is contained in:
Findus23 2015-02-08 12:13:45 +01:00
commit fe427c8552
7 changed files with 166 additions and 0 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
*.pdf
*.bak
*.tmp
tmp
*.txt

1
README.md Normal file
View file

@ -0,0 +1 @@
# nonsense

28
descr.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
rm nomen.txt
rm adj.txt
grep -E -o '(\w|\.|\-)+' descr.txt | sort | uniq > descr_words.txt
while read line; do
if [ $(echo $line | cut -c 1) == "-" ]
then
echo $line >> suf.txt
echo "Suffix"
elif [ $(echo $line | rev | cut -c 1) == "-" ]
then
echo $line >> präf.txt
echo "Präfix"
elif echo $line | grep [[:upper:]] >/dev/null
then
if echo $line | grep [[:lower:]] >/dev/null
then #Groß und Klein-> Nomen
echo $line >>nomen.txt
echo "Nomen"
fi # nur Groß -> Ikeaname -> verwerfen
elif echo $line | egrep "([[:lower:]]){3,}" >/dev/null
then # keine Großbuchstaben, aber Kleinbuchstaben -> kein Nomen
echo $line >>adj.txt
echo "kein Nomen"
#weder Großbuchstaben noch Kleinbuchstaben -> Zahl -> verwerfen
fi
done <descr_words.txt

48
descr_gen.sh Executable file
View file

@ -0,0 +1,48 @@
#!/bin/bash
if [ ! -z $1 ]
then
loops=$1
else
loops=1
fi
i=0
function nomen {
if [ $(shuf -i 0-10 -n 1) == "1" ]
then
praf=$(shuf -n 1 präf.txt)
echo "$praf$(nomen)"
elif [ $(shuf -i 0-10 -n 1) == "2" ]
then
suf=$(shuf -n 1 suf.txt)
echo "$(nomen)$suf"
else
echo $(shuf -n 1 nomen.txt)
fi
}
while [ $i -lt $loops ]
do
ikeaname=$(./ikeagen.py)
text=$(nomen)
# adj_count=$(shuf -i 0-2 -n 1)
adj_count=$(python -c "import random;print '{:1.0f}'.format(round(random.gauss(1.0,1.0)))")
a=0
while [ $a -lt $adj_count ]
do
if [ $(shuf -i 0-4 -n 1) == "0" ]
then
adj="mit $(shuf -n 1 nomen.txt)"
else
adj=$(shuf -n 1 adj.txt)
fi
text="$text $adj"
((a++))
done
if [ ! -z $2 ] && [ $2 == "tex-export" ]
then
echo "$ikeaname & $text \\\\"
else
echo -e "$ikeaname:\t$text"
# espeak -vde+m2 "$ikeaname: $text"
fi
((i++))
done

45
ikeagen.py Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/python3
import random
import sys
table= [ [ 0 for i in range(2210) ] for j in range(2210) ]
contents = open("ikeaname.txt").read().splitlines()
anzahl=0
for name in contents:
name= " " + name + " "
zeichen=list(name)
zeichenl=len(zeichen)
zeichenl += -1
a=0
while a < zeichenl:
table[ord(zeichen[a])][ord(zeichen[a+1])] +=1
anzahl +=1
a +=1
#row=0
#col=0
#for coln in range(221):
# for rown in range(221):
# if table[coln][rown] != 0:
# print(table[coln][rown],chr(rown),chr(coln))
#print(anzahl)
def letter(a):
mylist=[]
for b in range(221):
for x in range(table[a][b]):
mylist.append(b)
return random.choice(mylist)
try:
num=int(sys.argv[1])
except:
num=1
textnr=0
while textnr < num:
a=32
wort=[]
while a != 32 or wort == []:
a=letter(a)
wort.append(chr(a))
if len(wort) > 3:
print("".join(wort))
textnr +=1

23
liste.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
rm ikeaname.txt
rm descr.txt
for i in {0..25}
do
wget -O download.tmp http://www.ikea.com/at/de/catalog/productsaz/$i/
grep "productsAzLink" download.tmp > lines.tmp
while read line; do
name=$(echo $line | xmllint --xpath 'string(//a)' -)
ikeaname=$(echo "$name" | egrep -o "((([A-Z])+){2,} *)+")
descr=${name#$ikeaname}
echo $ikeaname >> ikeaname.txt
echo $descr >> descr.txt
done <lines.tmp
done
rm *.tmp
sort ikeaname.txt | uniq > ikeaname.txt.tmp
sort descr.txt | uniq > descr.txt.tmp
mv ikeaname.txt.tmp ikeaname.txt
mv descr.txt.tmp descr.txt

16
tex.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
inhalt=$(./descr_gen.sh $1 tex-export)
echo $inhalt
echo "\documentclass[14pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\author{Lukas Winkler}
\begin{document}
\begin{tabular}{rl}
$inhalt
\end{tabular}
\end{document}" > IKEA.tex
pdflatex IKEA.tex
rm IKEA.tex IKEA.log IKEA.aux