Koinos: PHP Library for working with References and Greek

Bible Study software, Unicode, Fonts, Keyboards, creating Web pages in Greek, and other software issues.
Post Reply
Nigel Chapman
Posts: 74
Joined: June 3rd, 2011, 4:55 pm
Location: Sydney Australia
Contact:

Koinos: PHP Library for working with References and Greek

Post by Nigel Chapman »

Here's a PHP library (also composer package and Symfony Bundle, though can be used by itself).

It's good at matching, manipulating and DB querying for complex biblical references, and at manipulating Unicode Greek text.

https://github.com/eukras/koinos

This is MIT licensed, so feel free to fork and mod. There is a large Unit Test suite, so you'll know immediately if you've broken anything.

INTRO

Libraries are defined in CSV files (Resources/libraries/nt/books.csv, and easy to add more):

Code: Select all

107,NT,1 Corinthians,1 Cor,1cor,2,1co,16
To query that book:

Code: Select all

use Koinos\Bundle\KoinosBundle\Service\ReferenceManager;
$rm = new ReferenceManager($libraries=['nt', 'lxx']); 

$ref1 = $rm->createReferenceFromQuery('1 Cor 16:1-5,8,10-12,13-14'); 
echo $rm->getTitle($ref1);  //  1 Corinthians 16:1-5,8,10-14 -- note merged ranges
It can match references in texts and turn them into links, or can identify if they exist in parallels (pipe-separated).

Internally, references are arrays of ranges [start, finish], each value being a quadruple of [bookId, sectionNum, chapterNum, verseNum]. These map to INT(12)s for efficient SQL querying:

Code: Select all

echo $ref1->getSqlClause($columnName='reference'); 

//  (reference BETWEEN 107001016001 AND 107001016005) OR 
//  (reference BETWEEN 107001016008 AND 107001016008) OR 
//  (reference BETWEEN 107001016010 AND 107001016014)  
The Greek utility provides a bundle of useful tools, incl. some for scanning texts, and can romanize any word in the Perseus dataset:

Code: Select all

use Koinos\Bundle\KoinosBundle\Utility\Greek;
$g = new Greek; 

echo $g->romanize('Ῥύγχος');   //  Rhunchos
echo $g->romanize('Ἡσυχάζω');  //  Hēsuchazō
echo $g->romanize('Αὑτοῖσι');  //  Hautoisi


Plenty more info in the README.md, code doc and Test suites...
"When eras die their legacies are left to strange police." -- Clarence Day
Nigel Chapman | http://chapman.id.au
Nigel Chapman
Posts: 74
Joined: June 3rd, 2011, 4:55 pm
Location: Sydney Australia
Contact:

Re: Koinos: PHP Library for working with References and Gree

Post by Nigel Chapman »

This is now a framework-independent composer library.

See v1.1.1 at https://github.com/eukras/koinos
"When eras die their legacies are left to strange police." -- Clarence Day
Nigel Chapman | http://chapman.id.au
Nigel Chapman
Posts: 74
Joined: June 3rd, 2011, 4:55 pm
Location: Sydney Australia
Contact:

Re: Koinos: PHP Library for working with References and Gree

Post by Nigel Chapman »

Koinos is now running a site of mine called http://hexap.la. It auto-tweets a daily Greek link on https://twitter.com/hexap_la (which echoes to facebook).

The site may be useful for easily linking to parallel passages, e.g. today's tweet: http://hexap.la/matt+1.2-17'luke+3.23-38.

I'm expecting to open source more of this as it stabilizes.
"When eras die their legacies are left to strange police." -- Clarence Day
Nigel Chapman | http://chapman.id.au
Post Reply

Return to “Software”