Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

boss_numbers.h

Go to the documentation of this file.
00001 /* boss_numbers.h    $Revision: 1.2 $ $Date: 2005/12/10 20:33:54 $
00002    Copyright (C) 2000 University of Bonn.
00003    http://www.ikp.uni-bonn.de/boss
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA  02111-1307, USA.
00019 */
00020 
00025 #ifndef BOSS_NUMBERS_H
00026 #define BOSS_NUMBERS_H
00027 #include "boss_utility/boss_types.h"
00028 #include <fstream>
00029 #include <set>
00030 #include <iterator>
00031 
00036 // Struct for a table entry
00037 // (number of digits of the number, number, word, transcription of the word)
00038 struct NW_mapper
00039 {
00040         unsigned length;
00041         string number;
00042         string n_word;
00043         string n_tra;
00044         NW_mapper() {;}
00045         NW_mapper(unsigned l, string n, string w, string t) : length(l), number(n), n_word(w), n_tra(t) {;}
00046 };
00047 
00048 // a vector of ZW_mapper Structs (corresponds to the assignment table as a file)
00049 typedef vector<struct NW_mapper> NW_Vector;
00050 
00051 /**************************************************************************************************
00052     The class "BOSS_Numbers" converts "signed float" numbers. A string of digits is transformed into a
00053     string of orthographic words. The constructor "BOSS_Numbers::BOSS_Numbers(const char* file)" is called
00054     with the file name of the table containing the entries of the names of the numbers
00055     ("nominal_word_tab.txt"). The "public" member functions are "string BOSS_Numbers::operator ()
00056     (string input_number) const" and "t_SSPair BOSS_Numbers::operator()(const string& input_number) const".
00057     The class "ordinal" is derived from class "BOSS_Numbers".
00058 */
00059 class BOSS_Numbers {
00060 protected:      
00061   NW_Vector table;
00062   set<string> specials; 
00063         
00064   virtual BOSS::t_SSPair patch(BOSS::t_SSPair number, BOSS::t_SSPair name) const;
00065   virtual BOSS::t_SSPair get_number(const string& input_number) const;
00066   virtual BOSS::t_SSPair get_name(const unsigned& length) const;
00067   virtual BOSS::t_SSPair convert(string input_number) const;
00068         
00069 public:
00070   virtual BOSS::t_SSPair roman(const string& input) const = 0;
00071   virtual BOSS::t_SSPair operator () (string input_number) const = 0;
00072   BOSS_Numbers() {};
00073   virtual ~BOSS_Numbers() {};
00074 };
00075 
00076 
00077 
00079 inline istream & operator >> (istream & in, NW_mapper & m) {
00080         return in >> m.length >> m.number >> m.n_word >> m.n_tra;
00081 }
00082 
00083 inline ostream & operator << (ostream & out, const NW_mapper & m) {
00084         return out << m.length << " " << m.number << " " << m.n_word << " " << m.n_tra;
00085 }
00086 
00088 inline istream & operator >> (istream & in, NW_Vector & v) {
00089         copy(istream_iterator< NW_mapper >(in), istream_iterator< NW_mapper >(), back_inserter(v));
00090         return in;
00091 }
00092 
00093 inline ostream & operator << (ostream & out, const NW_Vector & v) {
00094         copy(v.begin(), v.end(), ostream_iterator< NW_mapper >(out, "\n"));
00095         return out;
00096 }
00097 
00098 // '+' operator for t_SSPair
00099 inline BOSS::t_SSPair operator + (BOSS::t_SSPair a, const BOSS::t_SSPair& b) {
00100         a.first=a.first+b.first;
00101         a.second=a.second+b.second;
00102         return a;
00103 }
00104 
00105 // '+=' operator for t_SSPair
00106 inline void operator += (BOSS::t_SSPair& a, const BOSS::t_SSPair& b) {
00107         a=a+b;
00108 }
00109 
00110 #endif

Generated on Tue Dec 20 23:14:38 2005 for BOSS by doxygen 1.3.6