IbycusAuthTab


Description

IbycusAuthTab is the interface to the AUTHTAB.DIR file which lists the contents of each PHI/TLG disk. Each AUTHTAB.DIR contains one or more "corpora", each of which contains one or more authors, and has a "tag" and a name. For instance, the PHI disk contains three corpora:

Tag Name
LAT Latin Texts
CIV Miscellaneous Works
COP Coptic Texts

Each author has an ID, a name, and may have "aliases" (e.g., Marcus Tullius Cicero, has the aliases "Cicero" and "Tully", Publius Vergilius Maro the aliases "Vergil" and "Virgil"). The author's ID can be used to open up that author's .IDT and .TXT files.

Constructor Index

Method Index


Constructors

CTlgAuthTab()

Default Constructor.

CTlgAuthTab(const ibystring_t & dn, const ibystring_t & fn = "AUTHTAB.DIR") throw(IbyFileException, IbyParseException)

Parameters

Throws

Opens up the AUTHTAB.DIR in directory dn.


Methods

int Count() const

Returns

int Count(const ibystring_t & tag) const throw(IbyException)

Parameters

Returns

Throws

int Count(int index) const throw(IbyException)

Parameters

Returns

Throws

int Index(const ibystring_t & tag) const throw(IbyException)

Parameters

Returns

Throws

const ibystring_t & Name(int index) const

Parameters

Returns

const ibystring_t & Name(int corpus, int author) const throw(IbyException)

Parameters

Returns

Throws

const ibystring_t & Id(int corpus, int author) const throw(IbyException)

Parameters

Returns

Throws

const ibystring_t & Tag(int index) const

Parameters

Returns

Throws

int AliasCount(int corpus, int author) const throw(IbyException)

Parameters

Returns

Throws

const ibystring_t & Alias(int corpus, int author, int alias) const throw(IbyException)

Parameters

Returns

Throws

Example

Given a directory and a string, this program searches the AUTHTAB.DIR file for the string in authors names and prints out the result along with some statistics about AUTHTAB.DIR


/* 
 * A Sample program to search the AUTHTAB.DIR for an
 * author's name
 *
 * Copyright (c) 2000  Sean Redmond
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

#include "TlgAuthTab.h"

typedef map<ibystring_t, ibystring_t, less<ibystring_t> > HITMAP;

int main(int argc, char *argv[])
{
   if (argc <= 1)
      return 1;

   ibystring_t term, name;
   ibystring_t dir = "c:\\musaios\\phi";
   term = argv[1];
   cout << "Search author table for: " << term << "\n";
   HITMAP hitlist;

   CTlgAuthTab at = CTlgAuthTab(dir);
	
   cout << "# of Corpora: " << at.Count() << "\n";
	
	
   try {
      cout << "# of Authors in LAT: " << at.Count("LAT") << "\n";
      cout << "# of Authors in 0: " << at.Count(0) << "\n"; // same as LAT
      cout << "Name of corpus 1: " << at.Name(1) << "\n";
      cout << "Tag of corpus 2: " << at.Tag(2) << "\n";
      cout << "# of Authors in ABC: " << at.Count("ABC") << "\n"; // causes an exception
   } catch(IbyException E) {
      cout << E.message << "\n"; // handles the exception
   }

   int i, j, k;
   for (i = 0; i < at.Count(); i++) {                  // iterate through the corpora
      for(j = 0; j < at.Count(i); j++) {               // iterate through the authors
         name = at.Name(i, j);
         transform(name.begin(), name.end(), name.begin(), tolower);
         if (name.find(term) != name.npos) {
            hitlist[at.Name(i, j)] = at.Id(i, j);
         } else {                                         // if no match...
            for (k = 0; k < at.AliasCount(i,j); k++) { // iterate through the aliases
               name = at.Alias(i,j,k);
               transform(name.begin(), name.end(), name.begin(), tolower);
               if (name.find(term) != name.npos) {
                  hitlist[at.Name(i, j)] = at.Id(i, j);
               }
            }
         }
      }
   }

   cout << hitlist.size() << " authors:\n";

   HITMAP::iterator it;
   for (it = hitlist.begin(); it != hitlist.end(); ++it)
      cout << (*it).second << '\t' << (*it).first << '\n';
   return 1;

}
C:\>authsearch tull
Search author table for: tull
# of Corpora: 3
# of Authors in LAT: 363
# of Authors in 0: 363
Name of corpus 1: Miscellaneous Works
Tag of corpus 2: COP
No corpus with the tag ABC
5 authors:
LAT0472 Catullus, Gaius Valerius
LAT0474 Cicero, Marcus Tullius
LAT0478 Cicero, Quintus Tullius
LAT0540 Laurea, Tullius
LAT0662 Tiro, Marcus Tullius