diff --git a/README.md b/README.md
index 3fdfc0a..28e686c 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,7 @@ at the [blog post for the project][blog].
list Lists commands
pdf Generate a PDF from a markdown file
selfupdate Updates md2resume.phar to the latest version.
+ stats Generate a word frequency analysis of your resume
templates List available templates
version Show current version information
diff --git a/bin/md2resume b/bin/md2resume
index 483b6b1..8069314 100755
Binary files a/bin/md2resume and b/bin/md2resume differ
diff --git a/src/Resume/Cli/Resume.php b/src/Resume/Cli/Resume.php
index 079123d..dc025ce 100644
--- a/src/Resume/Cli/Resume.php
+++ b/src/Resume/Cli/Resume.php
@@ -38,6 +38,7 @@ class Resume extends Application
$this->add(new Command\HtmlCommand());
$this->add(new Command\PdfCommand());
$this->add(new Command\SelfUpdateCommand());
+ $this->add(new Command\StatsCommand());
$this->add(new Command\TemplatesCommand());
$this->add(new Command\VersionCommand());
diff --git a/src/Resume/Command/StatsCommand.php b/src/Resume/Command/StatsCommand.php
new file mode 100644
index 0000000..774a605
--- /dev/null
+++ b/src/Resume/Command/StatsCommand.php
@@ -0,0 +1,97 @@
+setName('stats')
+ ->setDescription('Generate a word frequency analysis of your resume')
+ ->addArgument(
+ 'source',
+ InputArgument::REQUIRED,
+ 'Source markdown document'
+ );
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->app = $this->getApplication();
+ $source = $input->getArgument('source');
+
+ $text = file_get_contents($source);
+ $text = $this->stripCommon($text);
+ $analysis = array(
+ 'single' => $this->buildStats($text, 1),
+ 'double' => $this->buildStats($text, 2),
+ 'triple' => $this->buildStats($text, 3),
+ );
+
+ $template = $this->app->twig->loadTemplate('frequency.twig');
+ $view = $template->render($analysis);
+ $output->write($view, true, $this->app->outputFormat);
+
+ return true;
+ }
+
+ private function stripCommon($content)
+ {
+ $content = preg_replace("/(,|\"|\.|\?|:|!|;|#|-|>|{|\*| - )/", " ", $content);
+ $content = preg_replace("/\n/", " ", $content);
+ $content = preg_replace("/\s\s+/", " ", $content);
+ $content = explode(" ", $content);
+
+ return $content;
+ }
+
+ // source: https://github.com/benbalter/Frequency-Analysis/blob/master/frequency-analysis.php
+ private function buildStats($input, $num)
+ {
+ $results = array();
+
+ foreach ($input as $key => $word) {
+ $phrase = '';
+
+ //look for every n-word pattern and tally counts in array
+ for ($i=0; $i < $num; $i++) {
+ if ($i != 0) {
+ $phrase .= ' ';
+ }
+ if (!empty($input[$key+$i])) {
+ $phrase .= strtolower($input[$key+$i]);
+ }
+ }
+ if (!isset( $results[$phrase])) {
+ $results[$phrase] = 1;
+ } else {
+ $results[$phrase]++;
+ }
+ }
+ if ($num == 1) {
+ //clean boring words
+ $a = explode(
+ " ",
+ "the of and to a in that it is was i for on you he be with as by " .
+ "at have are this not but had his they from she which or we an there " .
+ "her were one do been all their has would will what if can when so my"
+ );
+ foreach ($a as $banned) {
+ unset($results[$banned]);
+ }
+ }
+
+ //sort, clean, return
+ array_multisort($results, SORT_DESC);
+ unset($results[""]);
+
+ return $results;
+ }
+}
+
+/* End of file StatsCommand.php */
diff --git a/src/Resume/Templates/frequency.twig b/src/Resume/Templates/frequency.twig
new file mode 100644
index 0000000..429b4a6
--- /dev/null
+++ b/src/Resume/Templates/frequency.twig
@@ -0,0 +1,24 @@
+————————————————————————————————————————————————————————————————————————————————
+ Word Frequency Analysis
+————————————————————————————————————————————————————————————————————————————————
+
+Triple Word Phrases:
+{% for phrase, frequency in triple %}
+{% if frequency > 1%}
+{{frequency|style("info")|pad(3, "right")}} {{phrase}}
+{% endif %}
+{% endfor %}
+
+Double Word Phrases:
+{% for phrase, frequency in double %}
+{% if frequency > 1%}
+{{frequency|style("info")|pad(3, "right")}} {{phrase}}
+{% endif %}
+{% endfor %}
+
+Single Words:
+{% for phrase, frequency in single %}
+{% if frequency > 1%}
+{{frequency|style("info")|pad(3, "right")}} {{phrase}}
+{% endif %}
+{% endfor %}