File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ import numpy as np
2+ import pandas as pd
3+ from collections import defaultdict
4+
5+
6+ def scavenger_hunt () -> dict :
7+ pass
8+
9+
10+ def get_words (file_path ) -> list :
11+ pass
12+
13+
14+ def get_ngrams (words , size ) -> list :
15+ pass
16+
17+
18+ def get_counts (n_grams ) -> dict :
19+ pass
20+
21+
22+ def generate_gram (counts , context ) -> str :
23+ pass
24+
25+
26+ def generate_sentence (counts , context , length = 10 ) -> list :
27+ pass
28+
29+
30+ def stringify (sentence ) -> list :
31+ return " " .join (" " .join (gram ) for gram in sentence )
32+
33+
34+ if __name__ == '__main__' :
35+ # create model
36+ words = get_words ('corpus.txt' )
37+ n_grams = get_ngrams (words , 1 )
38+ counts = get_counts (n_grams )
39+
40+ # generate text
41+ context = n_grams [np .random .choice (len (n_grams ))]
42+ sentence = generate_sentence (counts , context , length = 50 )
43+ print (stringify (sentence ))
You can’t perform that action at this time.
0 commit comments