Wie kann man ein Wörterbuch / eine Wortliste optimieren?

403
OKCarl

Ich habe eine Kopie einer 4.09 GB-Wortliste / eines Wörterbuchs crackstation.txt. Jetzt sind die Wörter und Zahlen in der üblichen Reihenfolge angeordnet:

0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStT uUvVwWxXyYzZ 

Wie ordne ich die Reihenfolge wie folgt an:

tTaAsShHwWiIoObBmMfFcCdDpPnNeEgGrRyYuUvVjJkKqQzZxX 1023985467 

Diese Sequenz gibt die ersten Buchstaben der englischen Wörter in der Reihenfolge ihrer Beliebtheit an, von den beliebtesten (links) bis zu den am wenigsten populären (rechts)

0

1 Antwort auf die Frage

1
Xen2050

Using some tools like grep, sed, awk, & sort you can implement some answers from this other site. They include (if you wanted b then d then everything else normally):

Pull out lines in the order desired, starting with the first, then second, etc"

grep '^b' myfile > outfile grep '^d' myfile >> outfile grep -v '^b' myfile | grep -v '^d' | sort >> outfile 

Add your custom "sort key" first, then sort, then remove it later:

sed -e 's/^b/0&/' -e t -e 's/^d/1&/' -e 't' -e 's/^/2/' | sort | sed 's/^.//' 

The easiest looks to be:

use a language such as Perl, Python or Ruby that lets you easily specify a custom sort function.

perl -e 'print sort {($b =~ /^[bd]/) - ($a =~ /^[bd]/) || $a cmp $b} <>' python -c 'import sys; sys.stdout.write(sorted(sys.stdin.readlines(), key=lambda s: (0 if s[0]=="b" else 1 if s[0]=="d" else 2), s))' 

Or try awk (no explanation given, YMMV):

sort myfile | awk '$0 ~ /^b/ || $0 ~ /^d/ $0 !~ /^b/ && $0 !~ /^d/ { a[f++] = $0 } END { for (word = 0; word < f; word++) { print a[word] } }'