calculate frequency of bigrams in text

This commit is contained in:
Kuba 2023-03-21 22:31:17 +01:00
parent 2afff87ba0
commit d6be2a2ce9

4
analysis/bigrams_freq.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# Convert text to lowercase and replace non-alphabetic characters with spaces, then use awk to print bigrams
bzcat $1 | tr '[:upper:]' '[:lower:]' | tr -cs '[:alpha:]' ' ' | fold -w 1000 | sed -e 's/\b\s\+\b/ /g' | awk '{for(i=1;i<NF;i++)print $i,$(i+1)}' | sort | uniq -c > bigram_freq.txt