LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
automatonCommon.h
Go to the documentation of this file.
1// Copyright 2002-2013 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/************************************************************************
7 *
8 * @file automatonCommon.h
9 * @author besancon (besanconr@zoe.cea.fr)
10 * @date Tue Mar 22 2005
11 * @version $Id$
12 * copyright Copyright (C) 2005-2012 by CEA LIST
13 * Project Automaton
14 *
15 * @brief common types and objects for automaton
16 *
17 *
18 ***********************************************************************/
19
20#ifndef AUTOMATONCOMMON_H
21#define AUTOMATONCOMMON_H
22
23#include "AutomatonExport.h"
29#include <iostream>
30#include <fstream>
31#include <string>
32#include <vector>
33#include <set>
34
35namespace Lima {
36namespace LinguisticProcessing {
37namespace Automaton {
38
39//----------------------------------------------------------------------
40// type definitions
41typedef uint64_t Tstate;
42typedef StringsPoolIndex Tword; // use string pool
43
44// Part of speech: Macro and Micro are coded on the same LinguisticCode
46
47//----------------------------------------------------------------------
48// utility functions for defined types
49inline Tstate readTstate(std::ifstream& file) { return Common::Misc::readCodedInt(file); }
50inline void writeTstate(std::ofstream& file, const Tstate s) { Common::Misc::writeCodedInt(file,s); }
51
52// reading and writing Tword in binary format
53void readTword(std::ifstream& file, Tword& s,FsaStringsPool& sp);
54void writeTword(std::ofstream& file,const Tword& s,const FsaStringsPool& sp);
55
56// std::ostream& operator << (std::ostream&, const Tpos&);
57
58// reading and writing Tpos in binary format
59void readTpos(std::ifstream&, Tpos&);
60void writeTpos(std::ofstream&,const Tpos&);
61
62// reading and writing set of words (for gazeteer)
63void readWordVector(std::ifstream& file, std::vector<LimaString>& wordVector);
64void writeWordSet(std::ofstream& file,const std::set<LimaString>& wordSet);
65
66//comparing the part-of-speech type with a LingPropertyEntry
67// should take a const LingPropertyEntry& argument
68// check with JYS
69bool compareTpos(const Tpos&, const LinguisticCode& lingProperty,
70 const Common::PropertyCode::PropertyAccessor& macroAccessor,
71 const Common::PropertyCode::PropertyAccessor& microAccessor);
72
73//----------------------------------------------------------------------
74// exceptions
75class OpenFileException : public std::runtime_error {
76 public: OpenFileException(const std::string& mes):std::runtime_error(mes){
77 };
78};
79class UnknownTypeException : public std::runtime_error {
80 public: UnknownTypeException(const std::string& mes):
81 std::runtime_error(mes){ }
82};
83
84//----------------------------------------------------------------------
85// utility conversion function from limastring to int
87
88} // end namespace
89} // end namespace
90} // end namespace
91
92#endif
#define LIMA_AUTOMATON_EXPORT
Provide function to read write and check a property.
uint64_t readCodedInt(std::istream &file)
read a integer coded in variable-byte format in a file
void writeCodedInt(std::ostream &file, const uint64_t number)
write a integer coded in variable-byte format in a file
bool compareTpos(const Tpos &pos, const LinguisticCode &lingProperty, const PropertyCode::PropertyAccessor &macroAccessor, const PropertyCode::PropertyAccessor &microAccessor)
void writeTpos(std::ofstream &file, const Tpos &p)
void readTword(std::ifstream &file, Tword &s, FsaStringsPool &sp)
void readTpos(std::ifstream &file, Tpos &p)
void writeTstate(std::ofstream &file, const Tstate s)
void readWordVector(std::ifstream &file, std::vector< LimaString > &wordVector)
void writeTword(std::ofstream &file, const Tword &s, const FsaStringsPool &sp)
void writeWordSet(std::ofstream &file, const std::set< LimaString > &wordSet)
Tstate readTstate(std::ifstream &file)
NAUTITIA.
QString LimaString
Definition LimaString.h:33
STL namespace.