Natural Language Generation
Table 3.4: The impact of NLG
Template-Based NLG
Selection-Based NLG
Rule-Based NLG
Machine Learning-Based NLG
Using Template-Based NLG
quality check: if the chosen candidate is not semantically similar enough to
Using Selection-Based NLG
Networkx Library
Louvain Algorithm
Get_communities() Function
Now that all the words have been mapped to a community
Evaluate_sentences() Function
The original doc includes a total of 61 sentences. The following code can now be used to get the top 3 most important of these sentences:
The results verify this approach can indeed successfully
Using Rule-Based NLG to Create a Chatbot
2. Create a Simple Knowledge Base
This simple knowledge can be easily extended to add more Q/A levels and make the chatbot more intelligent.
Chat() Function
Interaction 2
Using Machine Learning to Generate Realistic Text
We had dinner at this restaurant yesterday.
This leads to a much more diverse output, while maintaining the authenticity of the generated text. The text uses a rich vocabulary and is syntactically correct.
Read the sentences and tick True or False.
Compare the different approaches of Natural Language Generation (NLG).
State three different applications for NLG.
Complete the following code so that the build_graph()
Complete the following code so that the function get_max_sim()