function markov_letters_test ( )

%*****************************************************************************80
%
%% markov_letters_test() tests markov_letters().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 August 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../markov_letters' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'markov_letters_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test markov_letters().\n' );

  filename = 'abc.txt';
  freq1 = unigram_frequency ( filename );
  c = unigram_values ( );
  label = sprintf ( 'Unigram frequency from "%s"', filename );
  unigram_frequency_print ( c, freq1, label );
  freq2 = bigram_frequency ( filename );
  label = sprintf ( 'Bigram frequency from "%s"', filename );
  bigram_frequency_print ( freq2, label );

  filename = 'quick_brown_fox.txt';
  freq1 = unigram_frequency ( filename );
  c = unigram_values ( );
  label = sprintf ( 'Unigram frequency from "%s"', filename );
  unigram_frequency_print ( c, freq1, label );
  freq2 = bigram_frequency ( filename );
  label = sprintf ( 'Bigram frequency from "%s"', filename );
  bigram_frequency_print ( freq2, label );

  filename = 'panjandrum.txt';
  freq1 = unigram_frequency ( filename );
  c = unigram_values ( );
  c = c(1:26);
  freq1 = freq1(1:26);
  [ freq1_sorted, index ] = sort ( freq1, 'descend' );
  c_sorted = c(index);
  label = sprintf ( 'Unigram frequency from "%s"', filename );
  label_sorted = sprintf ( 'Sorted unigram frequency from "%s"', filename );
  unigram_frequency_print ( c, freq1, label );
  unigram_frequency_print ( c_sorted, freq1_sorted, label_sorted );
  unigram_frequency_plot ( c, freq1, label );
  print ( '-dpng', 'panjandrum_unigram.png' );
  unigram_frequency_plot ( c_sorted, freq1_sorted, label_sorted );
  print ( '-dpng', 'panjandrum_unigram_sorted.png' );
  freq2 = bigram_frequency ( filename );
  label = sprintf ( 'Bigram probability from "%s"', filename );
  bigram_probability_print ( freq2, label );

  filename = 'alice_in_wonderland.txt';
  freq1 = unigram_frequency ( filename );
  c = unigram_values ( );
  c = c(1:26);
  freq1 = freq1(1:26);
  [ freq1_sorted, index ] = sort ( freq1, 'descend' );
  c_sorted = c(index);
  label = sprintf ( 'Unigram frequency from "%s"', filename );
  label_sorted = sprintf ( 'Sorted unigram frequency from "%s"', filename );
  label_sorted_plot = s_escape_tex ( label_sorted );
  label_plot = s_escape_tex ( label );
  unigram_frequency_print ( c, freq1, label );
  unigram_frequency_print ( c_sorted, freq1_sorted, label_sorted );
  unigram_frequency_plot ( c, freq1, label_plot );
  print ( '-dpng', 'alice_unigram.png' );
  unigram_frequency_plot ( c_sorted, freq1_sorted, label_sorted_plot );
  print ( '-dpng', 'alice_unigram_sorted.png' );
  freq2 = bigram_frequency ( filename );
  label = sprintf ( 'Bigram probability from "%s"', filename );
  bigram_probability_print ( freq2, label );

  filename = 'die_verwandlung.txt';
  freq1 = unigram_frequency ( filename );
  c = unigram_values ( );
  c = c(1:26);
  freq1 = freq1(1:26);
  [ freq1_sorted, index ] = sort ( freq1, 'descend' );
  c_sorted = c(index);
  label = sprintf ( 'Unigram frequency from "%s"', filename );
  label_sorted = sprintf ( 'Sorted unigram frequency from "%s"', filename );
  label_sorted_plot = s_escape_tex ( label_sorted );
  label_plot = s_escape_tex ( label );
  unigram_frequency_print ( c, freq1, label );
  unigram_frequency_print ( c_sorted, freq1_sorted, label_sorted );
  unigram_frequency_plot ( c, freq1, label_plot );
  print ( '-dpng', 'die_verwandlung_unigram.png' );
  unigram_frequency_plot ( c_sorted, freq1_sorted, label_sorted_plot );
  print ( '-dpng', 'die_verwandlung_unigram_sorted.png' );
  freq2 = bigram_frequency ( filename );
  label = sprintf ( 'Bigram probability from "%s"', filename );
  bigram_probability_print ( freq2, label );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'markov_letters_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../markov_letters' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

