Formulaic Density Summaries - warwickfoster/qurantools GitHub Wiki

File: app/formulae/formulaic_density_by_verse.php

Purpose

The code snippet you provided is a PHP script that generates an HTML table displaying formulaic density by verse for a given set of parameters.

Key Features

  • Database Query The script queries a database to retrieve data about verses, including word count and formulaic density.
  • Data Table The retrieved data is displayed in a HTML table with columns for verse number, word count, formulaic density, and a chart icon.
  • Chart Tooltips The script uses the Tipped.js library to provide tooltips for the chart icon, allowing users to view a mini chart of formulaic density for each verse.
  • Footer The script includes a footer with a summary of the total number of verses, words, and formulaic density.

Code Breakdown

  • Database Query The db_query() function executes a SQL query to retrieve the required data.
  • Data Table Creation The query results are iterated over to create HTML table rows, each representing a single verse.
  • Chart Icon The script includes an <a> tag with a class="chart-tip" attribute, which triggers the Tipped.js tooltip when hovered over.
  • Footer The footer calculates and displays the total number of verses, words, and formulaic density.

Usage

This script is intended to be used within an HTML document that includes the necessary JavaScript libraries (Tipped.js, jQuery). When run, it will generate an interactive table that allows users to view formulaic density data for each verse.

Additional Notes

  • The db_query(), db_rowcount(), and db_return_row() functions are assumed to be defined within the code base.
  • The plural() function is not included in the code snippet.
  • The specific SQL query and database schema are not provided, as they are not part of the code snippet.

Conclusion

The PHP script you provided is a comprehensive solution for displaying formulaic density data by verse. It provides an interactive and informative interface for users to explore this linguistic concept.