How to load the letter and their log probabilities in database.txt into our program?

1 view (last 30 days)
I have a txt file and I need to add this txt file into my program to access the unigram and bigram database.
Is there any way I could load it into the program directly without hardcoding/copy and paste?
***********************************************************
**** This table is the log_2
**** probability of letter unigrams
**** i.e., log_2(p('a letter'))
**** Note: the unigram and probability are tab delimited
***********************************************************
a -3.561879942602564
b -6.036018896964266
c -4.9663355149956425
***********************************************************
**** This table is the log_2
**** probability of letter bigrams
**** i.e., log_2(p('first letter, second letter'))
**** Note: the bigram and probability are tab delimited
***********************************************************
aa -11.077395929707704
ab -9.279102981402742
ac -7.9797285896725825
ad -8.160340354667962
ae -11.752348492976163

Accepted Answer

Jeff Miller
Jeff Miller on 4 Apr 2020
This function on FileExchange simply returns a long list of all the numbers in the file. Since it looks like your file has the numbers in a pre-determined order with no extraneous numbers, it might do what you want.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!