hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
ea5a359e366edb91520b5d8baa4306dc1f87bb92
18,054
h
C
avogadro/qtgui/rwmolecule.h
AlbertDeFusco/avogadrolibs
572aad6d16295c91da684d180b6b2705070549c1
[ "BSD-3-Clause" ]
null
null
null
avogadro/qtgui/rwmolecule.h
AlbertDeFusco/avogadrolibs
572aad6d16295c91da684d180b6b2705070549c1
[ "BSD-3-Clause" ]
null
null
null
avogadro/qtgui/rwmolecule.h
AlbertDeFusco/avogadrolibs
572aad6d16295c91da684d180b6b2705070549c1
[ "BSD-3-Clause" ]
null
null
null
/****************************************************************************** This source file is part of the Avogadro project. Copyright 2013 Kitware, Inc. This source code is released under the New BSD License, (the "License"). Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ******************************************************************************/ #ifndef AVOGADRO_QTGUI_RWMOLECULE_H #define AVOGADRO_QTGUI_RWMOLECULE_H #include <QtCore/QObject> #include "avogadroqtguiexport.h" #include "persistentatom.h" #include "persistentbond.h" #include <avogadro/core/array.h> #include <avogadro/core/atom.h> #include <avogadro/core/avogadrocore.h> #include <avogadro/core/bond.h> #include <avogadro/core/unitcell.h> #include <avogadro/core/vector.h> #include <QtWidgets/QUndoStack> namespace Avogadro { namespace QtGui { class Molecule; /** Concrete atom/bond proxy classes for RWMolecule. @{ */ class RWAtom; class RWBond; /** @} */ /** * @class RWMolecule rwmolecule.h <avogadro/qtgui/rwmolecule.h> * @brief The RWMolecule class is an editable molecule class that automatically * populates an undo stack. * * This class implements the molecule API and composes a QUndoStack * (undoStack()). New undo commands are automatically generated and push each * time a non-const method is called. * * An interactive mode is supported that causes "noisy" commands, such as * atom position changes, to be merged into a single command, saving memory * keeping the stack usable during interactive editing of the molecule. Use * setInteractive(bool) to toggle interactive mode. * * Similarly, multiple sequences of commands can be compressed into a single * named action using the QUndoStack's macro capability. Call * undoStack().beginMacro(tr("User Description Of Change")) to begin a macro, * and undoStack().endMacro() when finished. */ class AVOGADROQTGUI_EXPORT RWMolecule : public QObject { Q_OBJECT public: /** Typedef for Atom class. */ typedef RWAtom AtomType; /** Typedef for PersistentAtom class. */ typedef PersistentAtom<RWMolecule> PersistentAtomType; /** Typedef for Bond class. */ typedef RWBond BondType; /** Typedef for PersistentBond class. */ typedef PersistentBond<RWMolecule> PersistentBondType; /** Construct a empty molecule with a clean undo stack. */ explicit RWMolecule(QObject *parent = 0); /** Construct a molecule with the atoms/bonds of mol. */ explicit RWMolecule(const Molecule &mol, QObject *parent = 0); ~RWMolecule() AVO_OVERRIDE; /** * Add a new atom to the molecule. * @param atomicNumber The atomic number of the new atom. * @return The new Atom object. */ AtomType addAtom(unsigned char atomicNumber); /** * Obtain an atom object. * @param atomId The index of the atom to return. * @return The requested atom object. Will be invalid if @a atomId >= @a * atomCount(). */ AtomType atom(Index atomId) const; /** * Obtain an atom object from it's unique id. * @param atomUId The unique of the requested atom. * @return The requested atom object. Will be invalid if @a atomUId is not * in use. */ AtomType atomByUniqueId(Index atomUId) const; /** * @return The unique id of the atom. * @{ */ Index atomUniqueId(Index atomId) const; Index atomUniqueId(const AtomType &atom) const; /** @} */ /** * @return The number of atoms in the molecule. */ Index atomCount() const; /** * @return The number of atoms in the molecule with the atomic number @a * atomicNumber. */ Index atomCount(unsigned char atomicNumber) const; /** * Delete the specified atom from this molecule. * @return True on success, false otherwise. * @note This also removes all bonds connected to the atom. * @{ */ bool removeAtom(Index atomId); bool removeAtom(const AtomType &atom); /** @} */ /** * Delete all atoms from this molecule. * @note This also removes all bonds. */ void clearAtoms(); /** * @return An array containing atomic numbers for all atoms in the molecule, * indexed by atom index. */ const Core::Array<unsigned char>& atomicNumbers() const; /** * Get the atomic number for the requested atom. * @param atomId The index of the atom. * @return The atomic number of the atom indexed at @a atomId, or * Avogadro::InvalidElement if @a atomId is invalid. */ unsigned char atomicNumber(Index atomId) const; /** * Replace the current array of atomic numbers. * @param nums The new atomic number array. Must be of length atomCount(). * @return True on success, false otherwise. */ bool setAtomicNumbers(const Core::Array<unsigned char> &nums); /** * Set the atomic number of a single atom. * @param atomId The index of the atom to modify. * @param atomicNumber The new atomic number. * @return True on success, false otherwise. */ bool setAtomicNumber(Index atomId, unsigned char atomicNumber); /** * @return An array containing 3D coordinates for all atoms in the molecule, * indexed by atom index. * @note May be empty if position information has not been set for any atoms. */ const Core::Array<Vector3>& atomPositions3d() const; /** * Get the 3D position of a single atom. * @param atomId The index of the atom. * @return The position of the atom, or Vector3::Zero() if no position * information has been set. */ Vector3 atomPosition3d(Index atomId) const; /** * Replace the current array of 3D atomic coordinates. * @param pos The new coordinate array. Must be of length atomCount(). * @return True on success, false otherwise. */ bool setAtomPositions3d(const Core::Array<Vector3> &pos); /** * Set the 3D position of a single atom. * @param atomId The index of the atom to modify. * @param pos The new position of the atom. * @return True on success, false otherwise. */ bool setAtomPosition3d(Index atomId, const Vector3& pos); /** * Create a new bond in the molecule. * @param atom1 The first atom in the bond. * @param atom2 The second order in the bond. * @param order The bond order. * @return The new bond object. Will be invalid if @a atom1 or @a atom2 does * not exist. * @{ */ BondType addBond(Index atom1, Index atom2, unsigned char order = 1); BondType addBond(const AtomType &atom1, const AtomType &atom2, unsigned char order = 1); /** @} */ /** * Get a bond object. * @param bondId The index of the requested bond. * @return The requested bond object. Will be invalid if @a bondId >= * @a bondCount(). */ BondType bond(Index bondId) const; /** * Get a bond object. * @param atom1 The index of one atom in the bond. * @param atom2 The index of the other atom in bond. * @return The requested bond object. Will be invalid if @a atom1 or @a atom2 * do not exist. */ BondType bond(Index atom1, Index atom2) const; /** * Get a bond object. * @param atom1 One atom in the bond. * @param atom2 The other atom in bond. * @return The requested bond object. Will be invalid if @a atom1 or @a atom2 * are invalid. */ BondType bond(const AtomType &atom1, const AtomType &atom2) const; /** * Get a bond object from its unique id. * @param bondUid The unique id of the bond. * @return The requested bond object. Will be invalid if @a bondUid is not in * use. */ BondType bondByUniqueId(Index bondUid) const; /** * Get the unique id of a bond. * @param bondId The index of the requested bond. * @return The unique id currently assigned to the bond at index @a bondId */ Index bondUniqueId(Index bondId) const; /** * Get the unique id of a bond. * @param bond The requested bond object. * @return The unique id currently assigned to @a bond. */ Index bondUniqueId(const BondType &bond) const; /** * @return The number of bonds in the molecule. */ Index bondCount() const; /** * Remove the requested bond. * @return True on success, false otherwise. * @{ */ bool removeBond(Index bondId); bool removeBond(const BondType &bond); bool removeBond(Index atom1, Index atom2); bool removeBond(const AtomType &atom1, const AtomType &atom2); /** @} */ /** * Remove all bonds from the molecule. */ void clearBonds(); /** * Find bonds connected to an atom. * @param atom The atom of interest. * @return An array of bond objects that are attached to the specified atom. */ Core::Array<BondType> bonds(const AtomType &atom) const; /** * Find bonds connected to an atom. * @param atomId The index for the atom of interest. * @return An array of bond objects that are attached to the specified atom. */ Core::Array<BondType> bonds(const Index &atomId) const; /** * @return An array of bond orders for all bonds in the molecule, indexed by * bond index. */ const Core::Array<unsigned char>& bondOrders() const; /** * Get the order of a bond. * @param bondId The id of the bond. * @return The bond order. */ unsigned char bondOrder(Index bondId) const; /** * Replace the current array of bond orders. * @param orders The new array. * @return True on success, false on failure. */ bool setBondOrders(const Core::Array<unsigned char> &orders); /** * Set the order of a bond in the molecule. * @param bondId The bond's index. * @param order The new order of the bond. * @return True on success, false on failure. */ bool setBondOrder(Index bondId, unsigned char order); /** * @return An array of all bonded atoms in the molecule, indexed by bond * index. * Each bond pair is represented by a pair of atom indices. */ const Core::Array<std::pair<Index, Index> >& bondPairs() const; /** * Get the set of bonded atoms corresponding to @a bondId. * @param bondId The index of the requested bond. * @return The bonded atom pair, represented as a pair of atom indices. */ std::pair<Index, Index> bondPair(Index bondId) const; /** * Replace the current array of bonded atoms. * @param pairs The array. * @return True on success, false on failure. * @note The bonded atoms are represented as a pair of bond indices. * @note If needed, the elements in @a pairs will be modified to ensure that * the first atom index is less than the second. */ bool setBondPairs(const Core::Array<std::pair<Index, Index> > &pairs); /** * Set the bonded atoms for a bond. * @param bondId The bond to modify. * @param pair The new bond pair. * @return True on success, false otherwise. * @note If needed, @a pair will be modified to ensure that the first atom * index is less than the second. */ bool setBondPair(Index bondId, const std::pair<Index, Index> &pair); /** * @brief Begin or end an interactive edit. * * If enabled, certain undo operations will be merged together. For instance, * an editor dragging an atom through space in response to mouse movement will * only generate a single undo command containing the initial and final * positions and discard the intermediate states. If disabled, each * intermediate action will appear in the undo log. */ void setInteractive(bool b); /** * @return True if interactive mode is enabled, false otherwise. * @sa setInteractive */ bool isInteractive() const; /** * @return The QUndoStack for this molecule. * @{ */ QUndoStack& undoStack(); const QUndoStack& undoStack() const; /** @} */ class UndoCommand; friend class UndoCommand; public slots: /** * @brief Force the molecule to emit the changed() signal. * @param change See changed(). */ void emitChanged(unsigned int change); signals: /** * @brief Indicates that the molecule has changed. * @param change Use the MoleculeChange enum to check what has changed. * * The @p change variable indicates what has changed, i.e. if * change & Atoms == true then atoms were changed in some way, and if * change & Removed == true then one or more atoms were removed. */ void changed(unsigned int change); protected: Index findAtomUniqueId(Index atomId) const; Index findBondUniqueId(Index bondId) const; Core::Array<Index> m_atomUniqueIds; Core::Array<Index> m_bondUniqueIds; Core::Array<unsigned char> m_atomicNumbers; Core::Array<Vector3> m_positions3d; Core::Array<std::pair<Index, Index> > m_bondPairs; Core::Array<unsigned char> m_bondOrders; Core::UnitCell *m_unitCell; bool m_interactive; QUndoStack m_undoStack; friend class Molecule; }; class AVOGADROQTGUI_EXPORT RWAtom : public Core::AtomTemplate<RWMolecule> { public: RWAtom() : Core::AtomTemplate<RWMolecule>() {} RWAtom(RWMolecule *m, Index i) : Core::AtomTemplate<RWMolecule>(m, i) {} }; class AVOGADROQTGUI_EXPORT RWBond : public Core::BondTemplate<RWMolecule> { public: RWBond() : Core::BondTemplate<RWMolecule>() {} RWBond(RWMolecule *m, Index i) : Core::BondTemplate<RWMolecule>(m, i) {} }; inline RWMolecule::AtomType RWMolecule::atom(Index atomId) const { return AtomType(const_cast<RWMolecule*>(this), atomId); } inline RWMolecule::AtomType RWMolecule::atomByUniqueId(Index atomUId) const { return atomUId < m_atomUniqueIds.size() ? AtomType(const_cast<RWMolecule*>(this), m_atomUniqueIds[atomUId]) : AtomType(); } inline Index RWMolecule::atomUniqueId(Index atomId) const { return findAtomUniqueId(atomId); } inline Index RWMolecule::atomUniqueId(const RWMolecule::AtomType &a) const { return a.molecule() == this ? findAtomUniqueId(a.index()) : MaxIndex; } inline Index RWMolecule::atomCount() const { return m_atomicNumbers.size(); } inline bool RWMolecule::removeAtom(const AtomType &a) { return a.molecule() == this ? removeAtom(a.index()) : false; } inline const Core::Array<unsigned char> &RWMolecule::atomicNumbers() const { return m_atomicNumbers; } inline unsigned char RWMolecule::atomicNumber(Index atomId) const { return atomId < m_atomicNumbers.size() ? m_atomicNumbers[atomId] : InvalidElement; } inline const Core::Array<Vector3> &RWMolecule::atomPositions3d() const { return m_positions3d; } inline Vector3 RWMolecule::atomPosition3d(Index atomId) const { return atomId < m_positions3d.size() ? m_positions3d[atomId] : Vector3(); } inline RWMolecule::BondType RWMolecule::addBond(const AtomType &atom1, const AtomType &atom2, unsigned char order) { if (atom1.molecule() != atom2.molecule() || atom1.molecule() != this) return BondType(); return addBond(atom1.index(), atom2.index(), order); } inline RWMolecule::BondType RWMolecule::bond(Index bondId) const { return BondType(const_cast<RWMolecule*>(this), bondId); } inline RWMolecule::BondType RWMolecule::bond( const RWMolecule::AtomType &atom1, const RWMolecule::AtomType &atom2) const { if (atom1.molecule() == atom2.molecule() && atom1.molecule() == this) return bond(atom1.index(), atom2.index()); return BondType(); } inline RWMolecule::BondType RWMolecule::bondByUniqueId(Index bondUid) const { return bondUid < m_bondUniqueIds.size() ? BondType(const_cast<RWMolecule*>(this), m_bondUniqueIds[bondUid]) : BondType(); } inline Index RWMolecule::bondUniqueId(Index bondId) const { return findBondUniqueId(bondId); } inline Index RWMolecule::bondUniqueId(const RWMolecule::BondType &b) const { return b.molecule() == this ? findBondUniqueId(b.index()) : MaxIndex; } inline Index RWMolecule::bondCount() const { return m_bondOrders.size(); } inline bool RWMolecule::removeBond(const RWMolecule::BondType &b) { return b.molecule() == this ? removeBond(b.index()) : false; } inline bool RWMolecule::removeBond(Index atom1, Index atom2) { return removeBond(bond(atom1, atom2).index()); } inline bool RWMolecule::removeBond(const RWMolecule::AtomType &atom1, const RWMolecule::AtomType &atom2) { if (atom1.molecule() != atom2.molecule() || atom1.molecule() != this) return false; return removeBond(bond(atom1.index(), atom2.index()).index()); } inline Core::Array<RWMolecule::BondType> RWMolecule::bonds(const RWMolecule::AtomType &a) const { return a.molecule() == this ? bonds(a.index()) : Core::Array<BondType>(); } inline Core::Array<RWMolecule::BondType> RWMolecule::bonds(const Index &atomId) const { Core::Array<RWMolecule::BondType> result; for (Index i = 0; i < m_bondPairs.size(); ++i) if (m_bondPairs[i].first == atomId || m_bondPairs[i].second == atomId) result.push_back(BondType(const_cast<RWMolecule*>(this), i)); return result; } inline const Core::Array<unsigned char> &RWMolecule::bondOrders() const { return m_bondOrders; } inline unsigned char RWMolecule::bondOrder(Index bondId) const { return bondId < m_bondOrders.size() ? m_bondOrders[bondId] : 0; } inline const Core::Array<std::pair<Index, Index> > & RWMolecule::bondPairs() const { return m_bondPairs; } inline std::pair<Index, Index> RWMolecule::bondPair(Index bondId) const { return bondId < m_bondPairs.size() ? m_bondPairs[bondId] : std::make_pair(MaxIndex, MaxIndex); } inline void RWMolecule::setInteractive(bool b) { m_interactive = b; } inline bool RWMolecule::isInteractive() const { return m_interactive; } inline QUndoStack &RWMolecule::undoStack() { return m_undoStack; } inline const QUndoStack &RWMolecule::undoStack() const { return m_undoStack; } } // namespace QtGui } // namespace Avogadro #endif // AVOGADRO_QTGUI_RWMOLECULE_H
29.119355
80
0.685222
[ "object", "vector", "3d" ]
ea728a96b198418134ada22dbade389e4c958158
1,827
h
C
samples/bbcnews/app/model/item.h
reubenscratton/oaknut
03b37965ad84745bd5c077a27d8b53d58a173662
[ "MIT" ]
5
2019-10-04T05:10:06.000Z
2021-02-03T23:29:10.000Z
samples/bbcnews/app/model/item.h
reubenscratton/oaknut
03b37965ad84745bd5c077a27d8b53d58a173662
[ "MIT" ]
null
null
null
samples/bbcnews/app/model/item.h
reubenscratton/oaknut
03b37965ad84745bd5c077a27d8b53d58a173662
[ "MIT" ]
2
2019-09-27T00:34:36.000Z
2020-10-27T09:44:26.000Z
#pragma once #include "content.h" #include "../ui/articles/element.h" class BNCollection; class BNImage; class BNAV; class BNItem : public BNContent { public: BNItem(const variant& json); BNItem(const string& type, const string& modelId); BNItem(const string& modelId); struct Element { attributed_string text; BNImage* image; BNAV* media; Element(attributed_string& a) : text(a), image(nullptr), media(nullptr) {} Element(BNImage* img) : image(img), media(nullptr) {} Element(BNAV* av) : image(nullptr), media(av) {} }; vector<Element> _elements; string _shortName; BNImage* getIndexImage(); BNImage* getPrimaryImage(); BNCollection* getHomedCollection(); vector<BNBaseModel*> itemPictureGalleryImages(); vector<BNBaseModel*> photoGalleryImages(); vector<BNBaseModel*> primaryAVs(); BNRelationship* imageForMediaId(const string& mediaId); BNRelationship* videoForMediaId(const string& mediaId); BNRelationship* audioForMediaId(const string& mediaId); void configureAfterParsing(); bool isItem() override { return true; } virtual bool isLiveEvent() { return false; } vector<BNRelationship*> findRelationships(const vector<string>& primaryTypes, const vector<string>& secondaryTypes, const vector<string>& formats) override; protected: sp<BNImage> _indexImage; sp<BNImage> _primaryImage; sp<BNCollection> _homedCollection; vector<BNRelationship*> findOrderedRelationships(const vector<string>& primaryTypes, const vector<string>& secondaryTypes); vector<BNBaseModel*> findOrderedChildren(const vector<string>& primaryTypes, const vector<string>& secondaryTypes); vector<BNBaseModel*> findImages(const vector<string>& secondaryTypes); };
31.5
160
0.706623
[ "vector" ]
ee3bd7920437f0a2421fd5efe7d67b7f691e711f
1,642
h
C
old/dpd_cpp/micelle.h
brix4dayz/dpd_cpp
6156b9011f7fa529972620a9e949f1ff858f3a28
[ "MIT" ]
null
null
null
old/dpd_cpp/micelle.h
brix4dayz/dpd_cpp
6156b9011f7fa529972620a9e949f1ff858f3a28
[ "MIT" ]
7
2015-11-23T19:17:06.000Z
2016-03-02T20:55:29.000Z
old/dpd_cpp/micelle.h
brix4dayz/dpd_cpp
6156b9011f7fa529972620a9e949f1ff858f3a28
[ "MIT" ]
null
null
null
#include "hydrophobicCore.h" class Micelle : public ObjDPD { public: unsigned short aggreg_num; std::vector< HydrophobicCore* > coreList; DPDFrame<CopolymerChain>* frame; PosVect* com; Micelle( DPDFrame<CopolymerChain>* frame ); Micelle(); ~Micelle(); void addCore( HydrophobicCore* core ); void printMicelleCore( FILE* stream ); void unlink(); virtual void pbcCorrectMicelle( idx* box_length, const float& pbc_correction_factor ) {} virtual void calcCenterOfMass( idx* box_length, const float& pbc_correction_factor ) {} virtual void printMicelle( FILE* stream ) {} virtual void deriveChainList() {} }; class TriblockMicelle : public Micelle { public: std::vector< PECTriblock* > chainList; TriblockMicelle(); TriblockMicelle( DPDFrame<CopolymerChain>* frame ); ~TriblockMicelle(); void printMicelle( FILE* stream ); void addChain( PECTriblock* chain ); void deriveChainList(); void pbcCorrectMicelle( idx* box_length, const float& pbc_correction_factor ); void calcCenterOfMass( idx* box_length, const float& pbc_correction_factor ); void unlink(); }; class DiblockMicelle : public Micelle { public: // Diblock double radius_of_gyration; double shape_anisotropy; double asphericity; double corona_thickness; std::vector< CopolymerChain* > chainList; DiblockMicelle(); DiblockMicelle( DPDFrame<CopolymerChain>* frame ); ~DiblockMicelle(); void printMicelle( FILE* stream ); void deriveChainList(); void pbcCorrectMicelle( idx* box_length, const float& pbc_correction_factor ); void calcCenterOfMass( idx* box_length, const float& pbc_correction_factor ); };
32.84
90
0.744214
[ "vector" ]
ee4b437f60180963422227caf0f03c7cbd79a213
1,509
h
C
common_utils/meta_structures/BasicTypes.h
AljazBozic/CommonUtils
e81da45e570463fc1377c49e0cbedb7edfa4aacd
[ "MIT" ]
2
2021-06-19T14:22:13.000Z
2021-06-19T14:50:54.000Z
common_utils/meta_structures/BasicTypes.h
AljazBozic/CommonUtils
e81da45e570463fc1377c49e0cbedb7edfa4aacd
[ "MIT" ]
null
null
null
common_utils/meta_structures/BasicTypes.h
AljazBozic/CommonUtils
e81da45e570463fc1377c49e0cbedb7edfa4aacd
[ "MIT" ]
null
null
null
#pragma once #include "common_utils/Common.h" namespace common_utils { /** * Null type class (is not supposed to be initialized). */ class NullType {}; /** * Empty type class (can be initialized to represent an empty object). */ class EmptyType {}; /** * If condition is true, its result is type T1, otherwise its result is type T2. */ template<bool condition, typename T1, typename T2> struct ConditionedType; template<typename T1, typename T2> struct ConditionedType<true, T1, T2> { using type = T1; }; template<typename T1, typename T2> struct ConditionedType<false, T1, T2> { using type = T2; }; /** * Converts the compile-time int and unsigned number to type. */ template<int i> struct Int2Type {}; template<unsigned u> struct Unsigned2Type {}; template<bool b> struct Bool2Type {}; template<unsigned u> struct I {}; /** * Converts a type to a type class, to enable partial template specialization for functions. */ template <typename T> struct Type2Type { using type = T; }; /** * Raw array wrapper that allows empty raw arrays. */ template<typename Type, unsigned Size> struct RawArray { public: CPU_AND_GPU Type& operator[](unsigned i) { return m_data[i]; } CPU_AND_GPU const Type& operator[](unsigned i) const { return m_data[i]; } private: Type m_data[Size]; }; template<typename Type> struct RawArray<Type, 0> { }; } // namespace common_utils
21.253521
94
0.654738
[ "object" ]
ee5da4ec42a00c1fbec6e776ca331a270ed11b19
1,323
h
C
kernel/include/carbon/handle_table.h
heatd/Carbon
eb4984806f2dace675df3ffe70351147a8516187
[ "MIT" ]
4
2018-09-17T22:50:23.000Z
2019-10-17T16:49:09.000Z
kernel/include/carbon/handle_table.h
heatd/Carbon
eb4984806f2dace675df3ffe70351147a8516187
[ "MIT" ]
1
2019-07-31T22:55:11.000Z
2019-07-31T22:55:11.000Z
kernel/include/carbon/handle_table.h
heatd/Carbon
eb4984806f2dace675df3ffe70351147a8516187
[ "MIT" ]
1
2021-06-25T17:33:23.000Z
2021-06-25T17:33:23.000Z
/* * Copyright (c) 2019 Pedro Falcato * This file is part of Carbon, and is released under the terms of the MIT License * check LICENSE at the root directory for more information */ #ifndef _CARBON_HANDLE_TABLE_H #define _CARBON_HANDLE_TABLE_H #include <carbon/handle.h> #include <carbon/vector.h> #include <carbon/bitmap.h> #include <carbon/rwlock.h> #include <carbon/smart.h> #include <carbon/status.h> #define HANDLE_BITMAP_EXPANSION_INCREMENT 1024 class handle_table { private: /* Choosing between handle and handle* is hard because it's an issue of * cache locality and having to keep the thing locked forever or having kinda * crap locality but not needing to keep the thing locked for a long time. * I went with the latter. */ cul::vector<shared_ptr<handle> > handles; Bitmap<0> handle_bitmap; rw_lock handle_table_lock; unsigned long nr_open_handles; cbn_handle_t allocate_handle_index(); public: handle_table() : handles{}, handle_bitmap{}, handle_table_lock{} {} ~handle_table(); cbn_handle_t allocate_handle(handle *handle); cbn_status_t close_handle(cbn_handle_t handle); shared_ptr<handle> get_handle(cbn_handle_t id); /* note: emplace_handle returns the old handle if it exists*/ bool emplace_handle(handle *hndl, cbn_handle_t dst, shared_ptr<handle> &old, bool overwrite); }; #endif
31.5
94
0.772487
[ "vector" ]
ee691a0cfbf7c33641a55571c285e8b9bb9387f5
22,832
c
C
bsp/ls1cdev/applications/calculator.c
ghsecuritylab/Hackthon_weatherStation_RTT
fdb8a5127b0e11e6c452985a0b8b2660feb4b686
[ "Apache-2.0" ]
15
2018-11-12T04:29:53.000Z
2022-01-04T12:02:24.000Z
bsp/ls1cdev/applications/calculator.c
ghsecuritylab/Hackthon_weatherStation_RTT
fdb8a5127b0e11e6c452985a0b8b2660feb4b686
[ "Apache-2.0" ]
1
2020-08-28T06:51:36.000Z
2020-08-28T06:51:36.000Z
bsp/ls1cdev/applications/calculator.c
ghsecuritylab/Hackthon_weatherStation_RTT
fdb8a5127b0e11e6c452985a0b8b2660feb4b686
[ "Apache-2.0" ]
13
2018-06-02T21:01:58.000Z
2022-01-04T12:00:11.000Z
/* * Copyright (c) 2006-2018, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2014-2-22 jiezhi320 实现简易计算器 */ #include <stdio.h> #include <string.h> #include <rtthread.h> #ifdef RT_USING_RTGUI #include <rtgui/rtgui.h> #include <rtgui/widgets/container.h> #include <rtgui/widgets/window.h> #include <rtgui/widgets/button.h> #include <rtgui/image.h> #include <rtgui/widgets/label.h> #include <rtgui/rtgui_app.h> #endif #include "string.h" #include "stdlib.h" #include "math.h" struct rtgui_label *label_result; typedef enum _OPERATOR { PLUS, //+ MINUS, //- MULTI, //* DIV, // / PER //% } OPERATOR; static OPERATOR opert; //运算符 #define LEN 38 static char char_display[LEN]; //输入捕获用 static char char_res[LEN]; //显示用 static int step; //输入步骤 static int point_flag; #define C_NUM 1 #define C_OPERT 2 #define C_POINT 3 int input_type(char c) { if (c=='.') return C_POINT; if (c=='+') return C_OPERT; if (c=='-') return C_OPERT; if (c=='*') return C_OPERT; if (c=='/') return C_OPERT; if (c=='%') return C_OPERT; return C_NUM; } static void char_res_clr(void) { rt_memset(char_display, ' ', sizeof(char_display)); char_display[LEN-1]=0; rtgui_label_set_text(label_result, char_display); step = 0; point_flag = 0; } void cal(void) { static volatile int/*double*/ f_var1; //第一个操作数 static volatile int/*double*/ f_var2; //第二个操作数 static volatile int/*double*/ f_res; //运算结果 char offset_op, offset_num1, offset_num2; char c, buf[120]; int i; if ((strstr(char_display, "+")!= RT_NULL)|| (strstr(char_display, "-")!= RT_NULL)||(strstr(char_display, "*")!= RT_NULL)||\ (strstr(char_display, "/")!= RT_NULL)||(strstr(char_display, "%")!= RT_NULL)) {//有操作符 if ((char_display[LEN-2]>=48)&& (char_display[LEN-2]<=57)) { //操作数后有第二个操作数 开机计算 //定位操作符位置 if (opert == PLUS)(c='+') ; if (opert == MINUS) (c='-'); if (opert == MULTI) (c='*'); if (opert == DIV)(c='/') ; if (opert == PER)(c='%') ; offset_op = strchr(char_display,c)-char_display; //定位第一个操作数开始位置 for (i=0; i<offset_op;i++) { if(char_display[i]!=' ') { break; } } offset_num1=i; //定位第一个操作数开始位置 offset_num2=offset_op+1; if (offset_num1==offset_op) { f_var1=0; } else { memset(buf,0 ,sizeof(buf)); memcpy(buf,&char_display[offset_num1],offset_op-offset_num1); f_var1 = atoi(buf);//atof } f_var2 = atoi(&char_display[offset_num2]);//atof if (opert == PLUS) f_res = f_var1+f_var2; if (opert == MINUS) f_res = f_var1-f_var2; if (opert == MULTI) f_res = f_var1*f_var2; if (opert == DIV) f_res = f_var1/f_var2; if (opert == PER) f_res = ((int)(f_var1))%((int)(f_var2)); rt_kprintf("f_var1=%d\r\n", f_var1); rt_kprintf("f_var2=%d\r\n", f_var2); rt_kprintf("f_res=%d\r\n", f_res); //计算完 memset(buf,0 ,sizeof(buf)); rt_sprintf(buf, "%d", f_res); //将f_res转为字符串 //%f i=strlen(buf)+1;//结果加上=的长度 rt_kprintf("i=%d\r\n", i); memset(char_res,' ' ,sizeof(char_res)); memcpy(&char_res[LEN-(LEN-offset_num1-1+i)-1], &char_display[offset_num1], LEN-offset_num1-1); char_res[LEN-i-1]='='; rt_sprintf(&char_res[LEN-i], "%d", f_res); //将f_res转为字符串 //%f /* if (strstr(&char_res[LEN-8], ".000000")!= RT_NULL) { for (i=LEN-2; i>=7; i--) {//去掉浮点数后那些没用的0和. char_res[i]=char_res[i-7]; } } else { //计算后面有几个没用的'0' int j; for (j=LEN-2; j>=LEN-7; j--) { if (char_res[j]!='0') break; } for (i=LEN-2; i>=LEN-2-j; i--) {//去掉浮点数后那些没用的0 char_res[i]=char_res[i-(LEN-2-j)]; } } */ char_res[LEN-1]=0; } else { memset(char_res,0 ,sizeof(char_res)); memcpy(char_res, "Hi! Number is not completed!", LEN-1); //复位变量 point_flag =0; rt_memset(char_display, ' ', sizeof(char_display)); char_display[LEN-1]=0; step = 0; } } else { memset(char_res,0 ,sizeof(char_res)); memcpy(char_res, "Funny? No operator!!!", LEN-1); //复位变量 point_flag =0; rt_memset(char_display, ' ', sizeof(char_display)); char_display[LEN-1]=0; step = 0; } } void char_res_append(char c) { int i; switch(step) { case 0: //还没第一个操作数 或已经有第一个操作数但还没操作符 rt_kprintf("step=%d\r\n", step); if (input_type(c)==C_POINT) {//初始态 输入 . if (point_flag!=0) break; //操作数中已经有个小数点了,忽略 for(i=0; i<LEN-2; i++) { char_display[i] = char_display[i+1]; } char_display[LEN-2] = c; point_flag =1; rtgui_label_set_text(label_result, char_display); } else if (input_type(c)==C_NUM) {//初始态 输入 数字 for(i=0; i<LEN-2; i++) { char_display[i] = char_display[i+1]; } char_display[LEN-2] = c; rtgui_label_set_text(label_result, char_display); } else { for(i=0; i<LEN-2; i++) { char_display[i] = char_display[i+1]; } char_display[LEN-2] = c; step =1;//已经有第一个操作数和操作符了 point_flag =0; if (c=='+') opert = PLUS; if (c=='-') opert = MINUS; if (c=='*') opert = MULTI; if (c=='/') opert = DIV; if (c=='%') opert = PER; rtgui_label_set_text(label_result, char_display); } break; case 1://已经有第一个操作数和操作符了 rt_kprintf("step=%d\r\n", step); if (input_type(c)==C_POINT) { break; } else if (input_type(c)==C_OPERT) {//已经有个操作符了,再来一个操作符,则用后来的操作符替换原操作符 char_display[LEN-2] = c; if (c=='+') opert = PLUS; if (c=='-') opert = MINUS; if (c=='*') opert = MULTI; if (c=='/') opert = DIV; if (c=='%') opert = PER; rtgui_label_set_text(label_result, char_display); } else { step =2;//准备输入最后一个操作数 for(i=0; i<LEN-2; i++) { char_display[i] = char_display[i+1]; } char_display[LEN-2] = c; rtgui_label_set_text(label_result, char_display); } break; case 2://准备输入最后一个操作数 rt_kprintf("step=%d\r\n", step); if (input_type(c)==C_POINT) {//输入 . if (point_flag!=0) break; //操作数中已经有个小数点了,忽略 for(i=0; i<LEN-2; i++) { char_display[i] = char_display[i+1]; } char_display[LEN-2] = c; point_flag =1; rtgui_label_set_text(label_result, char_display); } else if (input_type(c)==C_NUM) {//初始态 输入 数字 for(i=0; i<LEN-2; i++) { char_display[i] = char_display[i+1]; } char_display[LEN-2] = c; rtgui_label_set_text(label_result, char_display); } else//按运算符 等于是要求计算 { cal(); rtgui_label_set_text(label_result, char_res); //复位变量 point_flag =0; rt_memset(char_display, ' ', sizeof(char_display)); char_display[LEN-1]=0; step = 0; } break; } rt_kprintf("%s\r\n", char_display); } /** * @function name :win1_event_handler * @param : *object: object pointer * @param : *event: event pointer * @return : rt_bool_t * @note :the win event handle function of win1 **/ static rt_bool_t win1_event_handler(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ rt_kprintf("event->type:%d\r\n", event->type); return rtgui_win_event_handler(object,event); } /** * @function name :button_num1_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num1 **/ static void button_num1_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('1'); } /** * @function name :button_plus_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_plus **/ static void button_plus_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('+'); } /** * @function name :button_clr_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_clr **/ static void button_clr_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_clr(); } /** * @function name :button_equal_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_equal **/ static void button_equal_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ cal(); rtgui_label_set_text(label_result, char_res); //复位变量 point_flag =0; rt_memset(char_display, ' ', sizeof(char_display)); char_display[LEN-1]=0; step = 0; } /** * @function name :button_minus_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_minus **/ static void button_minus_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('-'); } /** * @function name :button_div_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_div **/ static void button_div_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('/'); } /** * @function name :button_multi_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_multi **/ static void button_multi_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('*'); } /** * @function name :button_num2_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num2 **/ static void button_num2_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('2'); } /** * @function name :button_num3_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num3 **/ static void button_num3_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('3'); } /** * @function name :button_num6_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num6 **/ static void button_num6_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('6'); } /** * @function name :button_num5_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num5 **/ static void button_num5_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('5'); } /** * @function name :button_num4_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num4 **/ static void button_num4_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('4'); } /** * @function name :button_num9_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num9 **/ static void button_num9_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('9'); } /** * @function name :button_num8_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num8 **/ static void button_num8_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('8'); } /** * @function name :button_num7_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num7 **/ static void button_num7_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('7'); } /** * @function name :button_prec_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_prec **/ static void button_prec_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('%'); } /** * @function name :button_point_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_point **/ static void button_point_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('.'); } /** * @function name :button_num0_onbutton * @param : *object: object pointer * @param : *event: event pointer * @return : void * @note :the onbutton event function of button_num0 **/ static void button_num0_onbutton(struct rtgui_object *object, struct rtgui_event *event) { /* add you code here */ char_res_append('0'); } /** * @function name :win1_ui_init() * @param : void * @return : rtgui_win_t * * @note :the init function of win1 **/ struct rtgui_win * win1_ui_init(struct rtgui_win *parent) { struct rtgui_win *win1; rtgui_rect_t rect={30,30,350,270}; struct rtgui_label *label = RT_NULL; struct rtgui_button *button_num1,*button_plus,*button_clr,*button_equal,*button_minus,*button_div,\ *button_multi,*button_num2,*button_num3,*button_num6,*button_num5,*button_num4,*button_num9,*button_num8,\ *button_num7,*button_prec,*button_point,*button_num0; /* win1 Create */ { win1=rtgui_win_create(parent," Simple calculator -RTGUI",&rect,RTGUI_WIN_STYLE_CLOSEBOX); rtgui_object_set_event_handler(RTGUI_OBJECT(win1), win1_event_handler); RTGUI_WIDGET_BACKGROUND(win1) = RTGUI_RGB(0, 192, 192); } label = rtgui_label_create(" Simple calculator:Using RTGUI!"); rtgui_widget_set_minwidth(RTGUI_WIDGET(label), 250); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(label)); /* button_num1 Create */ { button_num1=rtgui_button_create("1"); RTGUI_RECT(rect,10,80,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num1), &rect); rtgui_button_set_onbutton(button_num1, button_num1_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num1)); } /* button_plus Create */ { button_plus=rtgui_button_create("+"); RTGUI_RECT(rect,220,80,40,40); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_plus), &rect); rtgui_button_set_onbutton(button_plus, button_plus_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_plus)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button_plus)) = RTGUI_RGB(0, 192, 0); } /* button_clr Create */ { button_clr=rtgui_button_create("clear"); RTGUI_RECT(rect,220,180,40,40); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_clr), &rect); rtgui_button_set_onbutton(button_clr, button_clr_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_clr)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button_clr)) = RTGUI_RGB(128, 64, 64); } /* button_equal Create */ { button_equal=rtgui_button_create("="); RTGUI_RECT(rect,270,180,40,40); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_equal), &rect); rtgui_button_set_onbutton(button_equal, button_equal_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_equal)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button_equal)) = RTGUI_RGB(255, 0, 0); } /* label_result Create */ { label_result=rtgui_label_create(""); RTGUI_RECT(rect,10,30,300,40); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect); rtgui_widget_set_rect(RTGUI_WIDGET(label_result), &rect); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(label_result)); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label_result)) = RTGUI_RGB(255, 0, 0); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label_result)) = RTGUI_RGB(255, 255, 255); //RTGUI_WIDGET_ALIGN(label_result)=RTGUI_ALIGN_CENTER_VERTICAL|RTGUI_ALIGN_RIGHT; } /* button_minus Create */ { button_minus=rtgui_button_create("-"); RTGUI_RECT(rect,270,80,40,40); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_minus), &rect); rtgui_button_set_onbutton(button_minus, button_minus_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_minus)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button_minus)) = RTGUI_RGB(0, 192, 0); } /* button_div Create */ { button_div=rtgui_button_create("/"); RTGUI_RECT(rect,270,130,40,40); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_div), &rect); rtgui_button_set_onbutton(button_div, button_div_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_div)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button_div)) = RTGUI_RGB(0, 192, 0); } /* button_multi Create */ { button_multi=rtgui_button_create("*"); RTGUI_RECT(rect,220,130,40,40); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_multi), &rect); rtgui_button_set_onbutton(button_multi, button_multi_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_multi)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button_multi)) = RTGUI_RGB(0, 192, 0); } /* button_num2 Create */ { button_num2=rtgui_button_create("2"); RTGUI_RECT(rect,80,80,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num2), &rect); rtgui_button_set_onbutton(button_num2, button_num2_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num2)); } /* button_num3 Create */ { button_num3=rtgui_button_create("3"); RTGUI_RECT(rect,150,80,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num3), &rect); rtgui_button_set_onbutton(button_num3, button_num3_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num3)); } /* button_num6 Create */ { button_num6=rtgui_button_create("6"); RTGUI_RECT(rect,150,120,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num6), &rect); rtgui_button_set_onbutton(button_num6, button_num6_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num6)); } /* button_num5 Create */ { button_num5=rtgui_button_create("5"); RTGUI_RECT(rect,80,120,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num5), &rect); rtgui_button_set_onbutton(button_num5, button_num5_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num5)); } /* button_num4 Create */ { button_num4=rtgui_button_create("4"); RTGUI_RECT(rect,10,120,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num4), &rect); rtgui_button_set_onbutton(button_num4, button_num4_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num4)); } /* button_num9 Create */ { button_num9=rtgui_button_create("9"); RTGUI_RECT(rect,150,160,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num9), &rect); rtgui_button_set_onbutton(button_num9, button_num9_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num9)); } /* button_num8 Create */ { button_num8=rtgui_button_create("8"); RTGUI_RECT(rect,80,160,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num8), &rect); rtgui_button_set_onbutton(button_num8, button_num8_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num8)); } /* button_num7 Create */ { button_num7=rtgui_button_create("7"); RTGUI_RECT(rect,10,160,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num7), &rect); rtgui_button_set_onbutton(button_num7, button_num7_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num7)); } /* button_prec Create */ { button_prec=rtgui_button_create("%"); RTGUI_RECT(rect,150,200,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_prec), &rect); rtgui_button_set_onbutton(button_prec, button_prec_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_prec)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button_prec)) = RTGUI_RGB(0, 192, 0); } /* button_point Create */ { button_point=rtgui_button_create("."); RTGUI_RECT(rect,80,200,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_point), &rect); rtgui_button_set_onbutton(button_point, button_point_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_point)); } /* button_num0 Create */ { button_num0=rtgui_button_create("0"); RTGUI_RECT(rect,10,200,60,30); rtgui_widget_rect_to_device(RTGUI_WIDGET(win1),&rect);rtgui_widget_set_rect(RTGUI_WIDGET(button_num0), &rect); rtgui_button_set_onbutton(button_num0, button_num0_onbutton); rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(button_num0)); } char_res_clr(); return win1; } static void calculator_thread_entry(void* parameter) { struct rtgui_app* application; struct rtgui_win* win; /* create calculator GUI application */ application = rtgui_app_create("calculator"); RT_ASSERT(application != RT_NULL); if (application != RT_NULL) { win = win1_ui_init(RT_NULL); } rtgui_win_show(win, RT_TRUE); rtgui_app_run(application); rtgui_app_destroy(application); } int calculator(void) { rt_thread_t tid; tid = rt_thread_create("calculator", calculator_thread_entry, RT_NULL, 2048, 20, 20); if (tid != RT_NULL) rt_thread_startup(tid); return 0; } #ifdef RT_USING_FINSH #include <finsh.h> FINSH_FUNCTION_EXPORT(calculator,calculator test ) ; /* 导出到 msh 命令列表中 */ MSH_CMD_EXPORT(calculator, calculator test); #endif
27.574879
124
0.701778
[ "object" ]
ee899df4b4080fd1ef1d22c334ac688f54926f6a
10,893
h
C
code/source/array.h
DEAKSoftware/KFX
8a759d21a651d9f8acbfef2e3d19b1e8580a74b5
[ "MIT" ]
null
null
null
code/source/array.h
DEAKSoftware/KFX
8a759d21a651d9f8acbfef2e3d19b1e8580a74b5
[ "MIT" ]
null
null
null
code/source/array.h
DEAKSoftware/KFX
8a759d21a651d9f8acbfef2e3d19b1e8580a74b5
[ "MIT" ]
null
null
null
/*=========================================================================== Array Template Class Dominik Deak ===========================================================================*/ #ifndef ___ARRAY_H___ #define ___ARRAY_H___ /*--------------------------------------------------------------------------- Header files ---------------------------------------------------------------------------*/ #include "common.h" #include "debug.h" //Namespaces NAMESPACE_BEGIN(NAMESPACE_PROJECT) /*--------------------------------------------------------------------------- The array class. The GRAN option sets the allocation granularity size. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN = 1> class Array { //---- Member data ---- private: TYPE* Items; usize Count; usize Total; //---- Methods ---- public: //Constructor, assigment, and destructor inline Array(void); inline Array(const Array<TYPE, GRAN> &A); inline Array<TYPE, GRAN> &operator = (const Array<TYPE, GRAN> &A); inline ~Array(void); //Data allocation inline void Clear(void); inline void Destroy(void); inline void Reserve(usize Extra); inline void Create(usize Extra); inline void Compact(void); //Adding and removing items inline void operator += (const Array<TYPE, GRAN> &A); inline void operator += (const TYPE &Item); inline uiter operator + (const TYPE &Item); inline void Remove(uiter I); //Data access inline TYPE operator [] (uiter I) const; inline TYPE& operator [] (uiter I); inline TYPE* Pointer(void) const; inline usize Size(void) const; private: //Data allocation inline void Resize(usize T); }; /*--------------------------------------------------------------------------- Default constructor. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline Array<TYPE, GRAN>::Array(void) { Clear(); } /*--------------------------------------------------------------------------- Copy constructor, invoked when the current object is instantiated. This method performs a deep copy of the specified object. The current object is unitialised, which must be cleared. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline Array<TYPE, GRAN>::Array(const Array<TYPE, GRAN> &A) { Clear(); Reserve(A.Size()); for (uiter I = 0; I < A.Size(); I++) { *this += A[I]; } } /*--------------------------------------------------------------------------- Assignment operator, invoked only when the current object already exist. This method performs a deep copy of the specified object. The current object may have allocated data which must be destroyed. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline Array<TYPE, GRAN> &Array<TYPE, GRAN>::operator = (const Array<TYPE, GRAN> &A) { //No action on self assignment if (this == &A) {return *this;} Destroy(); Reserve(A.Size()); for (uiter I = 0; I < A.Size(); I++) { *this += A[I]; } return *this; } /*--------------------------------------------------------------------------- Destructor. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline Array<TYPE, GRAN>::~Array(void) { Destroy(); } /*--------------------------------------------------------------------------- Clears the array contets. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::Clear(void) { Items = nullptr; Count = 0; Total = 0; } /*--------------------------------------------------------------------------- Destroys array contents. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::Destroy(void) { delete[] Items; Clear(); } /*--------------------------------------------------------------------------- Resizes array according to the new total. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::Resize(usize T) { if (T == Total) {return;} if (T < Count) {throw dexception("Invalid parameters.");} if (T < 1) {Destroy();} TYPE* New = new TYPE[T]; Total = T; for (uiter I = 0; I < Count; I++) { New[I] = Items[I]; } delete[] Items; Items = New; } /*--------------------------------------------------------------------------- Reserves some extra space on the array, on top of the existing Count. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::Reserve(usize Extra) { if (Extra < 1) {return;} Extra += Count; usize Rem = Extra % GRAN; if (Rem > 0) {Extra += GRAN - Rem;} Resize(Extra); } /*--------------------------------------------------------------------------- Creates extra entries on the array, on top of the existing Count. The new entries will be in an unitialised state, depending on the entry object type. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::Create(usize Extra) { if (Extra < 1) {return;} Reserve(Extra); Count += Extra; } /*--------------------------------------------------------------------------- Forces the array to be compacted so that Total matches Count. Useful for finalising the array when no more items are added. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::Compact(void) { if (Total > Count) { Resize(Count); } } /*--------------------------------------------------------------------------- Appends an external array to this array. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::operator += (const Array<TYPE, GRAN> &A) { if (A.Size() < 1) {return;} Reserve(A.Size()); //NOTE: Make a local copy of the external array size, // just in case the array is appending itself usize Size = A.Size(); for (uiter I = 0; I < Size; I++) { *this += A[I]; } } /*--------------------------------------------------------------------------- Appends new item at the end of the array. The method will grow the array if necessary, which can be an expensive process for large arrays. In that case, it is better to preallocate extra space via the Reserve( ) method before using this function. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::operator += (const TYPE &Item) { if (Total <= Count) { Resize(Total + GRAN); } Items[Count++] = Item; } /*--------------------------------------------------------------------------- Appends new item at the end of the array and returns its array index. The method will grow the array if necessary, which can be an expensive process for large arrays. In that case, it is better to preallocate extra space via the Reserve( ) method before using this function. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline uiter Array<TYPE, GRAN>::operator + (const TYPE &Item) { if (Total <= Count) { Resize(Total + GRAN); } uiter I = Count; Items[Count++] = Item; return I; } /*--------------------------------------------------------------------------- Removes item at the specified index and then it compacts array. The method will compact the array if necessary. Array compaction is an expensive process for large arrays, hence use this method sparingly. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline void Array<TYPE, GRAN>::Remove(uiter I) { if (I >= Count) {return;} for (uiter J = I + 1; J < Count; I++, J++) { Items[I] = Items[J]; } Count--; if (Total - Count >= GRAN) { Resize(Total - GRAN); } } /*--------------------------------------------------------------------------- Operator for returning entries. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline TYPE Array<TYPE, GRAN>::operator [] (uiter I) const { if (I >= Count) {throw dexception("Invalid array index.");} return Items[I]; } /*--------------------------------------------------------------------------- Operator for modifying entries by reference. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline TYPE& Array<TYPE, GRAN>::operator [] (uiter I) { if (I >= Count) {throw dexception("Invalid array index.");} return Items[I]; } /*--------------------------------------------------------------------------- Returns the base pointer of the array. Only used in special circumstances, such as buffering arrays in OpenGL, and so on. For general purpose array access, use the operator[] method instead. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline TYPE* Array<TYPE, GRAN>::Pointer(void) const { return Items; } /*--------------------------------------------------------------------------- Returns the number of entries in the array. ---------------------------------------------------------------------------*/ template <typename TYPE, usize GRAN> inline usize Array<TYPE, GRAN>::Size(void) const { return Count; } //Close namespaces NAMESPACE_END(NAMESPACE_PROJECT) //==== End of file =========================================================== #endif
31.758017
85
0.422381
[ "object" ]
ee8dc4e878d40e82215d6ca98c1c32656e137c80
2,183
h
C
src/ColorPalette.h
sitara-systems/ofxColorPalette
30aea3fa2569d96eef81b1c184d267036a36a86f
[ "MIT" ]
3
2020-09-19T11:31:10.000Z
2021-12-25T13:08:55.000Z
src/ColorPalette.h
morphogencc/ofxColorPalette
30aea3fa2569d96eef81b1c184d267036a36a86f
[ "MIT" ]
null
null
null
src/ColorPalette.h
morphogencc/ofxColorPalette
30aea3fa2569d96eef81b1c184d267036a36a86f
[ "MIT" ]
1
2020-09-19T09:25:06.000Z
2020-09-19T09:25:06.000Z
#pragma once #include "Palette.h" #include <vector> namespace ofxColorPalette { enum PALETTE_TYPE { MONOCHROME, COMPLEMENTARY, SPLIT_COMPLEMENTARY, TRIADIC, TETRADIC, FOUR_TONE, FIVE_TONE, SIX_TONE, NEUTRAL }; enum HUE_TYPE { UNIFORM, SKEWED_ROOT }; enum SATURATION_TYPE { STATIC, LEVELS, RANDOM }; class ColorPalette : public Palette { public: ColorPalette(PALETTE_TYPE palette, float rootHue); ColorPalette(PALETTE_TYPE palette); ~ColorPalette(); float getRootHue(); void setRootHue(float root); std::vector<float> getHues(); std::shared_ptr<ofColor> nextColor(); void resetPalette(PALETTE_TYPE palette, float rootHue); void setPaletteType(PALETTE_TYPE type); PALETTE_TYPE getPaletteType(); void randomizePalette(); void setProbabilities(float black, float white, float saturated); void setProbabilities(float black, float white, float saturated, float root); void setHueType(HUE_TYPE type); HUE_TYPE getHueType(); float getBlackProbability(); float getWhiteProbability(); float getSaturatedProbability(); void setSaturationType(SATURATION_TYPE type); SATURATION_TYPE getSaturationType(); void setMaximumSaturation(float maximum_saturation); float getMaximumSaturation(); void setMinimumSaturation(float minimum_saturation); float getMinimumSaturation(); void setNumberOfSaturationLevels(int levels); int getNumberOfSaturationLevels(); std::vector<float> getSaturationLevels(); void setMaximumBrightness(float maximum_brightness); float getMaximumBrightness(); void setMinimumBrightness(float minimum_brightness); float getMinimumBrightness(); protected: void init(PALETTE_TYPE palette); PALETTE_TYPE mPaletteType; SATURATION_TYPE mSaturationType; HUE_TYPE mHueType; std::vector<float> mHues; std::vector<float> mSaturationLevels; float mBlackProbability; float mWhiteProbability; float mSaturatedProbability; float mRootProbability; float mMaximumBrightness; float mMaximumSaturation; float mMinimumBrightness; float mMinimumSaturation; float mRootHue; }; }
25.682353
80
0.74393
[ "vector" ]
ee9148421b5e3f6c2b743498c7867542be9154e1
38,998
c
C
src/lang/json.c
heisz/toolkit
c10656b44c880dd2c2ccfb9eaeea9edc7dd758f4
[ "MIT" ]
null
null
null
src/lang/json.c
heisz/toolkit
c10656b44c880dd2c2ccfb9eaeea9edc7dd758f4
[ "MIT" ]
null
null
null
src/lang/json.c
heisz/toolkit
c10656b44c880dd2c2ccfb9eaeea9edc7dd758f4
[ "MIT" ]
null
null
null
/* * Structures and methods for parsing, representing and generating JSON data. * * Copyright (C) 2015-2020 J.M. Heisz. All Rights Reserved. * See the LICENSE file accompanying the distribution your rights to use * this software. */ #include <ctype.h> #include "jsonint.h" #include "encoding.h" #include "mem.h" /** * For debugging/logging, get the textual representation of the parsing error * code (not localized). * * @param errorCode The error code to translate. * @return The error string associated to the given error code. */ const char *WXJSON_GetErrorStr(WXJSONErrorCode errorCode) { static char *errStr[] = { "OK, no error encountered", "Memory allocation failure", "Syntax error: invalid JSON value", "Unallowed control character in string value", "Invalid Unicode character specification (\\u####)", "Invalid escape (\\) character sequence", "Unterminated string value (missing closing \")", "Syntax error: misplaced JSON value (not in value context)", "Syntax error: extraneous/unexpected object terminator '}'", "Syntax error: extraneous/unexpected array terminator ']'", "Syntax error: misplaced/unexpected colon token", "Syntax error: misplaced/unexpected comma token", "JSON root content must be a single value", "Syntax error: bad array continuation, expecting ',' or ']'", "Syntax error: missing object property name", "Syntax error: missing object property/value colon separator", "Syntax error: bad object continuation, expecting ',' or '}'", }; if ((errorCode < 0) || (errorCode > WXJSONERR_OBJECT_CONTINUE)) { return "Invalid/unknown parsing error code"; } return errStr[errorCode]; } /** * Initialize a lexer instance for the provided content. Just an internal * setup wrapper. * * @param lexer The lexer instance to initialize. * @param content The string JSON content to be parsed. */ void WXJSONLexerInit(WXJSONLexer *lexer, const char *content) { /* Really just a setup for the real work */ lexer->content = content; lexer->offset = 0; lexer->lineNumber = 1; lexer->lastToken.type = WXJSONTK_START; } /* Common macros for common circumstances */ #define RETURN_ERROR(x) \ lexer->lastToken.type = WXJSONTK_ERROR; \ lexer->lastToken.value.errorCode = x; \ return &(lexer->lastToken); #define IN_VALUE_CONTEXT() \ ((lexer->lastToken.type == WXJSONTK_START) || \ (lexer->lastToken.type == WXJSONTK_ARR_START) || \ (lexer->lastToken.type == WXJSONTK_COLON) || \ (lexer->lastToken.type == WXJSONTK_COMMA)) #define WAS_VALUE() \ ((lexer->lastToken.type & WXJSONTK_VALUE) == WXJSONTK_VALUE) /** * Internal method (except for testing) to obtain the next token from the * lexer. * * @param lexer The lexer instance to retrieve the token from. * @return Pointer to the next token (reference to the internal lastToken * element). */ WXJSONToken *WXJSONLexerNext(WXJSONLexer *lexer) { char ch, *ptr = (char *) (lexer->content + lexer->offset), *eptr; uint8_t strBufferData[1024], utf[4]; unsigned int idx, uchr, ucnt; WXBuffer strBuffer; /* Flush prior content */ (void) memset(&lexer->lastToken.value, 0, sizeof(lexer->lastToken.value)); /* Read to end of file (or a token occurs) */ while ((ch = *(ptr++)) != '\0') { /* Consume white space (non-Unicode) */ if ((ch == ' ') || (ch == '\t')) { continue; } if ((ch == '\r') && (*ptr == '\n')) { /* Collapse LF-CR into single CR */ ch = *(ptr++); } if ((ch == '\r') || (ch == '\n')) { lexer->lineNumber++; continue; } /* The grammar isn't that complex, condenses to one switch */ switch (ch) { case '{': if (!IN_VALUE_CONTEXT()) { RETURN_ERROR(WXJSONERR_VALUE_NOT_IN_CONTEXT); } lexer->lastToken.type = WXJSONTK_OBJ_START; lexer->offset = ptr - lexer->content; return &(lexer->lastToken); case '}': /* Last item must have been a value (closure) or empty */ if ((!WAS_VALUE()) && (lexer->lastToken.type != WXJSONTK_OBJ_START)) { RETURN_ERROR(WXJSONERR_EXT_OBJECT_TERMINATOR); } lexer->lastToken.type = WXJSONTK_VALUE_OBJ_END; lexer->offset = ptr - lexer->content; return &(lexer->lastToken); case '[': if (!IN_VALUE_CONTEXT()) { RETURN_ERROR(WXJSONERR_VALUE_NOT_IN_CONTEXT); } lexer->lastToken.type = WXJSONTK_ARR_START; lexer->offset = ptr - lexer->content; return &(lexer->lastToken); case ']': /* Last item must have been a value (closure) or empty */ if ((!WAS_VALUE()) && (lexer->lastToken.type != WXJSONTK_ARR_START)) { RETURN_ERROR(WXJSONERR_EXT_ARRAY_TERMINATOR); } lexer->lastToken.type = WXJSONTK_VALUE_ARR_END; lexer->offset = ptr - lexer->content; return &(lexer->lastToken); case 't': if (!IN_VALUE_CONTEXT()) { RETURN_ERROR(WXJSONERR_VALUE_NOT_IN_CONTEXT); } if (strncmp(ptr, "rue", 3) == 0) { lexer->lastToken.type = WXJSONTK_VALUE_TRUE; lexer->offset = (ptr - lexer->content) + 3; return &(lexer->lastToken); } else { RETURN_ERROR(WXJSONERR_INVALID_VALUE); } case 'f': if (!IN_VALUE_CONTEXT()) { RETURN_ERROR(WXJSONERR_VALUE_NOT_IN_CONTEXT); } if (strncmp(ptr, "alse", 4) == 0) { lexer->lastToken.type = WXJSONTK_VALUE_FALSE; lexer->offset = (ptr - lexer->content) + 4; return &(lexer->lastToken); } else { RETURN_ERROR(WXJSONERR_INVALID_VALUE); } case 'n': if (!IN_VALUE_CONTEXT()) { RETURN_ERROR(WXJSONERR_VALUE_NOT_IN_CONTEXT); } if (strncmp(ptr, "ull", 3) == 0) { lexer->lastToken.type = WXJSONTK_VALUE_NULL; lexer->offset = (ptr - lexer->content) + 3; return &(lexer->lastToken); } else { RETURN_ERROR(WXJSONERR_INVALID_VALUE); } case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (!IN_VALUE_CONTEXT()) { RETURN_ERROR(WXJSONERR_VALUE_NOT_IN_CONTEXT); } ptr--; for (idx = 1; ch != '\0'; idx++) { ch = *(ptr + idx); if ((ch == '.') || (ch == 'e') || (ch == 'E')) { /* Floating point entry */ lexer->lastToken.type = WXJSONTK_VALUE_DBL; lexer->lastToken.value.dval = strtod(ptr, &eptr); lexer->offset = eptr - lexer->content; return &(lexer->lastToken); } else if (!isdigit(ch)) { /* End of number, which is integer at this point */ lexer->lastToken.type = WXJSONTK_VALUE_INT; lexer->lastToken.value.ival = strtoll(ptr, &eptr, 10); lexer->offset = eptr - lexer->content; return &(lexer->lastToken); } } /* Never gets here, null terminator is not a digit */ break; case '"': /* Special, standalone value or key leader for object */ if ((!IN_VALUE_CONTEXT()) && (lexer->lastToken.type != WXJSONTK_OBJ_START)) { RETURN_ERROR(WXJSONERR_VALUE_NOT_IN_CONTEXT); } WXBuffer_InitLocal(&strBuffer, strBufferData, sizeof(strBufferData)); while ((ch = *(ptr++)) != '"') { if (ch == '\\') { switch (ch = *(ptr++)) { case '"': case '\\': case '/': /* Direct character mapping */ break; case 'b': ch = '\b'; break; case 'f': ch = '\f'; break; case 'n': ch = '\n'; break; case 'r': ch = '\r'; break; case 't': ch = '\t'; break; case 'u': uchr = 0; for (idx = 0; idx < 4; idx++) { ch = *(ptr + idx); if (((ch >= 'a') && (ch <= 'f')) || ((ch >= 'A') && (ch <= 'F'))) { uchr = (uchr << 4) | ((ch + 9) & 0x0F); } else if ((ch >= '0') && (ch <= '9')) { uchr = (uchr << 4) | (ch & 0x0F); } else { WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_INVALID_UNICHAR); } } if (uchr <= 0x7F) { utf[0] = (uint8_t) (uchr & 0x7F); ucnt = 1; } else if (uchr <= 0x7FF) { utf[0] = (uint8_t) (0xC0 | ((uchr >> 6) & 0x1F)); utf[1] = (uint8_t) (0x80 | (uchr & 0x3F)); ucnt = 2; } else { utf[0] = (uint8_t) (0xE0 | ((uchr >> 12) & 0x0F)); utf[1] = (uint8_t) (0x80 | ((uchr >> 6) & 0x3F)); utf[2] = (uint8_t) (0x80 | (uchr & 0x3F)); ucnt = 3; } if (WXBuffer_Append(&strBuffer, utf, ucnt, TRUE) == NULL) { WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_ALLOC_FAILURE); } ptr += 4; ch = '\0'; break; default: WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_INVALID_ESCAPE); break; } if (ch != '\0') { if (WXBuffer_Append(&strBuffer, (uint8_t *) &ch, 1, TRUE) == NULL) { WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_ALLOC_FAILURE); } } } else if (ch == '\0') { WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_UNTERMINATED_STRING); } else if (ch < 0x20) { WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_INVALID_CHARACTER); } else { if (WXBuffer_Append(&strBuffer, (uint8_t *) &ch, 1, TRUE) == NULL) { WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_ALLOC_FAILURE); } } } lexer->lastToken.type = WXJSONTK_VALUE_STR; if ((lexer->lastToken.value.sval = (char *) WXMalloc(strBuffer.length + 1)) == NULL) { WXBuffer_Destroy(&strBuffer); RETURN_ERROR(WXJSONERR_ALLOC_FAILURE); } (void) memcpy(lexer->lastToken.value.sval, strBuffer.buffer, strBuffer.length); lexer->lastToken.value.sval[strBuffer.length] = '\0'; WXBuffer_Destroy(&strBuffer); lexer->offset = ptr - lexer->content; return &(lexer->lastToken); case ':': /* Must follow a string value (key) */ if (lexer->lastToken.type != WXJSONTK_VALUE_STR) { RETURN_ERROR(WXJSONERR_MISPLACED_COLON); } lexer->lastToken.type = WXJSONTK_COLON; lexer->offset = ptr - lexer->content; return &(lexer->lastToken); case ',': /* Can follow any value (array or object field) */ if (!WAS_VALUE()) { RETURN_ERROR(WXJSONERR_MISPLACED_COMMA); } lexer->lastToken.type = WXJSONTK_COMMA; lexer->offset = ptr - lexer->content; return &(lexer->lastToken); default: RETURN_ERROR(WXJSONERR_INVALID_VALUE); } } lexer->lastToken.type = WXJSONTK_EOF; lexer->offset = ptr - lexer->content - 1; return &(lexer->lastToken); } /* Cleanup method for invalid token discard */ void WXJSONLexerDiscard(WXJSONToken *token) { /* Only the string token actually allocated anything */ if (token->type == WXJSONTK_VALUE_STR) { if (token->value.sval != NULL) WXFree(token->value.sval); } } /** * For closure, destruction method for lexer content. Does not release the * object itself and really only resets internal parsing details. * * @param lexer The lexer instance to be destroyed. */ void WXJSONLexerDestroy(WXJSONLexer *lexer) { lexer->content = NULL; lexer->offset = 0; } /* Scanners and forward declarations to release related items */ /* Note that objects contain allocated value, arrays are contained values */ static void _WXJSON_Destroy(WXJSONValue *value, int freeStructure); static int _objectDestroyScanner(WXHashTable *table, void *key, void *object, void *userData) { WXFree(key); _WXJSON_Destroy((WXJSONValue *) object, TRUE); return 0; } static int _arrayDestroyScanner(WXArray *array, void *object, void *userData) { _WXJSON_Destroy((WXJSONValue *) object, FALSE); return 0; } /* Internal method to capture optional allocated value release */ static void _WXJSON_Destroy(WXJSONValue *value, int freeStructure) { switch (value->type) { case WXJSONVALUE_ERROR: case WXJSONVALUE_NONE: case WXJSONVALUE_TRUE: case WXJSONVALUE_FALSE: case WXJSONVALUE_NULL: case WXJSONVALUE_INT: case WXJSONVALUE_DOUBLE: /* These all have unallocated content */ break; case WXJSONVALUE_STRING: WXFree(value->value.sval); break; case WXJSONVALUE_OBJECT: (void) WXHash_Scan(&(value->value.oval), _objectDestroyScanner, NULL); WXHash_Destroy(&(value->value.oval)); break; case WXJSONVALUE_ARRAY: (void) WXArray_Scan(&(value->value.aval), _arrayDestroyScanner, NULL); WXArray_Destroy(&(value->value.aval)); break; default: /* Not much we can actually do here... */ break; } if (freeStructure) WXFree(value); } /* * Parse a single data value at the next lexer point. Recurses for objects and * arrays. Returns 0 (WXJSONERR_NONE_OK) if successful, error code otherwise. */ static WXJSONErrorCode WXJSON_ParseValue(WXJSONLexer *lexer, WXJSONValue *value, int allowArrayClosure) { WXJSONValue inner, *propVal, *dupVal; char *propName = NULL, *dupName; WXJSONToken *token; int rc; /* Grab next token and check for validation from lexer */ token = WXJSONLexerNext(lexer); if (token->type == WXJSONTK_ERROR) { return token->value.errorCode; } /* Translate value tokens appropriately */ (void) memset(value, 0, sizeof(WXJSONValue)); switch (token->type) { case WXJSONTK_VALUE_TRUE: value->type = WXJSONVALUE_TRUE; break; case WXJSONTK_VALUE_FALSE: value->type = WXJSONVALUE_FALSE; break; case WXJSONTK_VALUE_NULL: value->type = WXJSONVALUE_NULL; break; case WXJSONTK_VALUE_INT: value->type = WXJSONVALUE_INT; value->value.ival = token->value.ival; break; case WXJSONTK_VALUE_DBL: value->type = WXJSONVALUE_DOUBLE; value->value.dval = token->value.dval; break; case WXJSONTK_VALUE_STR: value->type = WXJSONVALUE_STRING; value->value.sval = token->value.sval; break; case WXJSONTK_OBJ_START: /* Recursive iteration over object content */ value->type = WXJSONVALUE_OBJECT; (void) WXHash_InitTable(&(value->value.oval), 0); while (lexer->lastToken.type != WXJSONTK_EOF) { /* Need an object property */ token = WXJSONLexerNext(lexer); if (token->type == WXJSONTK_VALUE_STR) { propName = token->value.sval; } else if ((token->type == WXJSONTK_VALUE_OBJ_END) && (value->value.oval.entryCount == 0)) { /* Empty object... */ break; } else { WXJSONLexerDiscard(token); _WXJSON_Destroy(value, FALSE); return (token->type == WXJSONTK_ERROR) ? token->value.errorCode : WXJSONERR_MISSING_PROPERTY; } /* And a colon */ token = WXJSONLexerNext(lexer); if (token->type == WXJSONTK_COLON) { /* Do nothing, just moving along */ } else { WXFree(propName); WXJSONLexerDiscard(token); _WXJSON_Destroy(value, FALSE); return (token->type == WXJSONTK_ERROR) ? token->value.errorCode : WXJSONERR_MISSING_COLON; } /* Next a value, once we have that, push to hashtable */ propVal = (WXJSONValue *) WXMalloc(sizeof(WXJSONValue)); if (propVal == NULL) { WXFree(propName); _WXJSON_Destroy(value, FALSE); return WXJSONERR_ALLOC_FAILURE; } rc = WXJSON_ParseValue(lexer, propVal, FALSE); if (rc != WXJSONERR_NONE_OK) { WXFree(propName); WXFree(propVal); _WXJSON_Destroy(value, FALSE); return rc; } if (!WXHash_PutEntry(&(value->value.oval), propName, propVal, (void **) &dupName, (void **) &dupVal, WXHash_StrHashFn, WXHash_StrEqualsFn)) { /* Worst case for cleanup */ WXFree(propName); _WXJSON_Destroy(propVal, TRUE); _WXJSON_Destroy(value, FALSE); return WXJSONERR_ALLOC_FAILURE; } /* Handle duplicate/overlaid properties */ if (dupName != NULL) WXFree(dupName); if (dupVal != NULL) _WXJSON_Destroy(dupVal, TRUE); /* Finally a comma or end of object */ token = WXJSONLexerNext(lexer); if (token->type == WXJSONTK_COMMA) { /* Do nothing, just moving along */ } else if (token->type == WXJSONTK_VALUE_OBJ_END) { /* Object is complete, exit loop */ break; } else { _WXJSON_Destroy(value, FALSE); return (token->type == WXJSONTK_ERROR) ? token->value.errorCode : WXJSONERR_OBJECT_CONTINUE; } } break; case WXJSONTK_ARR_START: /* Recursive iteration over array content */ value->type = WXJSONVALUE_ARRAY; (void) WXArray_Init(&(value->value.aval), WXJSONValue, 0); while (lexer->lastToken.type != WXJSONTK_EOF) { /* Value must be first, get it and add to array */ rc = WXJSON_ParseValue(lexer, &inner, TRUE); if (rc != WXJSONERR_NONE_OK) { _WXJSON_Destroy(value, FALSE); return rc; } if (inner.type == WXJSONVALUE_NONE) { /* Empty array instance */ break; } if (WXArray_Push(&(value->value.aval), &inner) == NULL) { _WXJSON_Destroy(&inner, FALSE); _WXJSON_Destroy(value, FALSE); return WXJSONERR_ALLOC_FAILURE; } /* Followed by a comma or end of array */ token = WXJSONLexerNext(lexer); if (token->type == WXJSONTK_COMMA) { /* Do nothing, just moving along */ } else if (token->type == WXJSONTK_VALUE_ARR_END) { /* Array is complete, exit loop */ break; } else { _WXJSON_Destroy(value, FALSE); return (token->type == WXJSONTK_ERROR) ? token->value.errorCode : WXJSONERR_ARRAY_CONTINUE; } } break; case WXJSONTK_VALUE_ARR_END: /* Special bypass for empty array */ if (allowArrayClosure) { value->type = WXJSONVALUE_NONE; break; } return WXJSONERR_INVALID_VALUE; default: /* Lexer should capture these but just in case */ return WXJSONERR_INVALID_VALUE; } return WXJSONERR_NONE_OK; } /** * Parse/decode a JSON document, returning a corresponding data representation. * * @param content The JSON document/content to be parsed. * @return The root value of the JSON data, note that this contains an error * item for any parsing error. NULL for memory failure. */ WXJSONValue *WXJSON_Decode(const char *content) { WXJSONValue *retval = NULL; WXJSONToken *token; WXJSONLexer lexer; int rc; /* Prepare for parsing and return */ retval = (WXJSONValue *) WXMalloc(sizeof(WXJSONValue)); if (retval == NULL) return NULL; WXJSONLexerInit(&lexer, content); /* And away we go! */ rc = WXJSON_ParseValue(&lexer, retval, FALSE); if (rc != WXJSONERR_NONE_OK) { retval->type = WXJSONVALUE_ERROR; retval->value.error.errorCode = rc; retval->value.error.lineNumber = lexer.lineNumber; WXJSONLexerDestroy(&lexer); return retval; } /* There can be only one */ token = WXJSONLexerNext(&lexer); if (token->type != WXJSONTK_EOF) { _WXJSON_Destroy(retval, FALSE); retval->type = WXJSONVALUE_ERROR; retval->value.error.errorCode = (token->type == WXJSONTK_ERROR) ? token->value.errorCode : WXJSONERR_NONSINGULAR_ROOT; retval->value.error.lineNumber = lexer.lineNumber; WXJSONLexerDiscard(token); } WXJSONLexerDestroy(&lexer); return retval; } /* Tracking element for separator handling */ typedef struct { WXBuffer *buffer; int isFirstElement, prettyPrint, indent; } WXJSONListEncodeTracker; /* Common method to wrap JSON string encoding with quotes */ static uint8_t *_escapeJSONString(WXBuffer *buffer, char *str) { if (WXBuffer_Append(buffer, "\"", 1, TRUE) == NULL) return NULL; if (WXJSON_EscapeString(buffer, str, -1) == NULL) return NULL; if (WXBuffer_Append(buffer, "\"", 1, TRUE) == NULL) return NULL; return buffer->buffer; } /* Forward declaration for nested looping */ static int WXJSON_EncodeValue(WXBuffer *buffer, WXJSONValue *value, int prettyPrint, int indent); /* Scanners for encoding complex values */ static int _objectEncodeScanner(WXHashTable *table, void *key, void *object, void *userData) { WXJSONListEncodeTracker *trk = (WXJSONListEncodeTracker *) userData; if (!trk->isFirstElement) { if (WXBuffer_Append(trk->buffer, ",", 1, TRUE) == NULL) return -1; if (trk->prettyPrint) { if (WXBuffer_Append(trk->buffer, "\n", 1, TRUE) == NULL) return -1; } } trk->isFirstElement = FALSE; if (trk->prettyPrint) { if (WXIndent(trk->buffer, trk->indent * 4) == NULL) return -1; } if (_escapeJSONString(trk->buffer, (char *) key) == NULL) return -1; if (trk->prettyPrint) { if (WXBuffer_Append(trk->buffer, ": ", 2, TRUE) == NULL) return -1; } else { if (WXBuffer_Append(trk->buffer, ":", 1, TRUE) == NULL) return -1; } if (WXJSON_EncodeValue(trk->buffer, (WXJSONValue *) object, trk->prettyPrint, trk->indent) < 0) return -1; return 0; } static int _arrayEncodeScanner(WXArray *array, void *object, void *userData) { WXJSONListEncodeTracker *trk = (WXJSONListEncodeTracker *) userData; if (!trk->isFirstElement) { if (trk->prettyPrint) { if (WXBuffer_Append(trk->buffer, ", ", 2, TRUE) == NULL) return -1; } else { if (WXBuffer_Append(trk->buffer, ",", 1, TRUE) == NULL) return -1; } } trk->isFirstElement = FALSE; if (WXJSON_EncodeValue(trk->buffer, (WXJSONValue *) object, trk->prettyPrint, trk->indent) < 0) return -1; return 0; } static int WXJSON_EncodeValue(WXBuffer *buffer, WXJSONValue *value, int prettyPrint, int indent) { WXJSONListEncodeTracker trk; char prtBuff[128]; /* Common preparation for nested iteration processing */ trk.buffer = buffer; trk.prettyPrint = prettyPrint; trk.isFirstElement = TRUE; trk.indent = indent + 1; /* Output based on type */ switch (value->type) { case WXJSONVALUE_TRUE: if (WXBuffer_Append(buffer, "true", 4, TRUE) == NULL) return -1; break; case WXJSONVALUE_FALSE: if (WXBuffer_Append(buffer, "false", 5, TRUE) == NULL) return -1; break; case WXJSONVALUE_NULL: if (WXBuffer_Append(buffer, "null", 4, TRUE) == NULL) return -1; break; case WXJSONVALUE_INT: (void) sprintf(prtBuff, "%lld", value->value.ival); if (WXBuffer_Append(buffer, prtBuff, strlen(prtBuff), TRUE) == NULL) return -1; break; case WXJSONVALUE_DOUBLE: /* There is no consistent model for exact reproduction */ (void) sprintf(prtBuff, "%g", value->value.dval); if (WXBuffer_Append(buffer, prtBuff, strlen(prtBuff), TRUE) == NULL) return -1; break; case WXJSONVALUE_STRING: if (_escapeJSONString(buffer, value->value.sval) == NULL) return -1; break; case WXJSONVALUE_OBJECT: if (WXBuffer_Append(buffer, "{", 1, TRUE) == NULL) return -1; if (prettyPrint && (value->value.oval.entryCount != 0)) { if (WXBuffer_Append(buffer, "\n", 1, TRUE) == NULL) return -1; } (void) WXHash_Scan(&(value->value.oval), _objectEncodeScanner, &trk); if (prettyPrint && (value->value.oval.entryCount != 0)) { if (WXBuffer_Append(buffer, "\n", 1, TRUE) == NULL) return -1; if (WXIndent(buffer, indent * 4) == NULL) return -1; } if (WXBuffer_Append(buffer, "}", 1, TRUE) == NULL) return -1; break; case WXJSONVALUE_ARRAY: if (WXBuffer_Append(buffer, "[", 1, TRUE) == NULL) return -1; (void) WXArray_Scan(&(value->value.aval), _arrayEncodeScanner, &trk); if (WXBuffer_Append(buffer, "]", 1, TRUE) == NULL) return -1; break; default: /* Not much we can actually do here, no encoding none/error */ break; } return 0; } /** * Converse to the above, translate the JSON data content to a document. * * @param buffer Buffer into which the JSON data should be encoded. * @param value The root JSON value to be encoded. * @param prettyPrint If TRUE (non-zero) , pretty-print the JSON output, * otherwise (false/zero) output in compact format. * @return The buffer area containing the output document (null terminated) * or NULL if memory allocation failure occurred. */ char *WXJSON_Encode(WXBuffer *buffer, WXJSONValue *value, int prettyPrint) { if (WXJSON_EncodeValue(buffer, value, prettyPrint, 0) < 0) return NULL; if (WXBuffer_Append(buffer, "\0", 1, TRUE) == NULL) return NULL; return (char *) buffer->buffer; } /** * Destroy/release the contents of the provided data value (and all nested * values). This method will also free the value itself (consistent with * the allocated return from the parse method). * * @param value The value to be destroyed/freed. */ void WXJSON_Destroy(WXJSONValue *value) { _WXJSON_Destroy(value, TRUE); } /** * Quick utility method to locate a JSON value entry based on a fully qualified * child node name. Cannot (currently) cross array boundaries... * * @param root The parsed JSON node value to search from. * @param childName Fully qualified (period-delimited) name of the child node to * retrieve. An internal copy is made in local stack space, names * over the internal alloc limit will not be found (truncation). * @return The child node, if located, or NULL if any entry in the name is not * found. */ WXJSONValue *WXJSON_Find(WXJSONValue *root, const char *childName) { char *ptr, *eptr, name[4096]; WXJSONValue *child; /* Copy for manipulation */ (void) strncpy(name, childName, sizeof(name)); (void) strcpy(name + sizeof(name) - 5, "---"); ptr = name; /* Away we go... */ while (*ptr != '\0') { /* At any point, looking for the child of a non-object is a fail... */ if (root->type != WXJSONVALUE_OBJECT) return NULL; /* Find the next step in the chain, which could be the end */ eptr = strchr(ptr, '.'); if (eptr != NULL) *eptr = '\0'; child = WXHash_GetEntry(&(root->value.oval), ptr, WXHash_StrHashFn, WXHash_StrEqualsFn); if ((child == NULL) || (eptr == NULL)) return child; /* Next please... */ ptr = eptr + 1; root = child; } return NULL; } /* Internal messaging method to delineate types */ static char *descJSONType(WXJSONValueType type) { switch (type) { case WXJSONVALUE_TRUE: case WXJSONVALUE_FALSE: return "boolean (t/f)"; case WXJSONVALUE_NULL: return "null"; case WXJSONVALUE_INT: return "integer"; case WXJSONVALUE_DOUBLE: return "double/float"; case WXJSONVALUE_STRING: return "string"; case WXJSONVALUE_OBJECT: return "object"; case WXJSONVALUE_ARRAY: return "array"; default: break; } return "unknown"; } /** * Utility method to bind a JSON data object (hierarchy) into a physical * data structure. The binding method is reasonably strict, will not convert * between JSON and native data types outside of direct allocation/casting. * * @param root Parsed JSON data node to bind information from. * @param data Pointer to physical data structure to bind into. * @param defn Binding information for translating JSON to physical elements. * @param defnCount Number of elements in the binding information array. * @param errorMsg Externally provided buffer for returning binding error * information. * @param errorMsgLen Length of provided buffer. * @return TRUE if bind processing was successful, FALSE on error (message * in provided buffer). */ int WXJSON_Bind(WXJSONValue *root, void *data, WXJSONBindDefn *defn, int defnCount, char *errorMsg, int errorMsgLen) { WXJSONValue *val; char *ptr; int idx; /* Zoom through the provided binding definitions */ for (idx = 0; idx < defnCount; idx++, defn++) { /* Find the corresponding data point and dereference the structure */ val = WXJSON_Find(root, defn->name); if (val == NULL) { if (defn->required != 0) { (void) snprintf(errorMsg, errorMsgLen, "Missing JSON value for '%s'", defn->name); return FALSE; } continue; } ptr = ((char *) data) + defn->offset; /* Bind away! */ switch (defn->type) { case WXJSONBIND_STR: if ((val->type != WXJSONVALUE_STRING) && (val->type != WXJSONVALUE_NULL)) { (void) snprintf(errorMsg, errorMsgLen, "Expecting string/null value for '%s', " "found %s instead", defn->name, descJSONType(val->type)); return FALSE; } if (val->type == WXJSONVALUE_NULL) val = NULL; /* Lots of jiggerypokery to manage string (re)allocation */ if (val != NULL) { if (*((char **) ptr) != NULL) WXFree(*((char **) ptr)); *((char **) ptr) = WXMalloc(strlen(val->value.sval) + 1); if (*((char **) ptr) != NULL) { (void) strcpy(*((char **) ptr), val->value.sval); } } else { *((char **) ptr) = NULL; } break; case WXJSONBIND_BOOLEAN: if ((val->type != WXJSONVALUE_TRUE) && (val->type != WXJSONVALUE_FALSE)) { (void) snprintf(errorMsg, errorMsgLen, "Expecting true/false value for '%s', " "found %s instead", defn->name, descJSONType(val->type)); return FALSE; } *((int *) ptr) = (val->type == WXJSONVALUE_TRUE) ? TRUE : FALSE; break; case WXJSONBIND_INT: case WXJSONBIND_SIZE: case WXJSONBIND_LONG: if (val->type != WXJSONVALUE_INT) { (void) snprintf(errorMsg, errorMsgLen, "Expecting integer value for '%s', " "found %s instead", defn->name, descJSONType(val->type)); return FALSE; } if (defn->type == WXJSONBIND_INT) { *((int *) ptr) = (int) val->value.ival; } else if (defn->type == WXJSONBIND_SIZE) { *((size_t *) ptr) = (size_t) val->value.ival; } else { *((long long int *) ptr) = val->value.ival; } break; case WXJSONBIND_DOUBLE: /* Only convenience conversion, as int is a double as well */ if ((val->type != WXJSONVALUE_INT) && (val->type != WXJSONVALUE_DOUBLE)) { (void) snprintf(errorMsg, errorMsgLen, "Expecting numeric value for '%s', " "found %s instead", defn->name, descJSONType(val->type)); return FALSE; } if (defn->type == WXJSONBIND_INT) { *((double *) ptr) = (double) val->value.ival; } else { *((double *) ptr) = val->value.dval; } break; case WXJSONBIND_REF: if ((val->type != WXJSONVALUE_OBJECT) && (val->type != WXJSONVALUE_ARRAY)) { (void) snprintf(errorMsg, errorMsgLen, "Expecting object/array value for '%s', " "found %s instead", defn->name, descJSONType(val->type)); return FALSE; } *((WXJSONValue **) ptr) = val; break; default: (void) snprintf(errorMsg, errorMsgLen, "Internal error, unrecognized bind type"); return FALSE; } } return TRUE; }
39.997949
80
0.497436
[ "object", "model" ]
ee96a368fb833286c23769f72eee84068bf977aa
7,004
h
C
eigen/Eigen/src/plugins/ReshapedMethods.h
jwatson-CO-edu/scanviewer_ur5-intellisense
46753ef2a14fe90e4ed741c31aa4685c656c3f83
[ "MIT" ]
null
null
null
eigen/Eigen/src/plugins/ReshapedMethods.h
jwatson-CO-edu/scanviewer_ur5-intellisense
46753ef2a14fe90e4ed741c31aa4685c656c3f83
[ "MIT" ]
null
null
null
eigen/Eigen/src/plugins/ReshapedMethods.h
jwatson-CO-edu/scanviewer_ur5-intellisense
46753ef2a14fe90e4ed741c31aa4685c656c3f83
[ "MIT" ]
null
null
null
#ifdef EIGEN_PARSED_BY_DOXYGEN /// \returns an expression of \c *this with reshaped sizes. /// /// \param nRows the number of rows in the reshaped expression, specified at either run-time or compile-time, or AutoSize /// \param nCols the number of columns in the reshaped expression, specified at either run-time or compile-time, or AutoSize /// \tparam Order specifies whether the coefficients should be processed in column-major-order (ColMajor), in row-major-order (RowMajor), /// or follows the \em natural order of the nested expression (AutoOrder). The default is ColMajor. /// \tparam NRowsType the type of the value handling the number of rows, typically Index. /// \tparam NColsType the type of the value handling the number of columns, typically Index. /// /// Dynamic size example: \include MatrixBase_reshaped_int_int.cpp /// Output: \verbinclude MatrixBase_reshaped_int_int.out /// /// The number of rows \a nRows and columns \a nCols can also be specified at compile-time by passing Eigen::fix<N>, /// or Eigen::fix<N>(n) as arguments. In the later case, \c n plays the role of a runtime fallback value in case \c N equals Eigen::Dynamic. /// Here is an example with a fixed number of rows and columns: /// \include MatrixBase_reshaped_fixed.cpp /// Output: \verbinclude MatrixBase_reshaped_fixed.out /// /// Finally, one of the sizes parameter can be automatically deduced from the other one by passing AutoSize as in the following example: /// \include MatrixBase_reshaped_auto.cpp /// Output: \verbinclude MatrixBase_reshaped_auto.out /// AutoSize does preserve compile-time sizes when possible, i.e., when the sizes of the input are known at compile time \b and /// that the other size is passed at compile-time using Eigen::fix<N> as above. /// /// \sa class Reshaped, fix, fix<N>(int) /// template<int Order = ColMajor, typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC inline Reshaped<Derived,...> reshaped(NRowsType nRows, NColsType nCols); /** This is the const version of reshaped(NRowsType,NColsType). */ template<int Order = ColMajor, typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC inline const Reshaped<const Derived,...> reshaped(NRowsType nRows, NColsType nCols) const; /// \returns an expression of \c *this with columns (or rows) stacked to a linear column (or row) vector /// /// \tparam Order specifies whether to stack columns to a column-vector (ColMajor) or /// to cat rows to a row-vector (RowMajor). The default is ColMajor. /// /// If Order==ColMajor (the default), then it returns a column vector from the stacked columns of \c *this. /// This is equivalent to `A.reshaped<ColMajor>(AutoSize,fix<1>)`. /// /// If Order==RowMajor, then it returns a row vector from the glued rows of \c *this. /// This is equivalent to `A.reshaped<RowMajor>(fix<1>,AutoSize)`. /// /// Example: /// \include MatrixBase_reshaped_to_vector.cpp /// Output: \verbinclude MatrixBase_reshaped_to_vector.out /// /// If you want more control, you can still fall back to reshaped(NRowsType,NColsType). /// For instance, to return a column vector with element stacked following the storage order, /// you can do: \code A.reshaped<AutoOrder>(AutoSize,fix<1>) \endcode /// /// \sa reshaped(NRowsType,NColsType), class Reshaped /// template<int Order = ColMajor> EIGEN_DEVICE_FUNC inline Reshaped<Derived,...> reshaped(); /** This is the const version of reshaped(). */ template<int Order = ColMajor> EIGEN_DEVICE_FUNC inline const Reshaped<const Derived,...> reshaped() const; #else // This file is automatically included twice to generate const and non-const versions #ifndef EIGEN_RESHAPED_METHOD_2ND_PASS #define EIGEN_RESHAPED_METHOD_CONST const #else #define EIGEN_RESHAPED_METHOD_CONST #endif #ifndef EIGEN_RESHAPED_METHOD_2ND_PASS // This part is included once #endif template<typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value, internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value> reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST { return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value, internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value> (derived(), internal::get_runtime_reshape_size(nRows,internal::get_runtime_value(nCols),size()), internal::get_runtime_reshape_size(nCols,internal::get_runtime_value(nRows),size())); } template<int Order, typename NRowsType, typename NColsType> EIGEN_DEVICE_FUNC inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value, internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value, (Order==AutoOrder?Flags&RowMajorBit:Order)> reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST { return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value, internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value, Order==AutoOrder?Flags&RowMajorBit:Order> (derived(), internal::get_runtime_reshape_size(nRows,internal::get_runtime_value(nCols),size()), internal::get_runtime_reshape_size(nCols,internal::get_runtime_value(nRows),size())); } // Views as linear vectors EIGEN_DEVICE_FUNC inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,SizeAtCompileTime,1> reshaped() EIGEN_RESHAPED_METHOD_CONST { return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,SizeAtCompileTime,1>(derived(),size(),1); } template<int Order> EIGEN_DEVICE_FUNC inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, (Order==RowMajor ? 1 : SizeAtCompileTime), (Order==RowMajor ? SizeAtCompileTime : 1), (Order==AutoOrder?Flags&RowMajorBit:Order)> reshaped() EIGEN_RESHAPED_METHOD_CONST { EIGEN_STATIC_ASSERT(Order==RowMajor || Order==ColMajor, INVALID_TEMPLATE_PARAMETER); return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, Order==RowMajor ? 1 : SizeAtCompileTime, Order==RowMajor ? SizeAtCompileTime : 1, Order==AutoOrder?Flags&RowMajorBit:Order> (derived(), Order==RowMajor ? 1 : size(), Order==RowMajor ? size() : 1); } #undef EIGEN_RESHAPED_METHOD_CONST #ifndef EIGEN_RESHAPED_METHOD_2ND_PASS #define EIGEN_RESHAPED_METHOD_2ND_PASS #include "ReshapedMethods.h" #undef EIGEN_RESHAPED_METHOD_2ND_PASS #endif #endif // EIGEN_PARSED_BY_DOXYGEN
44.611465
140
0.741291
[ "vector" ]
ee9aa416ff138a3feee53dade65991f711827eb0
19,234
h
C
xic/include/sced.h
wrcad/xictools
f46ba6d42801426739cc8b2940a809b74f1641e2
[ "Apache-2.0" ]
73
2017-10-26T12:40:24.000Z
2022-03-02T16:59:43.000Z
xic/include/sced.h
markvolkmann/xictools
5d32ad130cfd13f4e5ecaae7701f2863b4558f4e
[ "Apache-2.0" ]
12
2017-11-01T10:18:22.000Z
2022-03-20T19:35:36.000Z
xic/include/sced.h
markvolkmann/xictools
5d32ad130cfd13f4e5ecaae7701f2863b4558f4e
[ "Apache-2.0" ]
34
2017-10-06T17:04:21.000Z
2022-02-18T16:22:03.000Z
/*========================================================================* * * * Distributed by Whiteley Research Inc., Sunnyvale, California, USA * * http://wrcad.com * * Copyright (C) 2017 Whiteley Research Inc., all rights reserved. * * Author: Stephen R. Whiteley, except as indicated. * * * * As fully as possible recognizing licensing terms and conditions * * imposed by earlier work from which this work was derived, if any, * * this work is released under the Apache License, Version 2.0 (the * * "License"). You may not use this file except in compliance with * * the License, and compliance with inherited licenses which are * * specified in a sub-header below this one if applicable. A copy * * of the License is provided with this distribution, or you may * * obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * See the License for the specific language governing permissions * * and limitations under the License. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON- * * INFRINGEMENT. IN NO EVENT SHALL WHITELEY RESEARCH INCORPORATED * * OR STEPHEN R. WHITELEY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * * USE OR OTHER DEALINGS IN THE SOFTWARE. * * * *========================================================================* * XicTools Integrated Circuit Design System * * * * Xic Integrated Circuit Layout and Schematic Editor * * * *========================================================================* $Id:$ *========================================================================*/ #ifndef SCED_H #define SCED_H #include "scedif.h" // // Variables // // Side Menu Commands #define VA_DevMenuStyle "DevMenuStyle" // Attributes Menu #define VA_ShowDots "ShowDots" // Spice Interface (see scedif.h) #define VA_SpiceListAll "SpiceListAll" #define VA_SpiceAlias "SpiceAlias" #define VA_SpiceHost "SpiceHost" // #define VA_SpiceHostDisplay "SpiceHostDisplay" #define VA_SpiceInclude "SpiceInclude" #define VA_SpiceProg "SpiceProg" #define VA_SpiceExecDir "SpiceExecDir" #define VA_SpiceExecName "SpiceExecName" #define VA_SpiceSubcCatchar "SpiceSubcCatchar" #define VA_SpiceSubcCatmode "SpiceSubcCatmode" #define VA_CheckSolitary "CheckSolitary" #define VA_NoSpiceTools "NoSpiceTools" // Extract Menu Commands #define VA_SourceTermDevName "SourceTermDevName" #define VA_SourceGndDevName "SourceGndDevName" // Properties for the device library. These can be given in the // device.lib file keyed by either the number or the text token, e.g., // Property 20 ... // Property SpiceDotSave ... // Add .saves, text is 'device_prefix param_name' (e.g., I c) // to add ".save @Ixxx[c]" lines. Added to all spice decks created. #define LpSpiceDotSaveVal 20 #define LpSpiceDotSaveStr "SpiceDotSave" // Add a default node, text is 'device_name num_nodes string' // (e.g., nmos 4 NSUB) to add a 4'th node "NSUB" to nmos device with // fewer than 4 nodes. #define LpDefaultNodeVal 21 #define LpDefaultNodeStr "DefaultNode" // OBSOLETE // Add a prefix/device mapping, text is 'prefix opt val nnodes nname pname' // prefix short device id prefix, first char must be alpha. This must // match a device in the library. // opt 0,no,off or 1,yes,on (binary). If true, last node presence is // optional (such as for bjt). // val 0,no,off or 1,yes,on (binary). If true, all text goes into // value string (such as for sources). // nnodes number of device nodes, including optional. // nname device name for device, or n-type device, in library. // pname if not 0 or missing, the device name for the p-type library // device. // (e.g., m 0 0 4 nmos pmos) #define LpDeviceKeyVal 22 #define LpDeviceKeyStr "DeviceKey" // Add a prefix/device mapping, text is 'prefix min max devs val nname pname' // prefix short device id prefix, first char must be alpha. This must // match a device in the library. // min min number of nodes. // max max number of nodes. // devs current-controlled device references. // val 0,no,off or 1,yes,on (binary). If true, all text goes into // value string, device has no model, // nname device name for device, or n-type device, in library. // pname if not 0 or missing, the device name for the p-type library // device. // (e.g., m 4 4 0 0 nmos pmos) #define LpDeviceKeyV2Val 23 #define LpDeviceKeyV2Str "DeviceKeyV2" // Arg to PopUpTermEdit struct TermEditInfo { TermEditInfo(const CDp_snode*, int); TermEditInfo(const CDsterm*); TermEditInfo(const CDp_bsnode*); TermEditInfo(const char *n, const char *lnm, unsigned int ix, unsigned int f, bool p) { ti_name = n; ti_netex = 0; ti_layer_name = lnm; ti_flags = f; ti_index = ix; ti_beg = 0; ti_end = 0; ti_bterm = false; ti_has_phys = p; } TermEditInfo(const char *n, unsigned int ix, unsigned int f, const char *nx) { ti_name = n; ti_netex = lstring::copy(nx); ti_layer_name = 0; ti_flags = f; ti_index = ix; ti_beg = 0; ti_end = 0; ti_bterm = true; ti_has_phys = false; } ~TermEditInfo() { delete [] ti_netex; } const char *name() const { return (ti_name); } const char *netex() const { return (ti_netex); } const char *layer_name() const { return (ti_layer_name); } unsigned int flags() const { return (ti_flags); } bool has_flag(unsigned f) const { return (ti_flags & f); } unsigned int index() const { return (ti_index); } unsigned int beg_range() const { return (ti_beg); } unsigned int end_range() const { return (ti_end); } bool has_bterm() const { return (ti_bterm); } bool has_phys() const { return (ti_has_phys); } private: const char *ti_name; // node/terminal name char *ti_netex; // bus net expression const char *ti_layer_name; // associated layer name unsigned int ti_flags; // node and terminal flags unsigned int ti_index; // terminal index unsigned int ti_beg; // bterm range begin unsigned int ti_end; // bterm range end bool ti_bterm; // true if info for bterm bool ti_has_phys; // has physical terminal }; struct hyList; struct hyEnt; struct sParamTab; class cModLib; class cSpiceIPC; class cScedGhost { public: cScedGhost(); // sced_arcs.cc void showGhostDiskPath(int, int, int, int); void showGhostArcPath(int, int, int, int); // sced_shape.cc void showGhostShape(int, int, int, int); // sced_subckt.cc void showGhostElecTerms(int, int, int, int); private: // sced_ghost.cc static void ghost_diskpth(int, int, int, int, bool); static void ghost_arcpth(int, int, int, int, bool); static void ghost_shape(int, int, int, int, bool); static void ghost_elec_terms(int, int, int, int, bool); }; // Store a line of spice text. This can look like the similar struct // in WRspice, but we don't use these features here. // struct SpiceLine { // #define SP_LINE_FULL SpiceLine(const char *s = 0) { li_next = 0; li_line = lstring::copy(s); #ifdef SP_LINE_FULL li_linenum = 0; li_error = 0; li_actual = 0; #endif } ~SpiceLine() { delete [] li_line; #ifdef SP_LINE_FULL delete [] li_error; SpiceLine::destroy(li_actual); #endif } static void destroy(SpiceLine *t) { while (t) { SpiceLine *tx = t; t = t->li_next; delete tx; } } SpiceLine *li_next; char *li_line; #ifdef SP_LINE_FULL char *li_error; SpiceLine *li_actual; int li_linenum; #endif }; inline class cSced *SCD(); class cSced : public cScedIf { public: friend inline cSced *SCD() { return (static_cast<cSced*>(ScedIf())); } bool hasSced() { return (true); } cScedGhost *SGst() { return (sc_ghost); } // ebtn_menu.cc MenuBox *createEbtnMenu(); bool setupCommand(MenuEnt*, bool*, bool*); // export // funcs_sced.cc void loadScriptFuncs(); // sced.cc cSced(); void modelLibraryOpen(const char*); // export void modelLibraryClose(); // export SpiceLine *modelText(const char*); bool isModel(const char*); void closeSpice(); // export bool simulationActive(); // export bool logConnect(); // export void setLogConnect(bool); // export static char *sp_gettok(const char**, bool=false); // sced_arcs.cc void makeArcPathExec(CmdDesc*); // sced_check.cc void checkElectrical(CDcbin*); // export bool prptyCheck(CDs*, FILE*, bool); bool prptyCheckCell(CDs*, char **); bool prptyCheckMutual(CDs*, CDp_nmut*, char**); bool prptyCheckLabel(CDs*, CDla*, char**); bool prptyCheckInst(CDs*, CDc*, char**); bool prptyRegenCell(); // sced_connect.cc bool connectAll(bool, CDs* = 0); // export void unconnectAll(); bool connect(CDs*); // export void updateHlabels(CDs*); void updateNames(CDs*); // export void renumberInstances(CDs*); // sced_dev.cc bool saveAsDev(const char*, bool); // sced_dots.cc void recomputeDots(); // export void updateDots(CDs*, CDo*); // export void dotsSetDirty(const CDs*); // export void dotsUpdateDirty(); // export void clearDots(); // export void updateDotsCellName(CDcellName, CDcellName); // export // sced_expr.cc double *evalExpr(const char**); char *findPlotExpressions(const char*); // sced_fixup.cc void addParentConnection(CDs*, int, int); // export void addParentConnections(CDs*); int addConnection(CDs*, int, int, CDw* = 0); bool checkAddConnection(CDs*, int, int, bool); void fixPaths(CDs*); void install(CDo*, CDs*, bool); // export void uninstall(CDo*, CDs*); // export void fixVertices(CDo*, CDs*); int addConnection(CDo*, int, int, bool); // sced_mutual.cc void showMutualExec(CmdDesc*); bool setMutParam(const char*, int, const char*); char *getMutParam(const char*, int); bool setMutLabel(CDs*, CDp_nmut*, CDp_nmut*); // export void mutToNewMut(CDs*); // export void mutParseName(const char*, char*, char*); // export // sced_netlist.cc bool isCheckingSolitary(); CDpl *getElecNodeProps(CDs*, int); stringlist *getElecNodeContactNames(CDs*, int); stringlist **getElecContactNames(CDs*, int*); // sced_nodemap.cc void setModified(cNodeMap*); // export void destroyNodes(CDs*); // export int findNode(const CDs*, const char*); const char *nodeName(const CDs*, int, bool* = 0); void updateNodes(const CDs*); // export void registerGlobalNetName(const char*); // export bool isGlobalNetName(const char*); SymTab *tabGlobals(CDs*); // sced_plot.cc void showOutputExec(CmdDesc*); void setDoIplotExec(CmdDesc*); int deletePlotRef(hyEnt*); void setPlotMarkColors(); // export void clearPlots(); // export char *getPlotCmd(bool); // export void setPlotCmd(const char*); // export char *getIplotCmd(bool); // export void setIplotCmd(const char*); // export hyList *getPlotList(); // export hyList *getIplotList(); // export // sced_prplabel.cc void genDeviceLabels(CDc*, CDc*, bool); // export void updateNameLabel(CDc*, CDp_cname*); // export bool updateLabelText(CDla*, CDs*, hyList*, BBox*); // export CDla *changeLabel(CDla*, CDs*, hyList*); // export void addDeviceLabel(CDc*, CDp*, CDp*, hyList*, bool, bool); int checkRepositionLabels(const CDc*); // export void labelPlacement(int, CDc*, Label*); // sced_prpty.cc bool setDevicePrpty(const char*, const char*); // export char *getDevicePrpty(const char*); // export CDp *prptyModify(CDc*, CDp*, int, const char*, hyList*); // export CDl *defaultLayer(CDp*); // export // sced_shape.cc const char *const *shapesList(); // export void addShape(int); // export // sced_spicein.cc void dumpDevKeys(); #define EFS_ALLDEVS 0x1 #define EFS_CREATE 0x2 #define EFS_CLEAR 0x4 #define EFS_WIRECAP 0x8 #define EFS_MASK 0xf void extractFromSpice(CDs*, FILE*, int); // sced_spiceout.cc char *getAnalysis(bool); // export void setAnalysis(const char*); // export hyList *getAnalysisList(); // export hyList *setAnalysisList(hyList*); bool dumpSpiceFile(const char*); void dumpSpiceDeck(FILE*); // export SpiceLine *makeSpiceDeck(CDs*, SymTab** = 0); // export stringlist *makeSpiceListing(CDs*); // sced_subckt.cc void showTermsExec(CmdDesc*); void symbolicExec(CmdDesc*); bool setCurSymbolic(bool); bool setCurSymbolicFast(bool); void assertSymbolic(bool); // export bool makeSymbolic(); void subcircuitExec(CmdDesc*); void subcircuitShowConnectPts(bool); bool subcircuitEditTerm(int*, bool*); bool subcircuitSetEditTerm(int, bool); bool subcircuitDeleteTerm(); bool subcircuitBits(bool); bool subcircuitBitsVisible(int); bool subcircuitBitsInvisible(int); // graphics system void PopUpSpiceIf(GRobject, ShowMode); // export void PopUpDevs(GRobject, ShowMode); // export void PopUpDots(GRobject, ShowMode); // export void DevsEscCallback(); // export void PopUpDevEdit(GRobject, ShowMode); // export bool PopUpNodeMap(GRobject, ShowMode, int = -1); // export void PopUpSim(SpType); // export void PopUpTermEdit(GRobject, ShowMode, TermEditInfo*, void(*)(TermEditInfo*, CDp*), CDp*, int, int); cSpiceIPC *spif() { return (sc_spice_interface); } cModLib *modlib() { return (sc_model_library); } void setShowDots(DotsType d) { sc_show_dots = d; } DotsType showingDots() { return (sc_show_dots); } // export // all export void setDoingPlot(bool b) { sc_doing_plot = b; } bool doingPlot() { return (sc_doing_plot); } void setDoingIplot(bool b) { sc_doing_iplot = b; } bool doingIplot() { return (sc_doing_iplot); } void setIplotStatusChanged(bool b) { sc_iplot_status_changed = b; } bool iplotStatusChanged() { return (sc_iplot_status_changed); } void setIncludeNoPhys(bool b) { sc_include_nophys = b; } bool includeNoPhys() { return (sc_include_nophys); } void setShowDevs(bool b) { sc_show_devs = b; } bool showDevs() { return (sc_show_devs); } private: // sced_setif.cc void setupInterface(); // sced_txtcmds.cc void setupBangCmds(); // sced_variables.cc void setupVariables(); cModLib *sc_model_library; // Device model library container. cSpiceIPC *sc_spice_interface; // Spice communications. SymTab *sc_global_tab; // Global node names. hyList *sc_analysis_cmd; // Spice analysis command. hyList *sc_plot_hpr_list; // Selected trace hypertext for plot; hyList *sc_iplot_hpr_list; // Selected trace hypertext for iplot; DotsType sc_show_dots; // Electrical connection indication. bool sc_doing_plot; // In plot mode. bool sc_doing_iplot; // Doing interactive plot. bool sc_iplot_status_changed; // Iplot status changed. bool sc_show_devs; // Device menu is visible. bool sc_include_nophys; // connect() will include nophys devs. cScedGhost *sc_ghost; // Ghost drawing }; #endif
39.413934
81
0.534678
[ "model" ]
ee9e892ad13f0e3cad2eeed8780758bdc349e3af
15,058
h
C
applications/plugins/DEPRECATED/frame/FrameMass.h
sofa-framework/issofa
94855f488465bc3ed41223cbde987581dfca5389
[ "OML" ]
null
null
null
applications/plugins/DEPRECATED/frame/FrameMass.h
sofa-framework/issofa
94855f488465bc3ed41223cbde987581dfca5389
[ "OML" ]
null
null
null
applications/plugins/DEPRECATED/frame/FrameMass.h
sofa-framework/issofa
94855f488465bc3ed41223cbde987581dfca5389
[ "OML" ]
null
null
null
/****************************************************************************** * SOFA, Simulation Open-Framework Architecture, development version * * (c) 2006-2017 INRIA, USTL, UJF, CNRS, MGH * * * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published by * * the Free Software Foundation; either version 2.1 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 Lesser General Public License * * for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************* * Authors: The SOFA Team and external contributors (see Authors.txt) * * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ #ifndef FRAME_FRAMEMASS_H #define FRAME_FRAMEMASS_H #include "AffineTypes.h" #include "QuadraticTypes.h" #include <sofa/defaulttype/RigidTypes.h> #include <sofa/simulation/Visitor.h> #include "initFrame.h" namespace sofa { namespace defaulttype { template<int Nl, int Nc, typename real> class FrameMass; using sofa::simulation::Visitor; //============================================================================= // 3D Frames //============================================================================= template<int Nc, typename real> class FrameMass<3, Nc, real> { public: //typedef real value_type; typedef real Real; typedef typename StdAffineTypes<3,Real>::Deriv AffineDeriv; typedef typename StdRigidTypes<3,Real>::Deriv RigidDeriv; typedef typename StdQuadraticTypes<3,Real>::Deriv QuadraticDeriv; typedef Mat<Nc,Nc,Real> MatMass; typedef Vec<Nc,Real> VecDOFs; typedef vector<double> VD; enum { InDerivDim=Nc};//StdRigidTypes<3,Real>::deriv_total_size }; Real mass; MatMass inertiaMatrix; // Inertia matrix of the object MatMass inertiaMassMatrix; // Inertia matrix of the object * mass of the object MatMass invInertiaMatrix; // inverse of inertiaMatrix MatMass invInertiaMassMatrix; // inverse of inertiaMassMatrix FrameMass ( Real m=1 ) { mass = m; //recalc(); } void operator= ( Real m ) { mass = m; //recalc(); } // operator to cast to const Real operator const Real() const { return mass; } void clear() { inertiaMatrix.clear(); inertiaMassMatrix.clear(); invInertiaMatrix.clear(); invInertiaMassMatrix.clear(); for ( unsigned int i = 0; i < Nc; i++ ) invInertiaMatrix[i][i]=inertiaMatrix[i][i]=invInertiaMassMatrix[i][i]=inertiaMassMatrix[i][i]=(Real)1.; } void recalc() { inertiaMassMatrix = inertiaMatrix * mass; if(!invInertiaMatrix.invert ( inertiaMatrix )) { clear(); std::cerr<<"Warning (FrameMass) : set Mass to identity "<<std::endl; return; } /* bool nullMatrix = true; for ( int i = 0; i < 6; i++ ) for ( int j = 0; j < 6; j++ ) if ( invInertiaMatrix[i][j] != 0 ) nullMatrix = false; if ( nullMatrix ) for ( int i = 0; i < 6; i++ ) invInertiaMatrix[i][i] = 1.0; */ invInertiaMassMatrix.invert ( inertiaMassMatrix ); /* nullMatrix = true; for ( int i = 0; i < 6; i++ ) for ( int j = 0; j < 6; j++ ) if ( invInertiaMassMatrix[i][j] != 0 ) nullMatrix = false; if ( nullMatrix ) for ( int i = 0; i < 6; i++ ) invInertiaMassMatrix[i][i] = mass; */ } /// compute ma = M*a RigidDeriv operator * ( const RigidDeriv& a ) const { // VecDOFs va, vma; // va[0] = getVOrientation(a) [0]; // va[1] = getVOrientation(a) [1]; // va[2] = getVOrientation(a) [2]; // va[3] = getVCenter(a) [0]; // va[4] = getVCenter(a) [1]; // va[5] = getVCenter(a) [2]; return RigidDeriv(inertiaMassMatrix * a.getVAll()); //std::cerr << "inertiaMassMatrix: " << inertiaMassMatrix << std::endl; // RigidDeriv ma; // getVOrientation(ma) [0] = vma[0]; // getVOrientation(ma) [1] = vma[1]; // ma.getVOrientation() [2] = vma[2]; // ma.getVCenter() [0] = vma[3]; // ma.getVCenter() [1] = vma[4]; // ma.getVCenter() [2] = vma[5]; // return ma; } /// compute a = f/m RigidDeriv operator / ( const RigidDeriv& f ) const { // VecDOFs va, vma; // vma[0] = f.getVOrientation() [0]; // vma[1] = f.getVOrientation() [1]; // vma[2] = f.getVOrientation() [2]; // vma[3] = f.getVCenter() [0]; // vma[4] = f.getVCenter() [1]; // vma[5] = f.getVCenter() [2]; return RigidDeriv(invInertiaMassMatrix * f.getVAll()); //std::cerr << "invInertiaMassMatrix: " << invInertiaMassMatrix << std::endl; // RigidDeriv a; // a.getVOrientation() [0] = va[0]; // a.getVOrientation() [1] = va[1]; // a.getVOrientation() [2] = va[2]; // a.getVCenter() [0] = va[3]; // a.getVCenter() [1] = va[4]; // a.getVCenter() [2] = va[5]; // // return a; } /// compute ma = M*a AffineDeriv operator * ( const AffineDeriv& a ) const { // VecDOFs va, vma; // va[0] = getVAffine(a) [0][0]; // va[1] = getVAffine(a) [0][1]; // va[2] = getVAffine(a) [0][2]; // va[3] = getVAffine(a) [1][0]; // va[4] = getVAffine(a) [1][1]; // va[5] = getVAffine(a) [1][2]; // va[6] = getVAffine(a) [2][0]; // va[7] = getVAffine(a) [2][1]; // va[8] = getVAffine(a) [2][2]; // va[9] = getVCenter(a) [0]; // va[10] = getVCenter(a) [1]; // va[11] = getVCenter(a) [2]; return inertiaMassMatrix * a.getVec(); //std::cerr << "inertiaMassMatrix: " << inertiaMassMatrix << std::endl; // AffineDeriv ma; // getVAffine(ma) [0][0] = vma[0]; // getVAffine(ma) [0][1] = vma[1]; // getVAffine(ma) [0][2] = vma[2]; // getVAffine(ma) [1][0] = vma[3]; // getVAffine(ma) [1][1] = vma[4]; // getVAffine(ma) [1][2] = vma[5]; // getVAffine(ma) [2][0] = vma[6]; // getVAffine(ma) [2][1] = vma[7]; // getVAffine(ma) [2][2] = vma[8]; // getVCenter(ma) [0] = vma[9]; // getVCenter(ma) [1] = vma[10]; // getVCenter(ma) [2] = vma[11]; // // return ma; } /// compute a = f/m AffineDeriv operator / ( const AffineDeriv& f ) const { // VecDOFs va, vma; // vma[0] = getVAffine(f) [0][0]; // vma[1] = getVAffine(f) [0][1]; // vma[2] = getVAffine(f) [0][2]; // vma[3] = getVAffine(f) [1][0]; // vma[4] = getVAffine(f) [1][1]; // vma[5] = getVAffine(f) [1][2]; // vma[6] = getVAffine(f) [2][0]; // vma[7] = getVAffine(f) [2][1]; // vma[8] = getVAffine(f) [2][2]; // vma[9] = getVCenter(f) [0]; // vma[10] = getVCenter(f) [1]; // vma[11] = getVCenter(f) [2]; return invInertiaMassMatrix * f.getVec(); //std::cerr << "invInertiaMassMatrix: " << invInertiaMassMatrix << std::endl; // AffineDeriv a; // getVAffine(a) [0][0] = va[0]; // getVAffine(a) [0][1] = va[1]; // getVAffine(a) [0][2] = va[2]; // getVAffine(a) [1][0] = va[3]; // getVAffine(a) [1][1] = va[4]; // getVAffine(a) [1][2] = va[5]; // getVAffine(a) [2][0] = va[6]; // getVAffine(a) [2][1] = va[7]; // getVAffine(a) [2][2] = va[8]; // getVCenter(a) [0] = va[9]; // getVCenter(a) [1] = va[10]; // getVCenter(a) [2] = va[11]; // // return a; } /// compute ma = M*a QuadraticDeriv operator * ( const QuadraticDeriv& a ) const { // const unsigned int& dim = (Nc-3)/3; // VecDOFs va, vma; // for (unsigned int i = 0; i < 3; ++i) // for (unsigned int j = 0; j < dim; ++j) // va[dim*i+j] = getVQuadratic(a) [i][j]; // va[3*dim ] = getVCenter(a) [0]; // va[3*dim+1] = getVCenter(a) [1]; // va[3*dim+2] = getVCenter(a) [2]; return inertiaMassMatrix * a.getVec(); //std::cerr << "inertiaMassMatrix: " << inertiaMassMatrix << std::endl; // QuadraticDeriv ma; // for (unsigned int i = 0; i < 3; ++i) // for (unsigned int j = 0; j < dim; ++j) // getVQuadratic(ma)[i][j] = vma[dim*i+j]; // getVCenter(ma)[0] = vma[3*dim]; // getVCenter(ma)[1] = vma[3*dim+1]; // getVCenter(ma)[2] = vma[3*dim+2]; // // return ma; } /// compute a = f/m QuadraticDeriv operator / ( const QuadraticDeriv& f ) const { // const unsigned int& dim = (Nc-3)/3; // VecDOFs va, vma; // for (unsigned int i = 0; i < 3; ++i) // for (unsigned int j = 0; j < dim; ++j) // vma[dim*i+j] = getVQuadratic(f) [i][j]; // vma[3*dim ] = getVCenter(f) [0]; // vma[3*dim+1] = getVCenter(f) [1]; // vma[3*dim+2] = getVCenter(f) [2]; return invInertiaMassMatrix * f.getVec(); //std::cerr << "invInertiaMassMatrix: " << invInertiaMassMatrix << std::endl; // QuadraticDeriv a; // for (unsigned int i = 0; i < 3; ++i) // for (unsigned int j = 0; j < dim; ++j) // getVQuadratic(a)[i][j] = va[dim*i+j]; // getVCenter(a)[0] = va[3*dim ]; // getVCenter(a)[1] = va[3*dim+1]; // getVCenter(a)[2] = va[3*dim+2]; // // return a; } void operator *= ( Real fact ) { mass *= fact; inertiaMassMatrix *= fact; invInertiaMassMatrix /= fact; } void operator /= ( Real fact ) { mass /= fact; inertiaMassMatrix /= fact; invInertiaMassMatrix *= fact; } inline friend std::ostream& operator << ( std::ostream& out, const FrameMass<3, Nc, real>& m ) { out<<m.mass; out<<" "<<m.inertiaMatrix; return out; } inline friend std::istream& operator >> ( std::istream& in, FrameMass<3, Nc, real>& m ) { in>>m.mass; in>>m.inertiaMatrix; return in; } static const char* Name(); }; template<int Nl, int Nc, typename real> inline typename StdRigidTypes<Nl, real>::Deriv operator* ( const typename StdRigidTypes<Nl,real>::Deriv& d, const FrameMass<Nl, Nc, real>& m ) { return m * d; } template<int Nl, int Nc, typename real> inline typename StdRigidTypes<Nl, real>::Deriv operator/ ( const typename StdRigidTypes<Nl, real>::Deriv& d, const FrameMass<Nl, Nc, real>& m ) { return m / d; } template<int Nl, int Nc, typename real> inline typename StdAffineTypes<Nl, real>::Deriv operator* ( const typename StdAffineTypes<Nl,real>::Deriv& d, const FrameMass<Nl, Nc, real>& m ) { return m * d; } template<int Nl, int Nc, typename real> inline typename StdAffineTypes<Nl, real>::Deriv operator/ ( const typename StdAffineTypes<Nl, real>::Deriv& d, const FrameMass<Nl, Nc, real>& m ) { return m / d; } template<int Nl, int Nc, typename real> inline typename StdQuadraticTypes<Nl, real>::Deriv operator* ( const typename StdQuadraticTypes<Nl,real>::Deriv& d, const FrameMass<Nl, Nc, real>& m ) { return m * d; } template<int Nl, int Nc, typename real> inline typename StdQuadraticTypes<Nl, real>::Deriv operator/ ( const typename StdQuadraticTypes<Nl, real>::Deriv& d, const FrameMass<Nl, Nc, real>& m ) { return m / d; } typedef FrameMass<3,6,double> Frame3x6dMass; typedef FrameMass<3,6,float> Frame3x6fMass; typedef FrameMass<3,12,double> Frame3x12dMass; typedef FrameMass<3,12,float> Frame3x12fMass; typedef FrameMass<3,30,double> Frame3x30dMass; typedef FrameMass<3,30,float> Frame3x30fMass; template<> inline const char* defaulttype::Frame3x6dMass::Name() { return "Frame3x6dMass"; } template<> inline const char* defaulttype::Frame3x6fMass::Name() { return "Frame3x6fMass"; } template<> inline const char* defaulttype::Frame3x12dMass::Name() { return "Frame3x12dMass"; } template<> inline const char* defaulttype::Frame3x12fMass::Name() { return "Frame3x12fMass"; } template<> inline const char* defaulttype::Frame3x30dMass::Name() { return "Frame3x30dMass"; } template<> inline const char* defaulttype::Frame3x30fMass::Name() { return "Frame3x30fMass"; } #ifdef SOFA_FLOAT typedef Frame3x6fMass Frame3x6Mass; typedef Frame3x12fMass Frame3x12Mass; typedef Frame3x30fMass Frame3x130Mass; #else typedef Frame3x6dMass Frame3x6Mass; typedef Frame3x12dMass Frame3x12Mass; typedef Frame3x30dMass Frame3x30Mass; #endif // The next line hides all those methods from the doxygen documentation /// \cond TEMPLATE_OVERRIDES template<> struct DataTypeName< defaulttype::Frame3x6fMass > { static const char* name() { return "Frame3x6fMass"; } }; template<> struct DataTypeName< defaulttype::Frame3x6dMass > { static const char* name() { return "Frame3x6dMass"; } }; template<> struct DataTypeName< defaulttype::Frame3x12fMass > { static const char* name() { return "Frame3x12fMass"; } }; template<> struct DataTypeName< defaulttype::Frame3x12dMass > { static const char* name() { return "Frame3x12dMass"; } }; template<> struct DataTypeName< defaulttype::Frame3x30fMass > { static const char* name() { return "Frame3x30fMass"; } }; template<> struct DataTypeName< defaulttype::Frame3x30dMass > { static const char* name() { return "Frame3x30dMass"; } }; /// \endcond } // namespace defaulttype } // namespace sofa #endif
33.686801
151
0.521583
[ "object", "vector", "3d" ]
6ed878fad90fe906632f74b6517db5e60a19285d
50,652
c
C
net/rras/netsh/if/showmib.c
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
net/rras/netsh/if/showmib.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
net/rras/netsh/if/showmib.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*++ Copyright (c) 1999 Microsoft Corporation Module Name: net\routing\netsh\if\showmib.c Abstract: Fns to parse and show MIB information Author: v raman Revision History: Anand Mahalingam Dave Thaler --*/ #include "precomp.h" #pragma hdrstop #include <time.h> #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) HANDLE g_hConsole, g_hStdOut; MIB_OBJECT_PARSER MIBObjectMap[] = { {TOKEN_MIB_OBJECT_INTERFACE,1,GetMIBIfIndex}, {TOKEN_MIB_OBJECT_IPSTATS, 0,NULL}, {TOKEN_MIB_OBJECT_IPADDRESS,1,GetMIBIpAddress}, {TOKEN_MIB_OBJECT_IPNET, 2,GetMIBIpNetIndex}, {TOKEN_MIB_OBJECT_ICMP, 0,NULL}, {TOKEN_MIB_OBJECT_TCPSTATS, 0,NULL}, {TOKEN_MIB_OBJECT_TCPCONN, 4,GetMIBTcpConnIndex}, {TOKEN_MIB_OBJECT_UDPSTATS, 0,NULL}, {TOKEN_MIB_OBJECT_UDPCONN, 2,GetMIBUdpConnIndex}, }; ULONG g_ulNumMibObjects = sizeof(MIBObjectMap)/sizeof(MIB_OBJECT_PARSER); MAGIC_TABLE MIBVar[] = { {IF_ROW, PrintIfRow}, {IF_TABLE, PrintIfTable}, {IP_STATS, PrintIpStats}, {IP_STATS, PrintIpStats}, {IP_ADDRROW, PrintIpAddrRow}, {IP_ADDRTABLE, PrintIpAddrTable}, {IP_NETROW, PrintIpNetRow}, {IP_NETTABLE, PrintIpNetTable}, {ICMP_STATS, PrintIcmp}, {ICMP_STATS, PrintIcmp}, {TCP_STATS, PrintTcpStats}, {TCP_STATS, PrintTcpStats}, {TCP_ROW, PrintTcpRow}, {TCP_TABLE, PrintTcpTable}, {UDP_STATS, PrintUdpStats}, {UDP_STATS, PrintUdpStats}, {UDP_ROW, PrintUdpRow}, {UDP_TABLE, PrintUdpTable}, }; DWORD GetMIBIfIndex( IN PTCHAR *pptcArguments, IN DWORD dwCurrentIndex, OUT PDWORD pdwIndices, OUT PDWORD pdwNumParsed ) /*++ Routine Description: Gets the interface index. Arguments: pptcArguments - Argument array dwCurrentIndex - Index of the first argument in array pdwIndices - Indices specified in command pdwNumParsed - Number of indices in command Return Value: NO_ERROR, ERROR_INVALID_PARAMETER --*/ { DWORD dwErr = NO_ERROR; *pdwNumParsed = 1; // If index was specified just use it if (iswdigit(pptcArguments[dwCurrentIndex][0])) { pdwIndices[0] = _tcstoul(pptcArguments[dwCurrentIndex],NULL,10); return NO_ERROR; } // Try converting a friendly name to an ifindex return IfutlGetIfIndexFromFriendlyName( pptcArguments[dwCurrentIndex], &pdwIndices[0] ); } DWORD GetMIBIpAddress( IN PTCHAR *pptcArguments, IN DWORD dwCurrentIndex, OUT PDWORD pdwIndices, OUT PDWORD pdwNumParsed ) /*++ Routine Description: Gets the IP address. Arguments: pptcArguments - Argument array dwCurrentIndex - Index of the first argument in array pdwIndices - Indices specified in command pdwNumParsed - Number of indices in command Return Value: NO_ERROR --*/ { DWORD dwErr = GetIpAddress(pptcArguments[dwCurrentIndex], &pdwIndices[0]); *pdwNumParsed = 1; return dwErr; } DWORD GetMIBIpNetIndex( IN PTCHAR *pptcArguments, IN DWORD dwCurrentIndex, OUT PDWORD pdwIndices, OUT PDWORD pdwNumParsed ) /*++ Routine Description: Gets the IP net index Arguments: pptcArguments - Argument array dwCurrentIndex - Index of the first argument in array pdwIndices - Indices specified in command pdwNumParsed - Number of indices in command Return Value: NO_ERROR --*/ { DWORD dwErr; pdwIndices[0] = _tcstoul(pptcArguments[dwCurrentIndex],NULL,10); dwErr = GetIpAddress(pptcArguments[dwCurrentIndex + 1], &pdwIndices[1]); *pdwNumParsed = 2; return dwErr; } DWORD GetMIBTcpConnIndex( IN PTCHAR *pptcArguments, IN DWORD dwCurrentIndex, OUT PDWORD pdwIndices, OUT PDWORD pdwNumParsed ) /*++ Routine Description: Gets the tco conn index Arguments: pptcArguments - Argument array dwCurrentIndex - Index of the first argument in array pdwIndices - Indices specified in command pdwNumParsed - Number of indices in command Return Value: NO_ERROR --*/ { DWORD dwErr = GetIpAddress(pptcArguments[dwCurrentIndex], &pdwIndices[0]); if (dwErr isnot NO_ERROR) { return dwErr; } pdwIndices[1] = htons((WORD)(_tcstoul(pptcArguments[dwCurrentIndex + 1],NULL,10))); dwErr = GetIpAddress(pptcArguments[dwCurrentIndex + 2], &pdwIndices[2]); pdwIndices[3] = htons((WORD)(_tcstoul(pptcArguments[dwCurrentIndex + 3], NULL,10))); *pdwNumParsed = 4; return dwErr; } DWORD GetMIBUdpConnIndex( IN PTCHAR *pptcArguments, IN DWORD dwCurrentIndex, OUT PDWORD pdwIndices, OUT PDWORD pdwNumParsed ) /*++ Routine Description: Gets the udp conn index Arguments: pptcArguments - Argument array dwCurrentIndex - Index of the first argument in array pdwIndices - Indices specified in command pdwNumParsed - Number of indices in command Return Value: NO_ERROR --*/ { DWORD dwErr = GetIpAddress(pptcArguments[dwCurrentIndex], &pdwIndices[0]); pdwIndices[1] = htons((WORD)(_tcstoul(pptcArguments[dwCurrentIndex + 1], NULL,10))); *pdwNumParsed = 2; return dwErr; } DWORD GetIgmpList(IN IPV4_ADDRESS NTEAddr, OUT IPV4_ADDRESS *pIgmpList, OUT PULONG dwOutBufLen ); DWORD GetPrintJoinRow( IPV4_ADDRESS ipAddr ) { DWORD dwOutBufLen = 0; IPV4_ADDRESS *pIgmpList = NULL; DWORD dwStatus; DWORD i; dwStatus = GetIgmpList( ipAddr, pIgmpList, &dwOutBufLen ); if (dwStatus == ERROR_INSUFFICIENT_BUFFER) { pIgmpList = HeapAlloc(GetProcessHeap(), 0, dwOutBufLen); if (!pIgmpList) return ERROR_NOT_ENOUGH_MEMORY; dwStatus = GetIgmpList( ipAddr, pIgmpList, &dwOutBufLen ); } if (dwStatus == STATUS_SUCCESS) { WCHAR pwszIfAddr[20], pwszGrAddr[20]; DWORD dwTotal = dwOutBufLen/sizeof(ipAddr); MakeAddressStringW(pwszIfAddr, ipAddr); if (!pwszIfAddr) return ERROR_NOT_ENOUGH_MEMORY; for (i=0; i<dwTotal; i++) { MakeAddressStringW(pwszGrAddr, pIgmpList[i]); if (!pwszGrAddr) return ERROR_NOT_ENOUGH_MEMORY; DisplayMessage( g_hModule, MSG_MIB_JOIN_ROW, pwszIfAddr, pwszGrAddr ); } } if (pIgmpList) HeapFree(GetProcessHeap(), 0, pIgmpList); return dwStatus; } DWORD GetIPv4Addresses( IN LPSOCKET_ADDRESS_LIST *ppList) { LPSOCKET_ADDRESS_LIST pList = NULL; ULONG ulSize = 0; DWORD dwErr; DWORD dwBytesReturned; SOCKET s; *ppList = NULL; s = socket(AF_INET, SOCK_DGRAM, 0); if (s == INVALID_SOCKET) return WSAGetLastError(); for (;;) { dwErr = WSAIoctl(s, SIO_ADDRESS_LIST_QUERY, NULL, 0, pList, ulSize, &dwBytesReturned, NULL, NULL); if (!dwErr) { break; } if (pList) { FREE(pList); pList = NULL; } dwErr = WSAGetLastError(); if (dwErr != WSAEFAULT) break; pList = MALLOC(dwBytesReturned); if (!pList) { dwErr = ERROR_NOT_ENOUGH_MEMORY; break; } ulSize = dwBytesReturned; } closesocket(s); *ppList = pList; return dwErr; } DWORD HandleIpShowJoins( IN LPCWSTR pwszMachine, IN OUT LPWSTR *ppwcArguments, IN DWORD dwCurrentIndex, IN DWORD dwArgCount, IN DWORD dwFlags, IN LPCVOID pvData, OUT BOOL *pbDone ) { MIB_OPAQUE_QUERY Query; PMIB_IPADDRTABLE lprpcTable; DWORD dwOutBufLen = 0 , dwNumParsed; IPV4_ADDRESS *pIgmpList = NULL, ipAddr; DWORD dwResult = NO_ERROR, dwOutEntrySize; DWORD i; PMIB_OPAQUE_INFO pRpcInfo; PWCHAR pszIfAddr; IFMON_CMD_ARG pArgs[] = { { IFMON_CMD_TYPE_STRING, {TOKEN_ADDR, FALSE, FALSE}, NULL, 0, NULL } }; do { dwResult = IfutlParse( ppwcArguments, dwCurrentIndex, dwArgCount, NULL, pArgs, sizeof(pArgs) / sizeof(*pArgs)); if (dwResult) { break; } DisplayMessage(g_hModule, MSG_MIB_JOIN_HDR); if (pArgs[0].rgTag.bPresent) { // address specified pszIfAddr = IFMON_CMD_ARG_GetPsz(&pArgs[0]); dwResult = GetIpAddress( pszIfAddr, &ipAddr ); if (dwResult) { break; } GetPrintJoinRow(ipAddr); } else { SOCKET_ADDRESS_LIST *pList; INT j; // Get all IPv4 addresses dwResult = GetIPv4Addresses(&pList); if (dwResult != NO_ERROR) break; // For each IPv4 address for (j=0; j<pList->iAddressCount; j++) { GetPrintJoinRow( ((LPSOCKADDR_IN)pList->Address[j].lpSockaddr)->sin_addr.s_addr ); } FREE(pList); } } while (FALSE); return dwResult; } DWORD HandleIpMibShowObject( IN LPCWSTR pwszMachine, IN OUT LPWSTR *ppwcArguments, IN DWORD dwCurrentIndex, IN DWORD dwArgCount, IN DWORD dwFlags, IN LPCVOID pvData, OUT BOOL *pbDone ) /*++ Routine Description: Parses command to get MIB object and optional parameters Arguments: Return Value: --*/ { DWORD dwIndices[MAX_NUM_INDICES]; DWORD dwNumParsed = 0; PMIB_OPAQUE_QUERY pQuery = NULL; PMIB_OPAQUE_INFO pRpcInfo; DWORD dwQuerySize; BOOL bFound = FALSE,bOptPresent = FALSE; DWORD dwRefreshRate; DWORD dwOutEntrySize; DWORD i,dwResult,dwErr; DWORD dwMIBIndex, dwIndex; BOOL bIndex = FALSE, dwType; DWORD dwRR = 0, dwInd = 0; HANDLE hMib; #if 0 TOKEN_VALUE tvMfeTypes[] = { { TOKEN_VALUE_POSITIVE, PositiveMfe }, { TOKEN_VALUE_NEGATIVE, NegativeMfe }, { TOKEN_VALUE_BOTH, Both } }; #endif if ( ! IfutlIsRouterRunning() ) { if (g_pwszRouter) { DisplayMessage(g_hModule, MSG_IP_REMOTE_ROUTER_NOT_RUNNING, g_pwszRouter); } else { DisplayMessage(g_hModule, MSG_IP_LOCAL_ROUTER_NOT_RUNNING); } return NO_ERROR; } // // Match MIB object // ppwcArguments += (dwCurrentIndex-1); dwArgCount -= (dwCurrentIndex-1); dwCurrentIndex = 1; //DEBUG2("In IP MIB Show : %s\n",pptcArguments[0]); for (i = 0; i < sizeof(MIBObjectMap)/sizeof(MIB_OBJECT_PARSER); i++) { if (MatchToken(ppwcArguments[0],MIBObjectMap[i].pwszMIBObj)) { dwIndex = i; bFound = TRUE; break; } } if (!bFound) { return ERROR_CMD_NOT_FOUND; } #if 0 // // Special case for MFEs where MFE type is specified // before index option // if ( ( MIBVar[ 2 * dwIndex ].dwId is MCAST_MFE ) || ( MIBVar[ 2 * dwIndex ].dwId is MCAST_MFE_STATS ) ) { if ( dwArgCount > 1 ) { if ( !_wcsnicmp( ppwcArguments[ 1 ], L"TYPE=", 5 ) ) { wcscpy( ppwcArguments[ 1 ], &ppwcArguments[ 1 ][ 5 ] ); } dwErr = MatchEnumTag( g_hModule, ppwcArguments[ 1 ], NUM_TOKENS_IN_TABLE( tvMfeTypes ), tvMfeTypes, &dwType ); } else { dwErr = ERROR_INVALID_PARAMETER; } if (dwErr isnot NO_ERROR) { return ERROR_INVALID_SYNTAX; } dwErr = GetMibTagToken(&ppwcArguments[2], dwArgCount - 2, MIBObjectMap[dwIndex].dwMinOptArg, &dwRR, &bIndex, &dwInd); } else #endif { dwErr = GetMibTagToken(&ppwcArguments[1], dwArgCount - 1, MIBObjectMap[dwIndex].dwMinOptArg, &dwRR, &bIndex, &dwInd); } if (dwErr isnot NO_ERROR) { return ERROR_INVALID_SYNTAX; } if (bIndex) { dwMIBIndex = dwIndex * 2; bOptPresent = TRUE; } else { dwMIBIndex = dwIndex * 2 + 1; } // // Convert refresh rate to msec // dwRR *= 1000; if (!InitializeConsole(&dwRR, &hMib, &g_hConsole)) { return ERROR_INIT_DISPLAY; } // // Query the MIB // pQuery = NULL; for ( ; ; ) { if(dwRR) { DisplayMessageToConsole(g_hModule, g_hConsole, MSG_CTRL_C_TO_QUIT); } // always... { if (!(dwMIBIndex % 2)) { (*MIBObjectMap[dwIndex].pfnMIBObjParser)(ppwcArguments, 1, dwIndices, &dwNumParsed); } dwQuerySize = ( sizeof( MIB_OPAQUE_QUERY ) - sizeof( DWORD ) ) + (dwNumParsed) * sizeof(DWORD); pQuery = (PMIB_OPAQUE_QUERY)HeapAlloc(GetProcessHeap(), 0, dwQuerySize); if (pQuery is NULL) { dwErr = ERROR_NOT_ENOUGH_MEMORY; DisplayMessage(g_hModule, MSG_IP_NOT_ENOUGH_MEMORY); return dwErr; } pQuery->dwVarId = MIBVar[dwMIBIndex].dwId; for( i = 0; i < dwNumParsed; i++ ) { pQuery->rgdwVarIndex[i] = dwIndices[i]; } dwResult = MibGet( PID_IP, IPRTRMGR_PID, (PVOID) pQuery, dwQuerySize, (PVOID *) &pRpcInfo, &dwOutEntrySize ); if ( dwResult isnot NO_ERROR ) { DisplayMessage(g_hModule, MSG_IP_DIM_ERROR, dwResult ); return dwResult; } if ( pRpcInfo is NULL ) { DisplayMessage(g_hModule, MSG_IP_NO_ENTRIES ); return dwResult; } (*MIBVar[dwMIBIndex].pfnPrintFunction)(g_hMIBServer, pRpcInfo); MprAdminMIBBufferFree( (PVOID) pRpcInfo ); } if(pQuery != NULL ) { HeapFree(GetProcessHeap(),0,pQuery); } if (!RefreshConsole(hMib, g_hConsole, dwRR)) { break; } } return dwResult; } VOID PrintIfTable( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints interface table information Arguments: Return Value: --*/ { PMIB_IFTABLE lprpcTable = (PMIB_IFTABLE)(prpcInfo->rgbyData); PTCHAR ptszIfType, ptszOper, ptszAdmin; TCHAR tszDescr[MAXLEN_IFDESCR + 1], tszIfName[MAX_INTERFACE_NAME_LEN + 1]; TCHAR tszPhysAddr[DISPLAYLEN_PHYSADDR + 1]; WCHAR wszBuffer[MAX_INTERFACE_NAME_LEN+1]; DWORD dwSize; DWORD dwCount = lprpcTable->dwNumEntries; DWORD i; DisplayMessageToConsole(g_hModule, g_hConsole, MSG_MIB_IF_HDR); if ( dwCount is 0 ) { DisplayMessageToConsole(g_hModule, g_hConsole, MSG_IP_NO_ENTRIES); return; } for(i = 0; i < dwCount; i++) { switch(lprpcTable->table[i].dwType) { case IF_TYPE_ETHERNET_CSMACD: { ptszIfType = MakeString(g_hModule, STRING_ETHERNET); break; } case IF_TYPE_ISO88025_TOKENRING: { ptszIfType = MakeString(g_hModule, STRING_TOKENRING); break; } case IF_TYPE_FDDI: { ptszIfType = MakeString(g_hModule, STRING_FDDI); break; } case IF_TYPE_PPP: { ptszIfType = MakeString(g_hModule, STRING_PPP); break; } case IF_TYPE_SOFTWARE_LOOPBACK: { ptszIfType = MakeString(g_hModule, STRING_LOOPBACK); break; } case IF_TYPE_SLIP: { ptszIfType = MakeString(g_hModule, STRING_SLIP); break; } case IF_TYPE_OTHER: default: { ptszIfType = MakeString(g_hModule, STRING_OTHER); break; } } switch(lprpcTable->table[i].dwAdminStatus) { case IF_ADMIN_STATUS_UP: { ptszAdmin = MakeString(g_hModule, STRING_UP); break; } case IF_ADMIN_STATUS_TESTING: { ptszAdmin = MakeString(g_hModule, STRING_TESTING); break; } case IF_ADMIN_STATUS_DOWN: default: { ptszAdmin = MakeString(g_hModule, STRING_DOWN); break; } } switch(lprpcTable->table[i].dwOperStatus) { case IF_OPER_STATUS_UNREACHABLE: { ptszOper = MakeString(g_hModule, STRING_UNREACHABLE); break; } case IF_OPER_STATUS_DISCONNECTED: { ptszOper = MakeString(g_hModule, STRING_DISCONNECTED); break; } case IF_OPER_STATUS_CONNECTING: { ptszOper = MakeString(g_hModule, STRING_CONNECTING); break; } case IF_OPER_STATUS_CONNECTED: { ptszOper = MakeString(g_hModule, STRING_CONNECTED); break; } case IF_OPER_STATUS_OPERATIONAL: { ptszOper = MakeString(g_hModule, STRING_OPERATIONAL); break; } case IF_OPER_STATUS_NON_OPERATIONAL: default: { ptszOper = MakeString(g_hModule, STRING_NON_OPERATIONAL); break; } } #ifdef UNICODE wcscpy(tszIfName, lprpcTable->table[i].wszName); MultiByteToWideChar(GetConsoleOutputCP(), 0, lprpcTable->table[i].bDescr, -1, tszDescr, MAXLEN_IFDESCR); #else WideCharToMultiByte(GetConsoleOutputCP(), 0, lprpcTable->table[i].wszName, -1, tszIfName, MAX_INTERFACE_NAME_LEN, NULL, NULL); strcpy(tszDescr,lprpcTable->table[i].bDescr); #endif if (lprpcTable->table[i].dwPhysAddrLen == 0) { tszPhysAddr[0] = TEXT('\0'); } else { MakeUnicodePhysAddr(tszPhysAddr, lprpcTable->table[i].bPhysAddr, lprpcTable->table[i].dwPhysAddrLen); } dwSize = sizeof(wszBuffer); IfutlGetInterfaceDescription( tszIfName, wszBuffer, &dwSize ); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_INTERFACE, lprpcTable->table[i].dwIndex, wszBuffer, tszIfName, ptszIfType, lprpcTable->table[i].dwMtu, lprpcTable->table[i].dwSpeed, tszPhysAddr, ptszAdmin, ptszOper, lprpcTable->table[i].dwLastChange, lprpcTable->table[i].dwInOctets, lprpcTable->table[i].dwInUcastPkts, lprpcTable->table[i].dwInNUcastPkts, lprpcTable->table[i].dwInDiscards, lprpcTable->table[i].dwInErrors, lprpcTable->table[i].dwInUnknownProtos, lprpcTable->table[i].dwOutOctets, lprpcTable->table[i].dwOutUcastPkts, lprpcTable->table[i].dwOutNUcastPkts, lprpcTable->table[i].dwOutDiscards, lprpcTable->table[i].dwOutErrors, lprpcTable->table[i].dwOutQLen, tszDescr); FreeString(ptszIfType); FreeString(ptszAdmin); FreeString(ptszOper); } } VOID PrintIfRow( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints interface row information Arguments: Return Value: --*/ { PMIB_IFROW ieRow = (PMIB_IFROW)(prpcInfo->rgbyData); PTCHAR ptszIfType, ptszOper, ptszAdmin; TCHAR tszDescr[MAXLEN_IFDESCR + 1], tszIfName[MAX_INTERFACE_NAME_LEN + 1]; TCHAR tszPhysAddr[DISPLAYLEN_PHYSADDR + 1]; WCHAR wszBuffer[MAX_INTERFACE_NAME_LEN+1]; DWORD dwSize; DisplayMessageToConsole(g_hModule, g_hConsole, MSG_MIB_IF_HDR); switch(ieRow->dwType) { case IF_TYPE_ETHERNET_CSMACD: { ptszIfType = MakeString(g_hModule, STRING_ETHERNET); break; } case IF_TYPE_ISO88025_TOKENRING: { ptszIfType = MakeString(g_hModule, STRING_TOKENRING); break; } case IF_TYPE_FDDI: { ptszIfType = MakeString(g_hModule, STRING_FDDI); break; } case IF_TYPE_PPP: { ptszIfType = MakeString(g_hModule, STRING_PPP); break; } case IF_TYPE_SOFTWARE_LOOPBACK: { ptszIfType = MakeString(g_hModule, STRING_LOOPBACK); break; } case IF_TYPE_SLIP: { ptszIfType = MakeString(g_hModule, STRING_SLIP); break; } case IF_TYPE_OTHER: default: { ptszIfType = MakeString(g_hModule, STRING_OTHER); break; } } switch(ieRow->dwAdminStatus) { case IF_ADMIN_STATUS_UP: { ptszAdmin = MakeString(g_hModule, STRING_UP); break; } case IF_ADMIN_STATUS_TESTING: { ptszAdmin = MakeString(g_hModule, STRING_TESTING); break; } case IF_ADMIN_STATUS_DOWN: default: { ptszAdmin = MakeString(g_hModule, STRING_DOWN); break; } } switch(ieRow->dwOperStatus) { case IF_OPER_STATUS_UNREACHABLE: { ptszOper = MakeString(g_hModule, STRING_UNREACHABLE); break; } case IF_OPER_STATUS_DISCONNECTED: { ptszOper = MakeString(g_hModule, STRING_DISCONNECTED); break; } case IF_OPER_STATUS_CONNECTING: { ptszOper = MakeString(g_hModule, STRING_CONNECTING); break; } case IF_OPER_STATUS_CONNECTED: { ptszOper = MakeString(g_hModule, STRING_CONNECTED); break; } case IF_OPER_STATUS_OPERATIONAL: { ptszOper = MakeString(g_hModule, STRING_OPERATIONAL); break; } case IF_OPER_STATUS_NON_OPERATIONAL: default: { ptszOper = MakeString(g_hModule, STRING_NON_OPERATIONAL); break; } } #ifdef UNICODE wcscpy(tszIfName, ieRow->wszName); MultiByteToWideChar(GetConsoleOutputCP(), 0, ieRow->bDescr, -1, tszDescr, MAXLEN_IFDESCR); #else WideCharToMultiByte(GetConsoleOutputCP(), 0, ieRow->wszName, -1, tszIfName, MAX_INTERFACE_NAME_LEN, NULL, NULL); strcpy(tszDescr,ieRow->bDescr); #endif if (ieRow->dwPhysAddrLen == 0) { tszPhysAddr[0] = TEXT('\0'); } else { MakeUnicodePhysAddr(tszPhysAddr,ieRow->bPhysAddr,ieRow->dwPhysAddrLen); } dwSize = sizeof(wszBuffer); IfutlGetInterfaceDescription( tszIfName, wszBuffer, &dwSize ); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_INTERFACE, ieRow->dwIndex, wszBuffer, tszIfName, ptszIfType, ieRow->dwMtu, ieRow->dwSpeed, tszPhysAddr, ptszAdmin, ptszOper, ieRow->dwLastChange, ieRow->dwInOctets, ieRow->dwInUcastPkts, ieRow->dwInNUcastPkts, ieRow->dwInDiscards, ieRow->dwInErrors, ieRow->dwInUnknownProtos, ieRow->dwOutOctets, ieRow->dwOutUcastPkts, ieRow->dwOutNUcastPkts, ieRow->dwOutDiscards, ieRow->dwOutErrors, ieRow->dwOutQLen, tszDescr); FreeString(ptszIfType); FreeString(ptszAdmin); FreeString(ptszOper); } VOID PrintIcmp( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints ICMP information. Arguments: Return Value: --*/ { PMIB_ICMP lprpcIcmp = (PMIB_ICMP)(prpcInfo->rgbyData); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_ICMP, lprpcIcmp->stats.icmpInStats.dwMsgs, lprpcIcmp->stats.icmpInStats.dwErrors, lprpcIcmp->stats.icmpInStats.dwDestUnreachs, lprpcIcmp->stats.icmpInStats.dwTimeExcds, lprpcIcmp->stats.icmpInStats.dwParmProbs, lprpcIcmp->stats.icmpInStats.dwSrcQuenchs, lprpcIcmp->stats.icmpInStats.dwRedirects, lprpcIcmp->stats.icmpInStats.dwEchos, lprpcIcmp->stats.icmpInStats.dwEchoReps, lprpcIcmp->stats.icmpInStats.dwTimestamps, lprpcIcmp->stats.icmpInStats.dwTimestampReps, lprpcIcmp->stats.icmpInStats.dwAddrMasks, lprpcIcmp->stats.icmpInStats.dwAddrMaskReps, lprpcIcmp->stats.icmpOutStats.dwMsgs, lprpcIcmp->stats.icmpOutStats.dwErrors, lprpcIcmp->stats.icmpOutStats.dwDestUnreachs, lprpcIcmp->stats.icmpOutStats.dwTimeExcds, lprpcIcmp->stats.icmpOutStats.dwParmProbs, lprpcIcmp->stats.icmpOutStats.dwSrcQuenchs, lprpcIcmp->stats.icmpOutStats.dwRedirects, lprpcIcmp->stats.icmpOutStats.dwEchos, lprpcIcmp->stats.icmpOutStats.dwEchoReps, lprpcIcmp->stats.icmpOutStats.dwTimestamps, lprpcIcmp->stats.icmpOutStats.dwTimestampReps, lprpcIcmp->stats.icmpOutStats.dwAddrMasks, lprpcIcmp->stats.icmpOutStats.dwAddrMaskReps); } VOID PrintUdpStats( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints UDP statistics. Arguments: Return Value: --*/ { PMIB_UDPSTATS lprpcUdp = (PMIB_UDPSTATS)(prpcInfo->rgbyData); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_UDP_STATS, lprpcUdp->dwInDatagrams, lprpcUdp->dwNoPorts, lprpcUdp->dwInErrors, lprpcUdp->dwOutDatagrams); } VOID PrintUdpTable( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints UDP table information. Arguments: Return Value: --*/ { PMIB_UDPTABLE lprpcTable = (PMIB_UDPTABLE)(prpcInfo->rgbyData); TCHAR tszAddr[ADDR_LENGTH + 1]; DWORD i; DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_UDP_ENTRY_HDR); if(lprpcTable->dwNumEntries is 0) { DisplayMessageToConsole(g_hModule, g_hConsole,MSG_IP_NO_ENTRIES); return; } for(i = 0; i < lprpcTable->dwNumEntries; i++) { MakeUnicodeIpAddr(tszAddr, inet_ntoa(*((struct in_addr *)(&lprpcTable->table[i].dwLocalAddr)))); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_UDP_ENTRY, tszAddr, ntohs((WORD)lprpcTable->table[i].dwLocalPort)); } } VOID PrintUdpRow( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints UDP row information. Arguments: Return Value: --*/ { PMIB_UDPROW ueRow = (PMIB_UDPROW)(prpcInfo->rgbyData); TCHAR tszAddr[ADDR_LENGTH + 1]; DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_UDP_ENTRY_HDR); MakeUnicodeIpAddr(tszAddr,inet_ntoa(*((struct in_addr *) (&ueRow->dwLocalAddr)))); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_UDP_ENTRY, tszAddr, ntohs((WORD)ueRow->dwLocalPort)); } VOID PrintTcpStats( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints TCP Statistics Arguments: Return Value: --*/ { PMIB_TCPSTATS lprpcTcp = (PMIB_TCPSTATS)(prpcInfo->rgbyData); PTCHAR ptszMaxConn, ptszAlgo; switch(lprpcTcp->dwRtoAlgorithm) { case MIB_TCP_RTO_CONSTANT: { ptszAlgo = MakeString(g_hModule, STRING_CONSTANT); break; } case MIB_TCP_RTO_RSRE: { ptszAlgo = MakeString(g_hModule, STRING_RSRE); break; } case MIB_TCP_RTO_VANJ: { ptszAlgo = MakeString(g_hModule, STRING_VANJ); break; } case MIB_TCP_RTO_OTHER: default: { ptszAlgo = MakeString(g_hModule, STRING_OTHER); break; } } if(lprpcTcp->dwMaxConn is MIB_TCP_MAXCONN_DYNAMIC) { ptszMaxConn = MakeString(g_hModule, STRING_DYNAMIC); } else { ptszMaxConn = HeapAlloc(GetProcessHeap(),0,20); if(ptszMaxConn is NULL) { return; } _stprintf(ptszMaxConn,TEXT("%d"),lprpcTcp->dwMaxConn); } DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_TCP_STATS, ptszAlgo, lprpcTcp->dwRtoMin, lprpcTcp->dwRtoMax, ptszMaxConn, lprpcTcp->dwActiveOpens, lprpcTcp->dwPassiveOpens, lprpcTcp->dwAttemptFails, lprpcTcp->dwEstabResets, lprpcTcp->dwCurrEstab, lprpcTcp->dwInSegs, lprpcTcp->dwOutSegs, lprpcTcp->dwRetransSegs, lprpcTcp->dwInErrs, lprpcTcp->dwOutRsts); FreeString(ptszAlgo); if(lprpcTcp->dwMaxConn is MIB_TCP_MAXCONN_DYNAMIC) { FreeString(ptszMaxConn); } else { HeapFree(GetProcessHeap,0,ptszMaxConn); } } VOID PrintTcpTable( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints TCP table information. Arguments: Return Value: --*/ { PMIB_TCPTABLE lprpcTable = (PMIB_TCPTABLE)(prpcInfo->rgbyData); TCHAR tszLAddr[ADDR_LENGTH + 1], tszRAddr[ADDR_LENGTH + 1]; PTCHAR ptszState; DWORD i; DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_TCP_ENTRY_HDR); if(lprpcTable->dwNumEntries is 0) { DisplayMessageToConsole(g_hModule, g_hConsole,MSG_IP_NO_ENTRIES); return; } for(i = 0; i < lprpcTable->dwNumEntries; i++) { switch(lprpcTable->table[i].dwState) { case MIB_TCP_STATE_CLOSED: { ptszState = MakeString(g_hModule, STRING_CLOSED); break; } case MIB_TCP_STATE_LISTEN: { ptszState = MakeString(g_hModule, STRING_LISTEN); break; } case MIB_TCP_STATE_SYN_SENT: { ptszState = MakeString(g_hModule, STRING_SYN_SENT); break; } case MIB_TCP_STATE_SYN_RCVD: { ptszState = MakeString(g_hModule, STRING_SYN_RCVD); break; } case MIB_TCP_STATE_ESTAB: { ptszState = MakeString(g_hModule, STRING_ESTAB); break; } case MIB_TCP_STATE_FIN_WAIT1: { ptszState = MakeString(g_hModule, STRING_FIN_WAIT1); break; } case MIB_TCP_STATE_FIN_WAIT2: { ptszState = MakeString(g_hModule, STRING_FIN_WAIT2); break; } case MIB_TCP_STATE_CLOSE_WAIT: { ptszState = MakeString(g_hModule, STRING_CLOSE_WAIT); break; } case MIB_TCP_STATE_CLOSING: { ptszState = MakeString(g_hModule, STRING_CLOSING); break; } case MIB_TCP_STATE_LAST_ACK: { ptszState = MakeString(g_hModule, STRING_LAST_ACK); break; } case MIB_TCP_STATE_TIME_WAIT: { ptszState = MakeString(g_hModule, STRING_TIME_WAIT); break; } case MIB_TCP_STATE_DELETE_TCB : { ptszState = MakeString(g_hModule, STRING_DELETE_TCB); break; } } MakeUnicodeIpAddr(tszLAddr, inet_ntoa(*((struct in_addr *) (&lprpcTable->table[i].dwLocalAddr)))); MakeUnicodeIpAddr(tszRAddr, inet_ntoa(*((struct in_addr *) (&lprpcTable->table[i].dwRemoteAddr)))); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_TCP_ENTRY, tszLAddr, ntohs((WORD)lprpcTable->table[i].dwLocalPort), tszRAddr, ntohs((WORD)lprpcTable->table[i].dwRemotePort), ptszState); FreeString(ptszState); } } VOID PrintTcpRow( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints TCP row information. Arguments: Return Value: --*/ { PMIB_TCPROW tcteRow = (PMIB_TCPROW)(prpcInfo->rgbyData); TCHAR tszLAddr[ADDR_LENGTH + 1], tszRAddr[ADDR_LENGTH + 1]; PTCHAR ptszState; DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_TCP_ENTRY_HDR); switch(tcteRow->dwState) { case MIB_TCP_STATE_CLOSED: { ptszState = MakeString(g_hModule, STRING_CLOSED); break; } case MIB_TCP_STATE_LISTEN: { ptszState = MakeString(g_hModule, STRING_LISTEN); break; } case MIB_TCP_STATE_SYN_SENT: { ptszState = MakeString(g_hModule, STRING_SYN_SENT); break; } case MIB_TCP_STATE_SYN_RCVD: { ptszState = MakeString(g_hModule, STRING_SYN_RCVD); break; } case MIB_TCP_STATE_ESTAB: { ptszState = MakeString(g_hModule, STRING_ESTAB); break; } case MIB_TCP_STATE_FIN_WAIT1: { ptszState = MakeString(g_hModule, STRING_FIN_WAIT1); break; } case MIB_TCP_STATE_FIN_WAIT2: { ptszState = MakeString(g_hModule, STRING_FIN_WAIT2); break; } case MIB_TCP_STATE_CLOSE_WAIT: { ptszState = MakeString(g_hModule, STRING_CLOSE_WAIT); break; } case MIB_TCP_STATE_CLOSING: { ptszState = MakeString(g_hModule, STRING_CLOSING); break; } case MIB_TCP_STATE_LAST_ACK: { ptszState = MakeString(g_hModule, STRING_LAST_ACK); break; } case MIB_TCP_STATE_TIME_WAIT: { ptszState = MakeString(g_hModule, STRING_TIME_WAIT); break; } case MIB_TCP_STATE_DELETE_TCB : { ptszState = MakeString(g_hModule, STRING_DELETE_TCB); break; } } MakeUnicodeIpAddr(tszLAddr, inet_ntoa(*((struct in_addr *) (&tcteRow->dwLocalAddr)))); MakeUnicodeIpAddr(tszRAddr, inet_ntoa(*((struct in_addr *) (&tcteRow->dwRemoteAddr)))); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_TCP_ENTRY, tszLAddr, ntohs((WORD)tcteRow->dwLocalPort), tszRAddr, ntohs((WORD)tcteRow->dwRemotePort), ptszState); FreeString(ptszState); } VOID PrintIpStats( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) { PMIB_IPSTATS lprpcIp = (PMIB_IPSTATS)(prpcInfo->rgbyData); PTCHAR ptszForw; if(lprpcIp->dwForwarding is MIB_IP_FORWARDING) { ptszForw = MakeString(g_hModule, STRING_ENABLED); } else { ptszForw = MakeString(g_hModule, STRING_DISABLED); } DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_STATS, ptszForw, lprpcIp->dwDefaultTTL, lprpcIp->dwInReceives, lprpcIp->dwInHdrErrors, lprpcIp->dwInAddrErrors, lprpcIp->dwForwDatagrams, lprpcIp->dwInUnknownProtos, lprpcIp->dwInDiscards, lprpcIp->dwInDelivers, lprpcIp->dwOutRequests, lprpcIp->dwRoutingDiscards, lprpcIp->dwOutDiscards, lprpcIp->dwOutNoRoutes, lprpcIp->dwReasmTimeout, lprpcIp->dwReasmReqds, lprpcIp->dwReasmOks, lprpcIp->dwReasmFails, lprpcIp->dwFragOks, lprpcIp->dwFragFails, lprpcIp->dwFragCreates); FreeString(ptszForw); } VOID PrintIpAddrTable( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints IP address table. Arguments: Return Value: --*/ { WCHAR wszFriendlyName[MAX_INTERFACE_NAME_LEN + 1]; PMIB_IPADDRTABLE lprpcTable; TCHAR tszAddr[ADDR_LENGTH + 1], tszMask[ADDR_LENGTH + 1]; DWORD i, dwErr = NO_ERROR; lprpcTable = (PMIB_IPADDRTABLE)(prpcInfo->rgbyData); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_ADDR_HDR); if(lprpcTable->dwNumEntries is 0) { DisplayMessageToConsole(g_hModule, g_hConsole,MSG_IP_NO_ENTRIES); return; } for(i = 0; i < lprpcTable->dwNumEntries; i++) { DWORD BufLen; MakeUnicodeIpAddr(tszAddr, inet_ntoa(*((struct in_addr *) (&lprpcTable->table[i].dwAddr)))); MakeUnicodeIpAddr(tszMask, inet_ntoa(*((struct in_addr *) (&lprpcTable->table[i].dwMask)))); BufLen = sizeof(wszFriendlyName); dwErr = IfutlGetFriendlyNameFromIfIndex( hMibServer, lprpcTable->table[i].dwIndex, wszFriendlyName,//in bytes. not chars BufLen ); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_ADDR_ENTRY, tszAddr, tszMask, lprpcTable->table[i].dwBCastAddr, lprpcTable->table[i].dwReasmSize, wszFriendlyName ); } } VOID PrintIpAddrRow( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints IP address table row. Arguments: Return Value: --*/ { WCHAR wszFriendlyName[MAX_INTERFACE_NAME_LEN + 1]; PMIB_IPADDRROW iaeRow = (PMIB_IPADDRROW)(prpcInfo->rgbyData); DWORD dwErr = NO_ERROR; TCHAR tszAddr[ADDR_LENGTH + 1], tszMask[ADDR_LENGTH + 1]; DWORD BufLen; MakeUnicodeIpAddr(tszAddr, inet_ntoa(*((struct in_addr *)(&iaeRow->dwAddr)))); MakeUnicodeIpAddr(tszMask, inet_ntoa(*((struct in_addr *)(&iaeRow->dwMask)))); BufLen = sizeof(wszFriendlyName); dwErr = IfutlGetFriendlyNameFromIfIndex( hMibServer, iaeRow->dwIndex, wszFriendlyName,//in bytes. not chars BufLen ); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_ADDR_HDR); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_ADDR_ENTRY, tszAddr, tszMask, iaeRow->dwBCastAddr, iaeRow->dwReasmSize, wszFriendlyName ); } VOID PrintIpNetTable( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints IP net table information. Arguments: Return Value: --*/ { WCHAR wszFriendlyName[MAX_INTERFACE_NAME_LEN + 1]; PMIB_IPNETTABLE lprpcTable = (PMIB_IPNETTABLE)(prpcInfo->rgbyData); TCHAR tszPhysAddr[DISPLAYLEN_PHYSADDR + 1], tszIpAddr[ADDR_LENGTH + 1]; PTCHAR ptszType; DWORD i, dwErr = NO_ERROR; DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_NET_HDR); if(lprpcTable->dwNumEntries is 0) { DisplayMessageToConsole(g_hModule, g_hConsole,MSG_IP_NO_ENTRIES); return; } for(i = 0; i < lprpcTable->dwNumEntries; i++) { DWORD BufLen; switch(lprpcTable->table[i].dwType) { case MIB_IPNET_TYPE_INVALID: { ptszType = MakeString(g_hModule, STRING_INVALID); break; } case MIB_IPNET_TYPE_DYNAMIC: { ptszType = MakeString(g_hModule, STRING_DYNAMIC); break; } case MIB_IPNET_TYPE_STATIC: { ptszType = MakeString(g_hModule, STRING_STATIC); break; } case MIB_IPNET_TYPE_OTHER: default: { ptszType = MakeString(g_hModule, STRING_OTHER); break; } } MakeUnicodeIpAddr(tszIpAddr, inet_ntoa(*((struct in_addr *) (&lprpcTable->table[i].dwAddr)))); MakeUnicodePhysAddr(tszPhysAddr, lprpcTable->table[i].bPhysAddr, lprpcTable->table[i].dwPhysAddrLen); BufLen = sizeof(wszFriendlyName); dwErr = IfutlGetFriendlyNameFromIfIndex( hMibServer, lprpcTable->table[i].dwIndex, wszFriendlyName,//in bytes. not chars BufLen); if (dwErr != NO_ERROR) { wcscpy(wszFriendlyName, L"?"); } DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_NET_ENTRY, wszFriendlyName, tszPhysAddr, tszIpAddr, ptszType); FreeString(ptszType); } } VOID PrintIpNetRow( MIB_SERVER_HANDLE hMibServer, PMIB_OPAQUE_INFO prpcInfo ) /*++ Routine Description: Prints IP net row information. Arguments: Return Value: --*/ { WCHAR wszFriendlyName[MAX_INTERFACE_NAME_LEN + 1]; PMIB_IPNETROW inmeRow = (PMIB_IPNETROW)(prpcInfo->rgbyData); TCHAR tszPhysAddr[DISPLAYLEN_PHYSADDR + 1], tszIpAddr[ADDR_LENGTH + 1]; PTCHAR ptszType; DWORD dwErr = NO_ERROR; DWORD BufLen; switch(inmeRow->dwType) { case MIB_IPNET_TYPE_INVALID: { ptszType = MakeString(g_hModule, STRING_INVALID); break; } case MIB_IPNET_TYPE_DYNAMIC: { ptszType = MakeString(g_hModule, STRING_DYNAMIC); break; } case MIB_IPNET_TYPE_STATIC: { ptszType = MakeString(g_hModule, STRING_STATIC); break; } case MIB_IPNET_TYPE_OTHER: default: { ptszType = MakeString(g_hModule, STRING_OTHER); break; } } MakeUnicodeIpAddr(tszIpAddr, inet_ntoa(*((struct in_addr *)(&inmeRow->dwAddr)))); MakeUnicodePhysAddr(tszPhysAddr,inmeRow->bPhysAddr,inmeRow->dwPhysAddrLen); BufLen = sizeof(wszFriendlyName); dwErr = IfutlGetFriendlyNameFromIfIndex( hMibServer, inmeRow->dwIndex, wszFriendlyName, BufLen);//in bytes. not chars DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_NET_HDR); DisplayMessageToConsole(g_hModule, g_hConsole,MSG_MIB_IP_NET_ENTRY, wszFriendlyName, tszPhysAddr, tszIpAddr, ptszType); FreeString(ptszType); }
27.203008
99
0.501086
[ "object" ]
6edd038470db3ad40e19c67dd95082a03144d3a9
2,539
h
C
src/turtlebot2_src/src/orocos-bayesian-filtering/orocos_bfl/examples/mobile_robot.h
alexoterno/turtlebot2_with_head
ac714f77379dd0f47ddb76d83896fdabee269a03
[ "MIT" ]
null
null
null
src/turtlebot2_src/src/orocos-bayesian-filtering/orocos_bfl/examples/mobile_robot.h
alexoterno/turtlebot2_with_head
ac714f77379dd0f47ddb76d83896fdabee269a03
[ "MIT" ]
null
null
null
src/turtlebot2_src/src/orocos-bayesian-filtering/orocos_bfl/examples/mobile_robot.h
alexoterno/turtlebot2_with_head
ac714f77379dd0f47ddb76d83896fdabee269a03
[ "MIT" ]
null
null
null
// $Id: mobile_robot.h tdelaet $ // Copyright (C) 2006 Tinne De Laet <first dot last at mech dot kuleuven dot be> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // #ifndef MOBILE_ROBOT_HPP #define MOBILE_ROBOT_HPP #include <model/analyticsystemmodel_gaussianuncertainty.h> #include <model/linearanalyticmeasurementmodel_gaussianuncertainty.h> #include <pdf/gaussian.h> #include <wrappers/matrix/matrix_wrapper.h> #include <wrappers/matrix/vector_wrapper.h> #include "mobile_robot_wall_cts.h" #include "nonlinearanalyticconditionalgaussianmobile.h" namespace BFL{ /// This is a class simulating a mobile robot /** The state of the mobile robot is represented with a ColumnVector of three * elements: the x and y position and the orientation. * The inputs of the robot are the linear velocity and the angular velocity. * The mobile robot is equipped with a ultrasonic sensor returning the distance * to a wall. * The initial position of the mobile robot is read from mobile_robot_wall_cts.h * During construction time the measurement model and system model are * constructed and their properties are read from mobile_robot_wall_cts.h */ class MobileRobot { public: // Constructor MobileRobot(); ~MobileRobot(); void Move(MatrixWrapper::ColumnVector inputs); const MatrixWrapper::ColumnVector Measure(); const MatrixWrapper::ColumnVector GetState(); //method only for simulation purposes private: Gaussian* _system_Uncertainty; NonLinearAnalyticConditionalGaussianMobile* _sys_pdf; AnalyticSystemModelGaussianUncertainty* _sys_model; Gaussian* _measurement_Uncertainty; LinearAnalyticConditionalGaussian* _meas_pdf; LinearAnalyticMeasurementModelGaussianUncertainty* _meas_model; MatrixWrapper::ColumnVector _state; }; } #endif
36.271429
89
0.76408
[ "model" ]
6ee55110eda6385a45b5b1925b2170c0f34acac7
907
c
C
SingleSource/UnitTests/Vector/Altivec/lvsl.c
gmlueck/llvm-test-suite
7ff842b8fec970561fed78c9347e496538cf74f5
[ "Apache-2.0" ]
70
2019-01-15T03:03:55.000Z
2022-03-28T02:16:13.000Z
SingleSource/UnitTests/Vector/Altivec/lvsl.c
gmlueck/llvm-test-suite
7ff842b8fec970561fed78c9347e496538cf74f5
[ "Apache-2.0" ]
519
2020-09-15T07:40:51.000Z
2022-03-31T20:51:15.000Z
SingleSource/UnitTests/Vector/Altivec/lvsl.c
gmlueck/llvm-test-suite
7ff842b8fec970561fed78c9347e496538cf74f5
[ "Apache-2.0" ]
117
2020-06-24T13:11:04.000Z
2022-03-23T15:44:23.000Z
#include "harness.h" __attribute__((__aligned__(16))) signed char sc[64]; __attribute__((__aligned__(16))) unsigned char uc[64]; __attribute__((__aligned__(16))) signed short ss[32]; __attribute__((__aligned__(16))) unsigned short us[32]; __attribute__((__aligned__(16))) signed int si[16]; __attribute__((__aligned__(16))) unsigned int ui[16]; __attribute__((__aligned__(16))) float f[16]; static void test() { vector unsigned char expected = {4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; check (vec_all_eq(vec_lvsl(0, &sc[4]), expected), "sc"); check (vec_all_eq(vec_lvsl(0, &uc[4]), expected), "uc"); check (vec_all_eq(vec_lvsl(0, &ss[2]), expected), "ss"); check (vec_all_eq(vec_lvsl(0, &us[2]), expected), "us"); check (vec_all_eq(vec_lvsl(0, &si[1]), expected), "si"); check (vec_all_eq(vec_lvsl(0, &ui[1]), expected), "ui"); check (vec_all_eq(vec_lvsl(0, & f[1]), expected), "f"); }
43.190476
78
0.681367
[ "vector" ]
6eeaff0d5b58f6bcf4110daa9a628110e2b6d245
3,418
c
C
Control_Files/infrared_obstacle_avoidance.c
LeoZ123/remote-control-car
44265fb5e57f99ea3f94f49478a441e0097bd49b
[ "MIT" ]
null
null
null
Control_Files/infrared_obstacle_avoidance.c
LeoZ123/remote-control-car
44265fb5e57f99ea3f94f49478a441e0097bd49b
[ "MIT" ]
null
null
null
Control_Files/infrared_obstacle_avoidance.c
LeoZ123/remote-control-car
44265fb5e57f99ea3f94f49478a441e0097bd49b
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <softPwm.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <netdb.h> #include <sys/types.h> #include <time.h> #include <sys/socket.h> #include <arpa/inet.h> #include <wiringPi.h> //define io #define Trig 28 #define Echo 29 #define LEFT 11 #define RIGHT 10 #define BUFSIZE 512 //define motor motion instruction #define MOTOR_GO_FORWARD digitalWrite(1,HIGH);digitalWrite(4,LOW);digitalWrite(5,HIGH);digitalWrite(6,LOW) #define MOTOR_GO_BACK digitalWrite(4,HIGH);digitalWrite(1,LOW);digitalWrite(6,HIGH);digitalWrite(5,LOW) #define MOTOR_GO_RIGHT digitalWrite(1,HIGH);digitalWrite(4,LOW);digitalWrite(6,HIGH);digitalWrite(5,LOW) #define MOTOR_GO_LEFT digitalWrite(4,HIGH);digitalWrite(1,LOW);digitalWrite(5,HIGH);digitalWrite(6,LOW) #define MOTOR_GO_STOP digitalWrite(1, LOW);digitalWrite(4,LOW);digitalWrite(5, LOW);digitalWrite(6,LOW) // go instruction void run() { softPwmWrite(4,0); //left wheel go forward softPwmWrite(1,250); softPwmWrite(6,0); //right wheel go forward softPwmWrite(5,250); } // stop instruction void brake(int time) { softPwmWrite(1,0); //left wheel stop softPwmWrite(4,0); softPwmWrite(5,0); //right wheel stop softPwmWrite(6,0); delay(time * 100); //set delay time to execute next instruciton } //left turn instruction void left() { softPwmWrite(4,250); //left wheel turn left softPwmWrite(1,0); softPwmWrite(6,0); //right wheel turn left softPwmWrite(5,250); //delay(time * 300); //set delay time to execute next instruciton } //right turn instruction void right() { softPwmWrite(4,0); //left wheel turn right softPwmWrite(1,250); softPwmWrite(6,250); //right wheel turn right softPwmWrite(5,0); //delay(time * 300); //set delay time to execute next instruciton } //back turn instruction void back() { softPwmWrite(4,250); //left wheel back softPwmWrite(1,0); softPwmWrite(6,250); //left wheel back softPwmWrite(5,0); //delay(time *200); //set delay time to execute next instruciton } int main(int argc, char *argv[]) { float dis; // char buf[BUFSIZE]={0xff,0x00,0x00,0x00,0xff}; int SR; int SL; /*RPI*/ wiringPiSetup(); /*WiringPi GPIO*/ pinMode (1, OUTPUT); //IN1 pinMode (4, OUTPUT); //IN2 pinMode (5, OUTPUT); //IN3 pinMode (6, OUTPUT); //IN4 // pinMode (27, OUTPUT); // softPwmCreate(1,1,500); softPwmCreate(4,1,500); softPwmCreate(5,1,500); softPwmCreate(6,1,500); // softPwmCreate(27,1,50); //softPwmWrite(27,1); while(1) { //having signal: set to LOW, no signal: set to HIGH SR = digitalRead(RIGHT); SL = digitalRead(LEFT); if (SL == LOW && SR==LOW){ printf("BACK"); //if both sensors find object back(); //execute BACK instruction delay(300); //delay 300mss left(); //execute delay(601); } else if (SL == HIGH && SR == LOW){ printf("RIGHT"); //if right sensor find object left(); //turn left } else if (SR == HIGH&&SL == LOW) { printf("LEFT"); //if left sensor find object right (); //turn right } else { printf("GO"); //else: no sensor find object run(); //keep going } } return 0; }
25.132353
109
0.62639
[ "object" ]
3e0f3cc6b59de126c6f5009f710729a1df2df579
4,408
h
C
src/postprocessing.h
SFCMM/LBM
99bf39e177cb0af94d4073ee9f9aef2e52ba7851
[ "BSD-3-Clause" ]
null
null
null
src/postprocessing.h
SFCMM/LBM
99bf39e177cb0af94d4073ee9f9aef2e52ba7851
[ "BSD-3-Clause" ]
null
null
null
src/postprocessing.h
SFCMM/LBM
99bf39e177cb0af94d4073ee9f9aef2e52ba7851
[ "BSD-3-Clause" ]
null
null
null
#ifndef LBM_LBM_POSTPROCESSING_H #define LBM_POSTPROCESSING_H #include <lbm/lbm_postprocessing.h> #include <utility> #include "common/configuration.h" #include "postprocessing_func.h" namespace pp { enum class HOOK { ATSTART, BEFORETIMESTEP, AFTERTIMESTEP, ATEND, NUM }; inline auto getHook(const GString& hookStr) -> HOOK { if(hookStr == "atStart") { return HOOK::ATSTART; } if(hookStr == "beforeTimestep") { return HOOK::BEFORETIMESTEP; } if(hookStr == "afterTimestep") { return HOOK::AFTERTIMESTEP; } if(hookStr == "atEnd") { return HOOK::ATEND; } TERMM(-1, "Invalid hook"); } inline auto getHook(const HOOK hook) -> GString { if(hook == HOOK::ATSTART) { return "atStart"; } if(hook == HOOK::BEFORETIMESTEP) { return "beforeTimestep"; } if(hook == HOOK::AFTERTIMESTEP) { return "afterTimestep"; } if(hook == HOOK::ATEND) { return "atEnd"; } TERMM(-1, "Invalid hook"); } } // namespace pp template <Debug_Level DEBUG_LEVEL, GInt NDIM, SolverType SOLVT, class SOLV> class Postprocess { public: Postprocess() = default; void init() { if(!m_postprocessing) { // nothing to do not active return; } if(SOLVT == SolverType::LBM) { for(const auto& obj : m_conf->getAllObjects()) { const auto typeId = m_conf->required_config_value<GString>(obj, "type"); const auto exeAt = m_conf->required_config_value<GString>(obj, "execute"); const pp::FuncType ppType = pp::getFuncType(typeId); const GInt atHook = static_cast<GInt>(pp::getHook(exeAt)); logger << "PP: Adding postprocessing function " << typeId << " for LBM solver at hook" << exeAt << std::endl; switch(ppType) { case pp::FuncType::LINE: m_postProcessFunc[atHook].emplace_back( std::make_unique<LBMPostprocessFunctionLine<NDIM>>(m_conf->getObject(obj), solver()->getCartesianGridData())); break; default: TERMM(-1, "Invalid postprocessing function type"); } } } else { TERMM(-1, "Invalid solver type"); } } void setConfAccessor(std::shared_ptr<ConfigurationAccess> ppConf) { m_conf = std::move(ppConf); if(m_conf != nullptr) { logger << "Postprocessing is ACTIVE" << std::endl; m_postprocessing = true; } } void executePostprocess(const pp::HOOK hook) { RECORD_TIMER_START(TimeKeeper[Timers::LBMPost]); if(m_postprocessing) { const GInt ppHookId = static_cast<GInt>(hook); if(!m_postProcessFunc.at(ppHookId).empty()) { // todo: this will produce to much output logger << "Executing postprocessing at hook:" << pp::getHook(hook) << std::endl; cerr0 << "Executing postprocessing at hook:" << pp::getHook(hook) << std::endl; for(const auto& func : m_postProcessFunc.at(ppHookId)) { func->execute(); } // todo: we output directly this needs to be settable... // todo: move output writing some where else... for(const auto& func : m_postProcessFunc.at(ppHookId)) { const auto& tmp = func->output(); std::vector<VectorD<NDIM>> tmp_coords; std::vector<IOIndex> tmp_index; std::vector<std::vector<GString>> tmp_values; std::vector<GDouble> tmp_vec; tmp_index.emplace_back(IOIndex{"u", "float"}); for(const GInt cellId : tmp) { tmp_coords.emplace_back(solver()->center(cellId)); tmp_vec.emplace_back(solver()->velocity(cellId, 0)); } tmp_values.emplace_back(toStringVector(tmp_vec, tmp_vec.size())); ASCII::writePointsCSV<NDIM>("line", tmp.size(), tmp_coords, tmp_index, tmp_values); } } } RECORD_TIMER_STOP(TimeKeeper[Timers::LBMPost]); } private: inline auto solver() -> SOLV* { return static_cast<SOLV*>(this); } std::array<std::vector<std::unique_ptr<PostprocessFunctionInterface<NDIM>>>, static_cast<GInt>(pp::HOOK::NUM)> m_postProcessFunc; GBool m_postprocessing = false; std::shared_ptr<ConfigurationAccess> m_conf = nullptr; }; #endif // LBM_LBM_POSTPROCESSING_H
34.170543
140
0.601633
[ "vector" ]
3e120476585a97620065492c0b4eebd2ad7af85a
1,752
h
C
AdditionalElements/elements.support.mail/EDCommon.framework/Versions/A/Headers/NSSet+Extensions.h
makotoy/quicksilver-my
d7c77e2bcd1c38acbd48a56bf7e36955a52fd188
[ "Apache-2.0" ]
1
2015-10-03T10:22:18.000Z
2015-10-03T10:22:18.000Z
AdditionalElements/elements.support.mail/EDCommon.framework/Versions/A/Headers/NSSet+Extensions.h
makotoy/quicksilver-my
d7c77e2bcd1c38acbd48a56bf7e36955a52fd188
[ "Apache-2.0" ]
null
null
null
AdditionalElements/elements.support.mail/EDCommon.framework/Versions/A/Headers/NSSet+Extensions.h
makotoy/quicksilver-my
d7c77e2bcd1c38acbd48a56bf7e36955a52fd188
[ "Apache-2.0" ]
null
null
null
//--------------------------------------------------------------------------------------- // NSSet+Extensions.h created by erik on Sat 10-Mar-2001 // $Id: NSSet+Extensions.h,v 2.0 2002-08-16 18:12:49 erik Exp $ // // Copyright (c) 2000 by Erik Doernenburg. All rights reserved. // // Permission to use, copy, modify and distribute this software and its documentation // is hereby granted, provided that both the copyright notice and this permission // notice appear in all copies of the software, derivative works or modified versions, // and any portions thereof, and that both notices appear in supporting documentation, // and that credit is given to Erik Doernenburg in all documents and publicity // pertaining to direct or indirect use of this code or its derivatives. // // THIS IS EXPERIMENTAL SOFTWARE AND IT IS KNOWN TO HAVE BUGS, SOME OF WHICH MAY HAVE // SERIOUS CONSEQUENCES. THE COPYRIGHT HOLDER ALLOWS FREE USE OF THIS SOFTWARE IN ITS // "AS IS" CONDITION. THE COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY // DAMAGES WHATSOEVER RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE // OR OF ANY DERIVATIVE WORK. //--------------------------------------------------------------------------------------- #import <Foundation/NSScanner.h> /*" Various common extensions to #NSSet. "*/ @interface NSSet(EDExtensions) /*" Adding objects "*/ - (NSSet *)setByAddingObjectsFromSet:(NSSet *)otherSet; - (NSSet *)setByAddingObjectsFromArray:(NSArray *)anArray; /*" Mapping the set "*/ - (NSSet *)setByMappingWithDictionary:(NSDictionary *)mapping; - (NSSet *)setByMappingWithSelector:(SEL)selector; // similar to valueForKey: - (NSSet *)setByMappingWithSelector:(SEL)selector withObject:(id)object; @end
47.351351
89
0.678082
[ "object" ]
3e18962b83a837c193a47402b163359d1b86540d
2,114
h
C
Xngine/ModuleCamera.h
FrancPS/Xngine
3eb031eb43a8c7fcfea0638f19347797783633b2
[ "MIT" ]
null
null
null
Xngine/ModuleCamera.h
FrancPS/Xngine
3eb031eb43a8c7fcfea0638f19347797783633b2
[ "MIT" ]
null
null
null
Xngine/ModuleCamera.h
FrancPS/Xngine
3eb031eb43a8c7fcfea0638f19347797783633b2
[ "MIT" ]
null
null
null
#ifndef __ModuleCamera_H__ #define __ModuleCamera_H__ #include "Globals.h" #include "Module.h" #include "Geometry/Frustum.h" #include "Math/float4x4.h" class ModuleCamera : public Module { public: Frustum frustum = Frustum::Frustum(); private: float4x4 projectionMatrix = float4x4::identity; // Projection Matrix float4x4 viewMatrix = float4x4::identity; // View Matrix float mTicks = 0; unsigned int mTicksCount = 0; // Tick counter for deltaTime float deltaTime = 0; public: ModuleCamera(); ~ModuleCamera(); // ----------- Module Functions ---------- // bool Init(); update_status PreUpdate(); update_status Update(); update_status PostUpdate(); bool CleanUp(); void ReceiveEvent(const Event& event); // ---------- Getters & Setters ---------- // float4x4 GetProjectionMatrix() const { return this->projectionMatrix; }; float4x4 GetViewMatrix() const { return this->viewMatrix; }; vec GetPosition() const { return frustum.Pos(); } vec GetOrientation() const { return frustum.Front(); } void SetPosition(const float _x, const float _y, const float _z) { frustum.SetPos(float3::float3(_x, _y, _z)); } void SetPlaneDistances(const float _zNear, const float _zFar) { frustum.SetViewPlaneDistances(_zNear, _zFar); } void SetFOV(const unsigned int width, const unsigned int height); // set the horizontal FOV keeping the aspect ratio //void SetAspectRatio(); // change the vertical FOV to meet the new aspect ratio. // ------------ Module Camera ------------ // void LookAt(const int _x, const int _y, const int _z); private: // ---------- Camera Traslations --------- // void MoveFrontAxis(const float _speed); void MoveRightAxis(const float _speed); void MoveUpAxis(const float _speed); void MoveYAxisUnit(const int upOrDown); // Yaws in the absolute Y axis, its less disorienting // ----------- Camera Rotations ---------- // void Pitch(const float _speed); void Yaw(const float _speed); void Orbit(const float _speedFront, const float _speedUp, const float3 focusPos); void Focus(); }; #endif // __ModuleCamera_H__
32.030303
118
0.685904
[ "geometry" ]
20407ea6c44adece952f2a3a0170c5ed3724028e
470
h
C
panda/src/gsgbase/config_gsgbase.h
cmarshall108/panda3d-python3
8bea2c0c120b03ec1c9fd179701fdeb7510bb97b
[ "PHP-3.0", "PHP-3.01" ]
3
2020-01-02T08:43:36.000Z
2020-07-05T08:59:02.000Z
panda/src/gsgbase/config_gsgbase.h
cmarshall108/panda3d-python3
8bea2c0c120b03ec1c9fd179701fdeb7510bb97b
[ "PHP-3.0", "PHP-3.01" ]
null
null
null
panda/src/gsgbase/config_gsgbase.h
cmarshall108/panda3d-python3
8bea2c0c120b03ec1c9fd179701fdeb7510bb97b
[ "PHP-3.0", "PHP-3.01" ]
1
2020-03-11T17:38:45.000Z
2020-03-11T17:38:45.000Z
/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * * All use of this software is subject to the terms of the revised BSD * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * * @file config_gsgbase.h * @author drose * @date 1999-10-06 */ #ifndef CONFIG_GSGBASE_H #define CONFIG_GSGBASE_H // No config variables to define yet for this package. #endif
23.5
70
0.725532
[ "3d" ]
20465a8b157ab2fdd706097d2713fda0b5713cea
18,836
c
C
components/fs/source/vfs_fs.c
shangliyun/lu_xing_xiang_one_os
02b3900bbc2303291ad6b16d59f50df786af4e27
[ "Apache-2.0" ]
2
2021-10-05T02:34:18.000Z
2022-01-18T15:22:41.000Z
components/fs/source/vfs_fs.c
shangliyun/lu_xing_xiang_one_os
02b3900bbc2303291ad6b16d59f50df786af4e27
[ "Apache-2.0" ]
1
2021-06-24T04:27:40.000Z
2021-06-24T04:27:40.000Z
components/fs/source/vfs_fs.c
shangliyun/lu_xing_xiang_one_os
02b3900bbc2303291ad6b16d59f50df786af4e27
[ "Apache-2.0" ]
2
2021-10-05T02:28:50.000Z
2022-03-23T06:39:39.000Z
/** *********************************************************************************************************************** * Copyright (c) 2020, China Mobile Communications Group Co.,Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * @file vfs_fs.c * * @brief This file implement the filesystem related APIs of vfs. * * @revision * Date Author Notes * 2020-03-10 OneOS Team First Version *********************************************************************************************************************** */ #include <vfs_fs.h> #include <vfs_file.h> #include "vfs_private.h" /** *********************************************************************************************************************** * @def VFS_FS_TAG * * @brief Define the log tag for vfs. *********************************************************************************************************************** */ #define VFS_FS_TAG "VFS_FS" /** *********************************************************************************************************************** * @brief This function register a new file system instance to vfs. * * @param[in] ops Filesystem ops of the new file system instance. * * @return Return 0 on successful, -1 on failed. *********************************************************************************************************************** */ int vfs_register(const struct vfs_filesystem_ops *ops) { int ret = 0; const struct vfs_filesystem_ops **empty = NULL; const struct vfs_filesystem_ops **iter; /* Lock filesystem */ vfs_lock(); /* Check if this filesystem was already registered */ for (iter = &filesystem_operation_table[0]; iter < &filesystem_operation_table[VFS_FILESYSTEM_TYPES_MAX]; iter ++) { /* Find out an empty filesystem type entry */ if (*iter == NULL) { (empty == NULL) ? (empty = iter) : 0; } else if (strcmp((*iter)->name, ops->name) == 0) { os_set_errno(-EEXIST); ret = -1; LOG_E(VFS_FS_TAG, "Filesystem %s was already registered.", ops->name); break; } } /* Save the filesystem's operations */ if (empty == NULL) { os_set_errno(-ENOSPC); LOG_E(VFS_FS_TAG, "There is no space to register this file system (%s).", ops->name); ret = -1; } else if (ret == 0) { *empty = ops; LOG_I(VFS_FS_TAG, "Register filesystem %s", ops->name); } vfs_unlock(); return ret; } /** *********************************************************************************************************************** * @brief This function return the file system mounted on the specified path. * * @param[in] path The specified path. * * @return Return the found file system, or NULL if no match was found. *********************************************************************************************************************** */ struct vfs_filesystem *vfs_filesystem_lookup(const char *path) { struct vfs_filesystem *iter; struct vfs_filesystem *fs = NULL; uint32_t fspath; uint32_t prefixlen; prefixlen = 0; OS_ASSERT(path); /* Lock filesystem */ vfs_lock(); /* Lookup it in the filesystem table */ for (iter = &filesystem_table[0]; iter < &filesystem_table[VFS_FILESYSTEMS_MAX]; iter++) { if ((iter->path == NULL) || (iter->ops == NULL)) { continue; } fspath = strlen(iter->path); if ((fspath < prefixlen) || (strncmp(iter->path, path, fspath) != 0)) { continue; } /* Check next path separator */ if (fspath > 1 && (strlen(path) > fspath) && (path[fspath] != '/')) { continue; } fs = iter; prefixlen = fspath; } vfs_unlock(); return fs; } /** *********************************************************************************************************************** * @brief This function will return the mounted path for specified device. * * @param[in] device The device object which is mounted. * * @return Return the mounted path or NULL if none device mounted. *********************************************************************************************************************** */ const char *vfs_filesystem_get_mounted_path(struct os_device *device) { const char *path = NULL; struct vfs_filesystem *iter; /* If no device is specified, return NULL. */ if(!device) { return NULL; } vfs_lock(); for (iter = &filesystem_table[0]; iter < &filesystem_table[VFS_FILESYSTEMS_MAX]; iter++) { if (iter->ops == NULL) { continue; } else if (iter->dev_id == device) { path = iter->path; break; } } /* Release filesystem_table lock */ vfs_unlock(); return path; } /** *********************************************************************************************************************** * @brief This function will fetch the partition table on specified buffer. * * @param[out] part The returned partition structure. * @param[in] buf The buffer contains partition table. * @param[in] pindex The index of partition table to fetch. * * @return OS_EOK on successful or -OS_ERROR on failed. *********************************************************************************************************************** */ int vfs_filesystem_get_partition(struct vfs_partition *part, uint8_t *buf, uint32_t pindex) { #define DPT_ADDRESS 0x1be /* device partition offset in Boot Sector */ #define DPT_ITEM_SIZE 16 /* partition item size */ uint8_t *dpt; uint8_t type; OS_ASSERT(part != NULL); OS_ASSERT(buf != NULL); dpt = buf + DPT_ADDRESS + pindex * DPT_ITEM_SIZE; /* Check if it is a valid partition table */ if ((*dpt != 0x80) && (*dpt != 0x00)) { return OS_EIO; } /* Get partition type */ type = *(dpt + 4); if (type == 0) { return OS_EIO; } /* Set partition information, size is the number of 512-Byte */ part->type = type; part->offset = *(dpt + 8) | *(dpt + 9) << 8 | *(dpt + 10) << 16 | *(dpt + 11) << 24; part->size = *(dpt + 12) | *(dpt + 13) << 8 | *(dpt + 14) << 16 | *(dpt + 15) << 24; os_kprintf("found part[%d], begin: %d, size: ", pindex, part->offset * 512); if ((part->size >> 11) == 0) { os_kprintf("%d%s", part->size >> 1, "KB\n"); /* KB */ } else { unsigned int part_size; part_size = part->size >> 11; /* MB */ if ((part_size >> 10) == 0) { os_kprintf("%d.%d%s", part_size, (part->size >> 1) & 0x3FF, "MB\n"); } else { os_kprintf("%d.%d%s", part_size >> 10, part_size & 0x3FF, "GB\n"); } } return OS_EOK; } /** *********************************************************************************************************************** * @brief This function will mount a file system on a specified path. * * @param[in] device_name The name of device to be mounted, which includes a file system * @param[in] path The path of mount point. * @param[in] filesystemtype The file system type to use. * @param[in] rwflag The supported access mode, read/write etc. flag. * @param[in] data The private data(parameter) for this file system. * * @return Return 0 on successful, -1 on failed. *********************************************************************************************************************** */ int vfs_mount(const char *device_name, const char *path, const char *filesystemtype, unsigned long rwflag, const void *data) { const struct vfs_filesystem_ops **ops; struct vfs_filesystem *iter; struct vfs_filesystem *fs = NULL; char *fullpath = NULL; os_device_t *dev_id; /* Open specific device */ if (device_name == NULL) { /* Which is a non-device filesystem mount */ dev_id = NULL; } else if ((dev_id = os_device_find(device_name)) == NULL) { os_set_errno(-ENODEV); return -1; } /* Find out the specific filesystem */ vfs_lock(); for (ops = &filesystem_operation_table[0]; ops < &filesystem_operation_table[VFS_FILESYSTEM_TYPES_MAX]; ops++) { if ((*ops != NULL) && (strcmp((*ops)->name, filesystemtype) == 0)) { break; } } vfs_unlock(); if (ops == &filesystem_operation_table[VFS_FILESYSTEM_TYPES_MAX]) { os_set_errno(-ENODEV); return -1; } /* Check if there is mount implementation */ if ((*ops == NULL) || ((*ops)->mount == NULL)) { os_set_errno(-ENOSYS); return -1; } /* Make full path for special file */ fullpath = vfs_normalize_path(NULL, path); if (fullpath == NULL) /* not an abstract path */ { os_set_errno(-ENOTDIR); return -1; } /* Check if the path exists or not, raw APIs call, fixme */ if ((strcmp(fullpath, "/") != 0) && (strcmp(fullpath, "/dev") != 0)) { struct vfs_fd fd; if (vfs_file_open(&fd, fullpath, O_RDONLY | O_DIRECTORY) < 0) { os_free(fullpath); os_set_errno(-ENOTDIR); return -1; } vfs_file_close(&fd); } /* Check whether the file system mounted or not in the filesystem table * if it is unmounted yet, find out an empty entry */ vfs_lock(); for (iter = &filesystem_table[0]; iter < &filesystem_table[VFS_FILESYSTEMS_MAX]; iter++) { /* Check if it is an empty filesystem table entry? if it is, save fs */ if (iter->ops == NULL) { (fs == NULL) ? (fs = iter) : 0; } /* Check if the PATH is mounted */ else if (strcmp(iter->path, path) == 0) { os_set_errno(-EINVAL); goto err1; } } if ((fs == NULL) && (iter == &filesystem_table[VFS_FILESYSTEMS_MAX])) { os_set_errno(-ENOSPC); LOG_E(VFS_FS_TAG, "There is no space to mount this file system (%s).", filesystemtype); goto err1; } /* Register file system */ fs->path = fullpath; fs->ops = *ops; fs->dev_id = dev_id; vfs_unlock(); /* Open device, but do not check the status of device */ if (dev_id != NULL) { if (os_device_open(fs->dev_id, OS_DEVICE_OFLAG_RDWR) != OS_EOK) { /* The underlaying device has error, clear the entry. */ vfs_lock(); memset(fs, 0, sizeof(struct vfs_filesystem)); goto err1; } } /* Call mount of this filesystem */ if ((*ops)->mount(fs, rwflag, data) < 0) { if (dev_id != NULL) { os_device_close(fs->dev_id); } /* Mount failed */ vfs_lock(); /* Clear filesystem table entry */ memset(fs, 0, sizeof(struct vfs_filesystem)); goto err1; } LOG_I(VFS_FS_TAG, "Mount %s to %s", filesystemtype, path); return 0; err1: vfs_unlock(); os_free(fullpath); return -1; } /** *********************************************************************************************************************** * @brief This function will unmount the file system on a specified path. * * @param[in] specialfile The specified path which mounted a file system. * * @return Return 0 on successful or -1 on failed. *********************************************************************************************************************** */ int vfs_unmount(const char *specialfile) { char *fullpath; struct vfs_filesystem *iter; struct vfs_filesystem *fs = NULL; fullpath = vfs_normalize_path(NULL, specialfile); if (fullpath == NULL) { os_set_errno(-ENOTDIR); return -1; } /* Lock filesystem */ vfs_lock(); for (iter = &filesystem_table[0]; iter < &filesystem_table[VFS_FILESYSTEMS_MAX]; iter++) { /* Check if the PATH is mounted */ if ((iter->path != NULL) && (strcmp(iter->path, fullpath) == 0)) { fs = iter; break; } } if (fs == NULL || fs->ops->unmount == NULL || fs->ops->unmount(fs) < 0) { goto err1; } /* Close device, but do not check the status of device */ if (fs->dev_id != NULL) os_device_close(fs->dev_id); if (fs->path != NULL) os_free(fs->path); /* Clear this filesystem table entry */ memset(fs, 0, sizeof(struct vfs_filesystem)); vfs_unlock(); os_free(fullpath); return 0; err1: vfs_unlock(); os_free(fullpath); return -1; } /** *********************************************************************************************************************** * @brief This function will format specified device into specified file system. * * @param[in] fs_name The file system name. * @param[in] device_name The device name. * * @return Return 0 on successful or -1 on failed. *********************************************************************************************************************** */ int vfs_mkfs(const char *fs_name, const char *device_name) { int index; os_device_t *dev_id = NULL; /* Check device name, and it should not be NULL */ if (device_name != NULL) { dev_id = os_device_find(device_name); } if (dev_id == NULL) { os_set_errno(-ENODEV); LOG_E(VFS_FS_TAG, "Device (%s) was not found", device_name); return -1; } vfs_lock(); /* Find the file system operations */ for (index = 0; index < VFS_FILESYSTEM_TYPES_MAX; index ++) { if (filesystem_operation_table[index] != NULL && strcmp(filesystem_operation_table[index]->name, fs_name) == 0) { break; } } vfs_unlock(); if (index < VFS_FILESYSTEM_TYPES_MAX) { /* Find file system operation */ const struct vfs_filesystem_ops *ops = filesystem_operation_table[index]; if (ops->mkfs == NULL) { LOG_E(VFS_FS_TAG, "The file system (%s) mkfs function was not implement", fs_name); os_set_errno(-ENOSYS); return -1; } return ops->mkfs(dev_id); } LOG_E(VFS_FS_TAG, "File system (%s) was not found.", fs_name); return -1; } /** *********************************************************************************************************************** * @brief This function will return the information about the mounted file system on specified path. * * @param[in] path The path on which the file system is mounted. * @param[out] buffer The buffer to save the returned information. * * @return Return 0 on successful or -1 on failed. *********************************************************************************************************************** */ int vfs_statfs(const char *path, struct statfs *buffer) { struct vfs_filesystem *fs; char *fullpath; fullpath = vfs_normalize_path(NULL, path); if (fullpath == NULL) { return -1; } fs = vfs_filesystem_lookup(fullpath); if (fs != NULL) { struct vfs_fd fd; int result; /* Check if path is valid */ result = vfs_file_open( &fd, fullpath, O_RDONLY); if(result < 0) { result = vfs_file_open( &fd, fullpath, O_RDONLY | O_DIRECTORY); } os_free(fullpath); if(result < 0) { return -1; } if (result == 0) { vfs_file_close(&fd); } if (fs->ops->statfs != NULL) { return fs->ops->statfs(fs, buffer); } } else { os_free(fullpath); } return -1; } #ifdef OS_USING_SHELL #include <shell.h> void mkfs(const char *fs_name, const char *device_name) { vfs_mkfs(fs_name, device_name); } /** *********************************************************************************************************************** * @brief This function print out free space infomation of the file system mounted on specified path. * * @param[in] path The path on which the file system is mounted. * * @return Return 0 on successful or -1 on failed. *********************************************************************************************************************** */ int df(const char *path) { int result; int minor = 0; long long cap; struct statfs buffer; int unit_index = 0; char *unit_str[] = {"KB", "MB", "GB"}; if(!path) { return -1; } result = vfs_statfs(path, &buffer); if (result != 0) { os_kprintf("vfs_statfs failed.\r\n"); return -1; } cap = ((long long)buffer.f_bsize) * ((long long)buffer.f_bfree) / 1024LL; for (unit_index = 0; unit_index < 2; unit_index ++) { if (cap < 1024) { break; } minor = (cap % 1024) * 10 / 1024; /* Only one decimal point */ cap = cap / 1024; } os_kprintf("disk free: %d.%d %s [ %d block, %d bytes per block ]\r\n", (unsigned long)cap, minor, unit_str[unit_index], buffer.f_bfree, buffer.f_bsize); return 0; } #endif /* OS_USING_SHELL */
28.582701
120
0.47011
[ "object" ]
2049995de5e19f9b2d2b662dc305379757185112
5,135
h
C
src/c/symbol.h
felixr/shen-c
6a4483b26be69f81b1d88f9fc0e351921b271947
[ "MIT" ]
64
2017-04-18T05:14:56.000Z
2022-03-20T13:08:31.000Z
src/c/symbol.h
felixr/shen-c
6a4483b26be69f81b1d88f9fc0e351921b271947
[ "MIT" ]
3
2019-08-17T16:16:28.000Z
2022-01-02T19:58:12.000Z
src/c/symbol.h
felixr/shen-c
6a4483b26be69f81b1d88f9fc0e351921b271947
[ "MIT" ]
5
2017-04-24T23:16:40.000Z
2021-01-02T17:11:42.000Z
#ifndef SHEN_C_SYMBOL_H #define SHEN_C_SYMBOL_H #include <stdbool.h> #include <stdio.h> #include <string.h> #include "boolean.h" #include "exception.h" #include "kl.h" #include "string.h" extern unsigned long auto_increment_symbol_name_id; extern char* auto_increment_symbol_name_prefix; extern khash_t(SymbolTable)* symbol_table; inline KLObject* get_symbol_name (Symbol* symbol) { return symbol->name; } inline void set_symbol_name (Symbol* symbol, KLObject* string_object) { symbol->name = string_object; } inline KLObject* get_symbol_function (Symbol* symbol) { return symbol->function; } inline void set_symbol_function (Symbol* symbol, KLObject* function_object) { symbol->function = function_object; } inline KLObject* get_symbol_variable_value (Symbol* symbol) { return symbol->variable_value; } inline void set_symbol_variable_value (Symbol* symbol, KLObject* variable_value_object) { symbol->variable_value = variable_value_object; } inline Symbol* create_symbol (KLObject* string_object) { Symbol *symbol = malloc(sizeof(Symbol)); set_symbol_name(symbol, string_object); set_symbol_function(symbol, NULL); set_symbol_variable_value(symbol, NULL); return symbol; } inline Symbol* get_symbol (KLObject* symbol_object) { return symbol_object->value.symbol; } inline void set_symbol (KLObject* symbol_object, Symbol* symbol) { symbol_object->value.symbol = symbol; } inline KLObject* create_kl_symbol (KLObject* string_object) { KLObject* symbol_object = create_kl_object(KL_TYPE_SYMBOL); Symbol* symbol = create_symbol(string_object); set_symbol(symbol_object, symbol); return symbol_object; } inline KLObject* create_kl_symbol_by_name (char* symbol_name) { return create_kl_symbol(create_kl_string_with_intern(symbol_name)); } inline KLObject* get_kl_symbol_name (KLObject* symbol_object) { return get_symbol_name(get_symbol(symbol_object)); } inline void set_kl_symbol_name (KLObject* symbol_object, KLObject* string_object) { set_symbol_name(get_symbol(symbol_object), string_object); } inline KLObject* get_kl_symbol_function (KLObject* symbol_object) { return get_symbol_function(get_symbol(symbol_object)); } inline void set_kl_symbol_function (KLObject* symbol_object, KLObject* function_object) { set_symbol_function(get_symbol(symbol_object), function_object); } inline KLObject* get_kl_symbol_variable_value (KLObject* symbol_object) { return get_symbol_variable_value(get_symbol(symbol_object)); } inline void set_kl_symbol_variable_value (KLObject* symbol_object, KLObject* variable_value_object) { set_symbol_variable_value(get_symbol(symbol_object), variable_value_object); } inline bool is_kl_symbol (KLObject* object) { return get_kl_object_type(object) == KL_TYPE_SYMBOL; } inline bool is_symbol_equal (Symbol* left_symbol, Symbol* right_symbol) { return left_symbol == right_symbol; } inline bool is_kl_symbol_equal (KLObject* left_object, KLObject* right_object) { return left_object == right_object; } inline unsigned long get_auto_increment_symbol_name_id (void) { return auto_increment_symbol_name_id; } inline unsigned long pre_increment_auto_increment_symbol_name_id (void) { return ++auto_increment_symbol_name_id; } inline char* get_auto_increment_symbol_name_prefix (void) { return auto_increment_symbol_name_prefix; } inline char* create_auto_increment_symbol_name (void) { pre_increment_auto_increment_symbol_name_id(); int symbol_name_length = snprintf(NULL, 0, "%s%zu", get_auto_increment_symbol_name_prefix(), get_auto_increment_symbol_name_id()); char* symbol_name = malloc((size_t)symbol_name_length + 1); sprintf(symbol_name, "%s%zu", get_auto_increment_symbol_name_prefix(), get_auto_increment_symbol_name_id()); return symbol_name; } inline KLObject* create_auto_increment_kl_symbol (void) { return create_kl_symbol_by_name(create_auto_increment_symbol_name()); } inline khash_t(SymbolTable)* get_symbol_table (void) { return symbol_table; } inline void initialize_symbol_table (void) { symbol_table = kh_init(SymbolTable); } inline KLObject* lookup_symbol_table (KLObject* string_object) { khash_t(SymbolTable)* table = get_symbol_table(); khiter_t hash_iterator = kh_get(SymbolTable, table, (kl_khint_ptr_t)string_object); bool is_key_not_found = hash_iterator == kh_end(table); if (is_key_not_found || kh_exist(table, hash_iterator) == 0) return NULL; return kh_value(table, hash_iterator); } inline void extend_symbol_table (KLObject* string_object, KLObject* symbol_object) { khash_t(SymbolTable)* table = get_symbol_table(); int put_result; khiter_t hash_iterator = kh_put(SymbolTable, table, (kl_khint_ptr_t)string_object, &put_result); if (put_result == -1) throw_kl_exception("Failed to extend symbol name table"); kh_value(table, hash_iterator) = symbol_object; } #endif
25.295567
85
0.753262
[ "object" ]
205663aa0c565ce8fee2e5c778a432a89d8c9720
9,340
h
C
System/AutomotiveKernel/src/main/jni/VIALibs/SensingComponent/include/mobile360/CameraCoord/CameraModule.h
via-intelligent-vision/VIA-AI
9b981c8177c097d0ee347b37d45ed52290ecdba5
[ "MIT" ]
39
2019-09-28T07:07:56.000Z
2021-05-25T12:21:26.000Z
System/AutomotiveKernel/src/main/jni/VIALibs/SensingComponent/include/mobile360/CameraCoord/CameraModule.h
via-intelligent-vision/VIA-AI
9b981c8177c097d0ee347b37d45ed52290ecdba5
[ "MIT" ]
2
2019-09-30T16:24:31.000Z
2022-03-05T16:11:10.000Z
System/AutomotiveKernel/src/main/jni/VIALibs/SensingComponent/include/mobile360/CameraCoord/CameraModule.h
via-intelligent-vision/VIA-AI
9b981c8177c097d0ee347b37d45ed52290ecdba5
[ "MIT" ]
23
2019-09-28T08:24:17.000Z
2021-11-07T02:31:27.000Z
#ifndef CAMERA_MODULE_H #define CAMERA_MODULE_H // ------------------------------------------------------------------------------------------------ #include <vector> #include <mutex> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include "mobile360/adas-core/utils/configure.h" #include "mobile360/CameraCoord/CameraTypes.h" namespace via { namespace camera { enum class CameraLocationTypes : unsigned int { Location_Unknown = 0, Location_Front = 1, Location_Right = 2, Location_Left = 3, Location_Rear = 4, }; /** @brief Calibration pattern information PatternAnchors are normalized to [0.0f~1.0f], p0 is in the top-left anchor of pattern, and sort p0~p3 as clockwisw. p0 ----- p1 | | p3 ----- p2 */ struct CalibrationPatternData { cv::Size2f patternSize; // unit : cm cv::Point2f nPatternAnchorP0; cv::Point2f nPatternAnchorP1; cv::Point2f nPatternAnchorP2; cv::Point2f nPatternAnchorP3; float patternDistanceFromVehicle; // unit : cm }; /** @brief Configuration for camera module. */ class CameraConfigure : public AdasCvConfigure { public: static const CameraTypes DEFAULT_CAMERA_TYPE; CameraConfigure(); CameraConfigure(CameraTypes type, CameraLocationTypes location); virtual ~CameraConfigure(); /** @brief Load & save Configuration with tag <Camera> , <LDWS>, <FCWS>. */ virtual bool load(const std::string &instrinsicPath, const std::string extrinsicPath); virtual bool save(const std::string &exportFullPath); virtual bool save(cv::FileStorage &fs); bool LoadConfigure(const std::string &file); void copyTo(CameraConfigure &dst); /** @brief Build extrinsic or perspective. This function is called when load() fiinish automatically. If you use set functions below, you must call buildScene() manually when all set() finish. This step is used to correct the params of extrinsic & perspective , * setCameraType(), * setCalibrationPatternInfo(), * setCameraMatrix(), * setDistCoeff(), * setCameraMatrix() */ bool buildScene(); bool isExtrinsicEmpty(); bool isIntrinsicEmpty(); bool isFrameSizeMatching(cv::Size checkSize); CameraTypes getCameraType(); CameraLocationTypes getCameraLocation(); std::string getErrMsg() { return errMsg; }; cv::Size getFrameCalibrationSize(); cv::Size getFrameSize(); cv::Mat getCameraMatrix(); cv::Mat getDistCoeff(); cv::Mat getExtrinsic(); cv::Mat getRvec(); cv::Mat getTvec(); void getCalibrationPatternData(CalibrationPatternData &dstPattern); void setCameraType(CameraTypes type, CameraLocationTypes location = CameraLocationTypes::Location_Front, int calWidth = 0, int calHeight = 0, float *cameraMatrix_3x3f = NULL, float *distCoeff_5x1f = NULL); void setCalibrationPatternInfo(cv::Size2f patternSize, cv::Point2f normalizePatternAnchorP0, cv::Point2f normalizePatternAnchorP1, cv::Point2f normalizePatternAnchorP2, cv::Point2f normalizePatternAnchorP3, float patternDistanceFromVehicle); void setFrameSize(cv::Size frameSize); void setCameraMatrix(cv::Mat cameraMatrix_3x3f); void setDistCoeff(cv::Mat distCoeff_5x1f); void setExtrinsic(cv::Mat extrinsic_4x4d); void setRvec(cv::Mat rvec_3x1d); void setTvec(cv::Mat tvec_3x1d); protected: void reset(); /** @brief Solve extrinsic or perspective. */ bool solveExtrinsic(std::vector<cv::Point3f> &objectPoints, std::vector<cv::Point2f> &imagePoints); bool solvePerspective(std::vector<cv::Point3f> &objectPoints, std::vector<cv::Point2f> &imagePoints); void refreshExtrinsic(); // TODO: these element must move to AdasCvConfigure std::mutex cfgMutex; std::string errMsg; /** @brief Camera types. this type decide the intrinsic of camera. */ CameraTypes cameraType; CameraTypes configCameraType; CameraLocationTypes cameraLocation; std::string cameraName; /** @brief Intrinsic data */ cv::Size frameCalibrationSize; // frmae Size in calibration cv::Mat cameraMatrix; cv::Mat distCoeff; /** @brief Extrinsic data In CameraConfigure, no interface to calculate extrinsic except the extrinsic inside XML. If the runtime extrinsic calcuation is need, use CameraModule replaced. */ cv::Mat extrinsic; // 4x4 matrix(double) , constructed by rvec & tvec cv::Mat rvec_3x1d; cv::Mat rvec_3x3d; cv::Mat tvec_3x1d; /** @brief Pattern informations PatternAnchors are normalized to [0.0f~1.0f], p0 is in the top-left anchor of pattern, and sort p0~p3 as clockwisw. p0 ----- p1 | | p3 ----- p2 */ CalibrationPatternData caliPattern; /** @brief Perspective matrix In CameraConfigure, no interface to calculate perspective except the perspective matrix inside XML. If the runtime perspective calcuation is need, use CameraModule replaced. Even thought we could build camera module with Instrinsic/Extrinsic, the camera type from customers is difficult to predict. In 0-plane distance/width measurment, perspectvie matrix is a similar solution as Instrinsic/Extrinsic. But, If user need auto calibtation solution, Instrinsic/Extrinsic is needed. */ cv::Size frameSize; // Camera frmae size, may different to the frameCalibrationSize cv::Mat perspectiveMatrix; cv::Mat perspectiveInvMatrix; cv::Size2f unitCvt_PerspectivePixelToMeter; cv::Size2f unitCvt_MeterToPerspectivePixel; cv::Point2f vehiclePoleInCamera; cv::Point2f perspectiveVehicleHeadAnchor; private: bool loadIntrinsic(const std::string &instrinsicPath); bool loadExtrinsic(const std::string extrinsicPath); }; /** @brief The camera model of this class is based on openCV camera model. */ class CameraModule : public CameraConfigure { public: CameraModule(); CameraModule(CameraTypes type, CameraLocationTypes location = CameraLocationTypes::Location_Front); CameraModule(CameraTypes type, CameraLocationTypes location, std::string name, int caliWidth, int caliHeight, float *cameraMatrix_3x3f, float *distCoeff_5x1f); ~CameraModule(); void copyTo(CameraModule &dst); bool load(const std::string &instrinsicPath, const std::string extrinsicPath); /** @brief Refresh calibration pattern, replace by virtual pattern. Call this function after auto calibration, or set extrinsic/perspective manually. */ bool invokeVirtualPattern(); bool isExtrinsicStable(); /** @brief Check input frame size is equalized to current camera or not. @return true if size matching, otherwise return false. */ bool frameSizeCheck(cv::Size &size); // TODO : Convert function for Extrinsic to normalized coordinate // [Extrinsic only] Undistort image coordinate to undistortion coordinate. cv::Point2f coordCvt_ImgCoord_To_UndistCoord(double imgCoordx, double imgCoordy, cv::Mat *cutomCameraMatrix_3x3f); // [Extrinsic only] Reprojects image coordinate(2D) to object coordinate (3D, z=0). cv::Point3f coordCvt_ImgCoord_To_ObjCoord_ZeroZ(double imgCoordx, double imgCoordy); // [Extrinsic only] Reprojects image coordinate(2D) to object coordinate (3D, z=0). cv::Point3f coordCvt_NormalizedImgCoord_To_ObjCoord_ZeroZ(double imgCoordx, double imgCoordy); // [Extrinsic only] Reprojects unstortion coordinate(2D) to object coordinate (3D, z=0). cv::Point3f coordCvt_UndistCoord_To_ObjCoord_ZeroZ(double undistCoordx, double undistCoordy); // [Extrinsic only] Project object coordinate(3D) to an image coordinate (2D). cv::Point2f coordCvt_ObjCoord_To_NormalizedImgCoord(double objCoordx, double objCoordy, double objCoordz); // [Extrinsic only] Calculate the <vehicle - object> distance from image coordinate double coordCvt_NormalizedImgCoord_To_cmDistance(double nImgCoordx, double inIgCoordy); /** @brief [Perspective only] Calculate the <vehicle - object> distance from image coordinate Flag isNormalized is used to identify imgCoord is normalized to [0.0~1.0] or not. In general, using normalized coordinate as input is recommended to reduce coordinate sync problem of developer. */ double calcDistance(double imgCoordx, double imgCoordy, bool isNormalized = false); /** @brief [Perspective only] These 3 function is reserved interface for FCWS. Be sure to the coordinate of input line must match the frameSize coordinate. */ bool CheckLenInRange(const std::vector<cv::Point2f> &line, float lower, float upper); std::vector<cv::Point2f> TransLineToReal(std::vector<cv::Point2f> &line); std::vector<cv::Point2f> TransLine(std::vector<cv::Point2f> &line); void forceExtrinsicStable(bool isStable); private: bool b_isExtrinsicStable; bool isValid(); }; } // namespace camera } // namespace via // ------------------------------------------------------------------------------------------------ // CAMERA_MODULE_H #endif
38.916667
246
0.689507
[ "object", "vector", "model", "3d" ]
20607277dcccdf1b5efb71a12b1943490ae6342b
4,005
h
C
packrat/lib/x86_64-w64-mingw32/3.6.1/Rcpp/include/Rcpp/hash/SelfHash.h
Denia-Vargas-Araya/ApartamentosR
3e62de9946efb5b6545ce431972f5cc790dae673
[ "MIT" ]
113
2018-07-12T07:49:33.000Z
2021-04-16T12:41:53.000Z
packrat/lib/x86_64-w64-mingw32/3.6.1/Rcpp/include/Rcpp/hash/SelfHash.h
Denia-Vargas-Araya/ApartamentosR
3e62de9946efb5b6545ce431972f5cc790dae673
[ "MIT" ]
81
2018-03-01T18:05:41.000Z
2020-01-15T18:47:31.000Z
packrat/lib/x86_64-w64-mingw32/3.6.1/Rcpp/include/Rcpp/hash/SelfHash.h
Denia-Vargas-Araya/ApartamentosR
3e62de9946efb5b6545ce431972f5cc790dae673
[ "MIT" ]
55
2017-05-20T12:42:19.000Z
2019-03-26T16:38:16.000Z
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*- // // hash.h: Rcpp R/C++ interface class library -- hashing utility, inspired // from Simon's fastmatch package // // Copyright (C) 2010, 2011 Simon Urbanek // Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // // Rcpp 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. // // Rcpp 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 Rcpp. If not, see <http://www.gnu.org/licenses/>. #ifndef RCPP__HASH__SELF_HASH_H #define RCPP__HASH__SELF_HASH_H namespace Rcpp{ namespace sugar{ template <int RTYPE> class SelfHash { public: typedef typename traits::storage_type<RTYPE>::type STORAGE ; typedef Vector<RTYPE> VECTOR ; SelfHash( SEXP table ) : n(Rf_length(table)), m(2), k(1), src( (STORAGE*)dataptr(table) ), data(), indices(), size_(0) { int desired = n*2 ; while( m < desired ){ m *= 2 ; k++ ; } data.resize( m ) ; indices.resize( m ) ; } inline IntegerVector fill_and_self_match(){ IntegerVector result = no_init(n) ; int* res = INTEGER(result) ; for( int i=0; i<n; i++) res[i] = add_value_get_index(i) ; return result ; } inline int size() const { return size_ ; } int n, m, k ; STORAGE* src ; std::vector<int> data ; std::vector<int> indices ; int size_ ; int add_value_get_index(int i){ STORAGE val = src[i++] ; unsigned int addr = get_addr(val) ; while (data[addr] && src[data[addr] - 1] != val) { addr++; if (addr == static_cast<unsigned int>(m)) addr = 0; } if (!data[addr]) { data[addr] = i ; indices[addr] = ++size_ ; } return indices[addr] ; } /* NOTE: we are returning a 1-based index ! */ unsigned int get_index(STORAGE value) const { unsigned int addr = get_addr(value) ; while (data[addr]) { if (src[data[addr] - 1] == value) return data[addr]; addr++; if (addr == static_cast<unsigned int>(m)) addr = 0; } return NA_INTEGER; } // defined below unsigned int get_addr(STORAGE value) const ; } ; template <> inline unsigned int SelfHash<INTSXP>::get_addr(int value) const { return RCPP_HASH(value) ; } template <> inline unsigned int SelfHash<REALSXP>::get_addr(double val) const { unsigned int addr; union dint_u { double d; unsigned int u[2]; }; union dint_u val_u; /* double is a bit tricky - we nave to normalize 0.0, NA and NaN */ if (val == 0.0) val = 0.0; if (internal::Rcpp_IsNA(val)) val = NA_REAL; else if (internal::Rcpp_IsNaN(val)) val = R_NaN; val_u.d = val; addr = RCPP_HASH(val_u.u[0] + val_u.u[1]); return addr ; } template <> inline unsigned int SelfHash<STRSXP>::get_addr(SEXP value) const { intptr_t val = (intptr_t) value; unsigned int addr; #if (defined _LP64) || (defined __LP64__) || (defined WIN64) addr = RCPP_HASH((val & 0xffffffff) ^ (val >> 32)); #else addr = RCPP_HASH(val); #endif return addr ; } } // sugar } // Rcpp #endif
30.807692
74
0.5603
[ "vector" ]
2066605fc1271a0db2cd30da9f0795af1a43d4ea
903,951
c
C
graphbrain/parsers/alpha_beta.c
danielvasic/CroatianGraphBrain
01177c1441129792c8fbde3f75092bab6856af6f
[ "MIT" ]
null
null
null
graphbrain/parsers/alpha_beta.c
danielvasic/CroatianGraphBrain
01177c1441129792c8fbde3f75092bab6856af6f
[ "MIT" ]
null
null
null
graphbrain/parsers/alpha_beta.c
danielvasic/CroatianGraphBrain
01177c1441129792c8fbde3f75092bab6856af6f
[ "MIT" ]
null
null
null
/* Generated by Cython 0.29.12 */ /* BEGIN: Cython Metadata { "distutils": { "name": "graphbrain.parsers.alpha_beta", "sources": [ "graphbrain/parsers/alpha_beta.pyx" ] }, "module_name": "graphbrain.parsers.alpha_beta" } END: Cython Metadata */ #define PY_SSIZE_T_CLEAN #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else #define CYTHON_ABI "0_29_12" #define CYTHON_HEX_VERSION 0x001D0CF0 #define CYTHON_FUTURE_DIVISION 1 #include <stddef.h> #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #elif !defined(CYTHON_USE_PYLONG_INTERNALS) #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #ifndef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if PY_VERSION_HEX < 0x030300F0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) #endif #ifndef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) #endif #ifndef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR # if defined(__cplusplus) template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } # else # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ #if _MSC_VER < 1300 typedef unsigned char uint8_t; typedef unsigned int uint32_t; #else typedef unsigned __int8 uint8_t; typedef unsigned __int32 uint32_t; #endif #endif #else #include <stdint.h> #endif #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) && __cplusplus >= 201103L #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__ ) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #define __Pyx_PyCFunctionFast _PyCFunctionFast #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #if CYTHON_FAST_PYCCALL #define __Pyx_PyFastCFunction_Check(func)\ ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 #define PyMem_RawMalloc(n) PyMem_Malloc(n) #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) #define PyMem_RawFree(p) PyMem_Free(p) #endif #if CYTHON_COMPILING_IN_PYSTON #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #else #define __Pyx_PyThreadState_Current _PyThreadState_Current #endif #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) #include "pythread.h" #define Py_tss_NEEDS_INIT 0 typedef int Py_tss_t; static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { *key = PyThread_create_key(); return 0; } static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); *key = Py_tss_NEEDS_INIT; return key; } static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { PyObject_Free(key); } static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { return *key != Py_tss_NEEDS_INIT; } static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { PyThread_delete_key(*key); *key = Py_tss_NEEDS_INIT; } static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { return PyThread_set_key_value(*key, value); } static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { return PyThread_get_key_value(*key); } #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) #else #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #else #define CYTHON_PEP393_ENABLED 0 #define PyUnicode_1BYTE_KIND 1 #define PyUnicode_2BYTE_KIND 2 #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #define PyObject_Unicode PyObject_Str #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #else #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef __Pyx_PyAsyncMethodsStruct typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include <math.h> #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #define __PYX_ERR(f_index, lineno, Ln_error) \ { \ __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ } #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__graphbrain__parsers__alpha_beta #define __PYX_HAVE_API__graphbrain__parsers__alpha_beta /* Early includes */ #ifdef _OPENMP #include <omp.h> #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include <cstdlib> #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char *__pyx_f[] = { "graphbrain/parsers/alpha_beta.pyx", }; /*--- Type declarations ---*/ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywords.proto */ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #else #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) #endif #define __Pyx_BUILD_ASSERT_EXPR(cond)\ (sizeof(char [1 - 2*!(cond)]) - 1) #ifndef Py_MEMBER_SIZE #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #endif static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" #define __Pxy_PyFrame_Initialize_Offsets()\ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) #define __Pyx_PyFrame_GetLocalsplus(frame)\ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) #endif /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif /* PyCFunctionFastCall.proto */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); #else #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) #endif /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* IncludeStringH.proto */ #include <string.h> /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __pyx_dict_cached_value;\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } #define __Pyx_GetModuleGlobalNameUncached(var, name) {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* PyObjectCall2Args.proto */ static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* SliceObject.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** py_start, PyObject** py_stop, PyObject** py_slice, int has_cstart, int has_cstop, int wraparound); /* ListCompAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len)) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) #endif /* PyObjectSetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* ObjectGetItem.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); #else #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) #endif /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* IterFinish.proto */ static CYTHON_INLINE int __Pyx_IterFinish(void); /* UnpackItemEndCheck.proto */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* PySequenceContains.proto */ static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { int result = PySequence_Contains(seq, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* SetItemInt.proto */ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, int wraparound, int boundscheck); /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* CalculateMetaclass.proto */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); /* CythonFunction.proto */ #define __Pyx_CyFunction_USED 1 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { PyCFunctionObject func; #if PY_VERSION_HEX < 0x030500A0 PyObject *func_weakreflist; #endif PyObject *func_dict; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; PyObject *func_classobj; void *defaults; int defaults_pyobjects; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; } __pyx_CyFunctionObject; static PyTypeObject *__pyx_CyFunctionType = 0; #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType)) #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\ __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *self, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, size_t size, int pyobjects); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(void); /* SetNameInClass.proto */ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 #define __Pyx_SetNameInClass(ns, name, value)\ (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value)) #elif CYTHON_COMPILING_IN_CPYTHON #define __Pyx_SetNameInClass(ns, name, value)\ (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value)) #else #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value) #endif /* Py3ClassCreate.proto */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc); static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /* CyFunctionClassCell.proto */ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj); /* CLineInTraceback.proto */ #ifdef CYTHON_CLINE_IN_TRACEBACK #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #else static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #endif /* CodeObjectCache.proto */ typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) /* CStringEquals.proto */ static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'graphbrain.parsers.alpha_beta' */ #define __Pyx_MODULE_NAME "graphbrain.parsers.alpha_beta" extern int __pyx_module_is_main_graphbrain__parsers__alpha_beta; int __pyx_module_is_main_graphbrain__parsers__alpha_beta = 0; /* Implementation of 'graphbrain.parsers.alpha_beta' */ static PyObject *__pyx_builtin_super; static PyObject *__pyx_builtin_NotImplementedError; static PyObject *__pyx_builtin_zip; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_any; static const char __pyx_k_a[] = "a"; static const char __pyx_k_b[] = "+/b.{}/."; static const char __pyx_k_c[] = "c"; static const char __pyx_k_d[] = "d"; static const char __pyx_k_i[] = "i"; static const char __pyx_k_m[] = "m"; static const char __pyx_k_p[] = "p"; static const char __pyx_k_r[] = "r"; static const char __pyx_k_s[] = "s"; static const char __pyx_k_t[] = "t"; static const char __pyx_k_w[] = "w"; static const char __pyx_k_x[] = "x"; static const char __pyx_k__3[] = ""; static const char __pyx_k__4[] = "."; static const char __pyx_k__5[] = "?"; static const char __pyx_k__6[] = "{}..{}"; static const char __pyx_k__7[] = "/"; static const char __pyx_k__8[] = "{}.{}.{}"; static const char __pyx_k_av[] = "av.{}"; static const char __pyx_k_cm[] = "cm"; static const char __pyx_k_ct[] = "ct"; static const char __pyx_k_et[] = "et"; static const char __pyx_k_pc[] = "pc"; static const char __pyx_k_pd[] = "pd"; static const char __pyx_k_pm[] = "pm"; static const char __pyx_k_pr[] = "pr"; static const char __pyx_k_ps[] = "ps"; static const char __pyx_k_pt[] = "pt"; static const char __pyx_k_rm[] = "rm"; static const char __pyx_k_tt[] = "tt"; static const char __pyx_k_xv[] = "xv.{}"; static const char __pyx_k__10[] = "*"; static const char __pyx_k__64[] = "_"; static const char __pyx_k_add[] = "add"; static const char __pyx_k_any[] = "any"; static const char __pyx_k_b_2[] = "b"; static const char __pyx_k_b_3[] = "b+"; static const char __pyx_k_b_4[] = ":/b/."; static const char __pyx_k_dep[] = "dep_"; static const char __pyx_k_doc[] = "__doc__"; static const char __pyx_k_get[] = "get"; static const char __pyx_k_p_2[] = "p?"; static const char __pyx_k_pos[] = "pos"; static const char __pyx_k_t_t[] = "t/t/."; static const char __pyx_k_tag[] = "tag_"; static const char __pyx_k_zip[] = "zip"; static const char __pyx_k_ATOM[] = "ATOM: {}"; static const char __pyx_k_DATE[] = "DATE"; static const char __pyx_k_TIME[] = "TIME"; static const char __pyx_k_args[] = "args"; static const char __pyx_k_atom[] = "atom"; static const char __pyx_k_b_am[] = "+/b.am"; static const char __pyx_k_edge[] = "edge"; static const char __pyx_k_flat[] = "flat"; static const char __pyx_k_head[] = "head"; static const char __pyx_k_init[] = "__init__"; static const char __pyx_k_item[] = "item"; static const char __pyx_k_lang[] = "lang"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_nest[] = "nest"; static const char __pyx_k_orig[] = "orig"; static const char __pyx_k_pred[] = "pred"; static const char __pyx_k_role[] = "role"; static const char __pyx_k_self[] = "self"; static const char __pyx_k_t_tt[] = "t/tt/."; static const char __pyx_k_targ[] = "targ"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_text[] = "text"; static const char __pyx_k_type[] = "type"; static const char __pyx_k_child[] = "child"; static const char __pyx_k_const[] = "const"; static const char __pyx_k_debug[] = "debug"; static const char __pyx_k_first[] = "first"; static const char __pyx_k_hedge[] = "hedge"; static const char __pyx_k_inner[] = "inner"; static const char __pyx_k_lefts[] = "lefts"; static const char __pyx_k_lemma[] = "lemma_"; static const char __pyx_k_lower[] = "lower"; static const char __pyx_k_outer[] = "outer"; static const char __pyx_k_param[] = "param"; static const char __pyx_k_parts[] = "parts"; static const char __pyx_k_punct[] = "punct"; static const char __pyx_k_split[] = "split"; static const char __pyx_k_strip[] = "strip"; static const char __pyx_k_super[] = "super"; static const char __pyx_k_tedge[] = "tedge"; static const char __pyx_k_temps[] = "temps"; static const char __pyx_k_token[] = "token"; static const char __pyx_k_Parser[] = "Parser"; static const char __pyx_k_before[] = "before"; static const char __pyx_k_entity[] = "entity"; static const char __pyx_k_format[] = "format"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_lemmas[] = "lemmas"; static const char __pyx_k_module[] = "__module__"; static const char __pyx_k_parser[] = "parser"; static const char __pyx_k_repeat[] = "repeat"; static const char __pyx_k_result[] = "result"; static const char __pyx_k_rights[] = "rights"; static const char __pyx_k_arg_pos[] = "arg_pos"; static const char __pyx_k_builder[] = "builder"; static const char __pyx_k_concept[] = "concept"; static const char __pyx_k_connect[] = "connect"; static const char __pyx_k_is_atom[] = "is_atom"; static const char __pyx_k_is_noun[] = "_is_noun"; static const char __pyx_k_is_verb[] = "_is_verb"; static const char __pyx_k_lemma_2[] = "lemma"; static const char __pyx_k_logging[] = "logging"; static const char __pyx_k_prepare[] = "__prepare__"; static const char __pyx_k_trigger[] = "trigger"; static const char __pyx_k_warning[] = "warning"; static const char __pyx_k_arg_role[] = "arg_role"; static const char __pyx_k_arg_type[] = "_arg_type"; static const char __pyx_k_children[] = "children"; static const char __pyx_k_choice_1[] = "choice: 1"; static const char __pyx_k_choice_2[] = "choice: 2"; static const char __pyx_k_choice_3[] = "choice: 3"; static const char __pyx_k_choice_5[] = "choice: 5"; static const char __pyx_k_choice_6[] = "choice: 6"; static const char __pyx_k_choice_7[] = "choice: 7"; static const char __pyx_k_choice_8[] = "choice: 8"; static const char __pyx_k_choice_9[] = "choice: 9"; static const char __pyx_k_con_list[] = "con_list"; static const char __pyx_k_concepts[] = "concepts"; static const char __pyx_k_cur_text[] = "cur_text"; static const char __pyx_k_ent_type[] = "ent_type"; static const char __pyx_k_new_args[] = "new_args"; static const char __pyx_k_new_part[] = "new_part"; static const char __pyx_k_new_pred[] = "new_pred"; static const char __pyx_k_newparts[] = "newparts"; static const char __pyx_k_pos_dict[] = "pos_dict"; static const char __pyx_k_qualname[] = "__qualname__"; static const char __pyx_k_sequence[] = "sequence"; static const char __pyx_k_subparts[] = "subparts"; static const char __pyx_k_temporal[] = "temporal"; static const char __pyx_k_triparts[] = "triparts"; static const char __pyx_k_AlphaBeta[] = "AlphaBeta"; static const char __pyx_k_arg_roles[] = "arg_roles"; static const char __pyx_k_child_s_s[] = "child: [%s] %s"; static const char __pyx_k_choice_10[] = "choice: 10"; static const char __pyx_k_choice_11[] = "choice: 11"; static const char __pyx_k_choice_12[] = "choice: 12"; static const char __pyx_k_choice_13[] = "choice: 13"; static const char __pyx_k_choice_14[] = "choice: 14"; static const char __pyx_k_choice_15[] = "choice: 15"; static const char __pyx_k_choice_16[] = "choice: 16"; static const char __pyx_k_choice_17[] = "choice: 17"; static const char __pyx_k_choice_18[] = "choice: 18"; static const char __pyx_k_choice_19[] = "choice: 19"; static const char __pyx_k_choice_20[] = "choice: 20"; static const char __pyx_k_choice_4a[] = "choice: 4a"; static const char __pyx_k_choice_4b[] = "choice: 4b"; static const char __pyx_k_enumerate[] = "enumerate"; static const char __pyx_k_first_rel[] = "first_rel"; static const char __pyx_k_inner_rel[] = "inner_rel"; static const char __pyx_k_itertools[] = "itertools"; static const char __pyx_k_metaclass[] = "__metaclass__"; static const char __pyx_k_new_child[] = "new_child"; static const char __pyx_k_predicate[] = "predicate"; static const char __pyx_k_proc_edge[] = "proc_edge"; static const char __pyx_k_subentity[] = "subentity"; static const char __pyx_k_targ_type[] = "targ_type"; static const char __pyx_k_add_lemmas[] = "_add_lemmas"; static const char __pyx_k_atom2token[] = "atom2token"; static const char __pyx_k_build_atom[] = "build_atom"; static const char __pyx_k_child_type[] = "child_type"; static const char __pyx_k_ent_type_2[] = "ent_type_"; static const char __pyx_k_entity_s_s[] = "entity: [%s] %s"; static const char __pyx_k_graphbrain[] = "graphbrain"; static const char __pyx_k_last_token[] = "last_token"; static const char __pyx_k_lemma_edge[] = "lemma_edge"; static const char __pyx_k_lemma_pred[] = "lemma_pred"; static const char __pyx_k_new_entity[] = "new_entity"; static const char __pyx_k_result_s_s[] = "result: [%s] %s\n"; static const char __pyx_k_token_dict[] = "token_dict"; static const char __pyx_k_token_type[] = "_token_type"; static const char __pyx_k_args_string[] = "args_string"; static const char __pyx_k_child_token[] = "child_token"; static const char __pyx_k_extra_edges[] = "extra_edges"; static const char __pyx_k_is_compound[] = "_is_compound"; static const char __pyx_k_parse_token[] = "_parse_token"; static const char __pyx_k_build_atom_2[] = "_build_atom"; static const char __pyx_k_child_tokens[] = "child_tokens"; static const char __pyx_k_concept_role[] = "_concept_role"; static const char __pyx_k_post_process[] = "_post_process"; static const char __pyx_k_replace_atom[] = "replace_atom"; static const char __pyx_k_trigger_atom[] = "trigger_atom"; static const char __pyx_k_concept_roles[] = "concept_roles"; static const char __pyx_k_verb_features[] = "_verb_features"; static const char __pyx_k_atom_with_type[] = "atom_with_type"; static const char __pyx_k_connector_type[] = "connector_type"; static const char __pyx_k_nest_predicate[] = "nest_predicate"; static const char __pyx_k_token_head_type[] = "_token_head_type"; static const char __pyx_k_verb_features_2[] = "verb_features"; static const char __pyx_k_AlphaBeta___init[] = "AlphaBeta.__init__"; static const char __pyx_k_compose_concepts[] = "_compose_concepts"; static const char __pyx_k_post_parse_token[] = "_post_parse_token"; static const char __pyx_k_builder_arg_roles[] = "_builder_arg_roles"; static const char __pyx_k_replace_atom_part[] = "replace_atom_part"; static const char __pyx_k_AlphaBeta__is_noun[] = "AlphaBeta._is_noun"; static const char __pyx_k_AlphaBeta__is_verb[] = "AlphaBeta._is_verb"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_contains_atom_type[] = "contains_atom_type"; static const char __pyx_k_AlphaBeta__arg_type[] = "AlphaBeta._arg_type"; static const char __pyx_k_NotImplementedError[] = "NotImplementedError"; static const char __pyx_k_is_relative_concept[] = "_is_relative_concept"; static const char __pyx_k_relative_to_concept[] = "relative_to_concept"; static const char __pyx_k_build_atom_auxiliary[] = "_build_atom_auxiliary"; static const char __pyx_k_build_atom_predicate[] = "_build_atom_predicate"; static const char __pyx_k_graphbrain_constants[] = "graphbrain.constants"; static const char __pyx_k_parse_token_children[] = "_parse_token_children"; static const char __pyx_k_AlphaBeta__add_lemmas[] = "AlphaBeta._add_lemmas"; static const char __pyx_k_AlphaBeta__build_atom[] = "AlphaBeta._build_atom"; static const char __pyx_k_AlphaBeta__token_type[] = "AlphaBeta._token_type"; static const char __pyx_k_before_parse_sentence[] = "_before_parse_sentence"; static const char __pyx_k_insert_first_argument[] = "insert_first_argument"; static const char __pyx_k_AlphaBeta__is_compound[] = "AlphaBeta._is_compound"; static const char __pyx_k_AlphaBeta__parse_token[] = "AlphaBeta._parse_token"; static const char __pyx_k_insert_after_predicate[] = "insert_after_predicate"; static const char __pyx_k_AlphaBeta__concept_role[] = "AlphaBeta._concept_role"; static const char __pyx_k_AlphaBeta__post_process[] = "AlphaBeta._post_process"; static const char __pyx_k_build_atom_subpredicate[] = "_build_atom_subpredicate"; static const char __pyx_k_AlphaBeta__verb_features[] = "AlphaBeta._verb_features"; static const char __pyx_k_builder_type_and_subtype[] = "_builder_type_and_subtype"; static const char __pyx_k_concept_type_and_subtype[] = "_concept_type_and_subtype"; static const char __pyx_k_modifier_type_and_subtype[] = "_modifier_type_and_subtype"; static const char __pyx_k_AlphaBeta__token_head_type[] = "AlphaBeta._token_head_type"; static const char __pyx_k_auxiliary_type_and_subtype[] = "_auxiliary_type_and_subtype"; static const char __pyx_k_AlphaBeta__compose_concepts[] = "AlphaBeta._compose_concepts"; static const char __pyx_k_AlphaBeta__post_parse_token[] = "AlphaBeta._post_parse_token"; static const char __pyx_k_AlphaBeta__builder_arg_roles[] = "AlphaBeta._builder_arg_roles"; static const char __pyx_k_graphbrain_parsers_alpha_beta[] = "graphbrain.parsers.alpha_beta"; static const char __pyx_k_is_post_parse_token_necessary[] = "_is_post_parse_token_necessary"; static const char __pyx_k_AlphaBeta__is_relative_concept[] = "AlphaBeta._is_relative_concept"; static const char __pyx_k_AlphaBeta__build_atom_auxiliary[] = "AlphaBeta._build_atom_auxiliary"; static const char __pyx_k_AlphaBeta__build_atom_predicate[] = "AlphaBeta._build_atom_predicate"; static const char __pyx_k_AlphaBeta__parse_token_children[] = "AlphaBeta._parse_token_children"; static const char __pyx_k_apply_aux_concept_list_to_conce[] = "_apply_aux_concept_list_to_concept"; static const char __pyx_k_predicate_post_type_and_subtype[] = "_predicate_post_type_and_subtype"; static const char __pyx_k_AlphaBeta__auxiliary_type_and_su[] = "AlphaBeta._auxiliary_type_and_subtype"; static const char __pyx_k_AlphaBeta__before_parse_sentence[] = "AlphaBeta._before_parse_sentence"; static const char __pyx_k_AlphaBeta__build_atom_subpredica[] = "AlphaBeta._build_atom_subpredicate"; static const char __pyx_k_AlphaBeta__builder_type_and_subt[] = "AlphaBeta._builder_type_and_subtype"; static const char __pyx_k_AlphaBeta__concept_type_and_subt[] = "AlphaBeta._concept_type_and_subtype"; static const char __pyx_k_AlphaBeta__is_post_parse_token_n[] = "AlphaBeta._is_post_parse_token_necessary"; static const char __pyx_k_AlphaBeta__modifier_type_and_sub[] = "AlphaBeta._modifier_type_and_subtype"; static const char __pyx_k_AlphaBeta__predicate_post_type_a[] = "AlphaBeta._predicate_post_type_and_subtype"; static const char __pyx_k_Failed_to_parse_token__parse_tok[] = "Failed to parse token (_parse_token): {}"; static const char __pyx_k_graphbrain_parsers_alpha_beta_py[] = "graphbrain/parsers/alpha_beta.pyx"; static const char __pyx_k_insert_after_predicate_failedwit[] = "insert_after_predicate failedwith: {}"; static PyObject *__pyx_kp_u_ATOM; static PyObject *__pyx_n_s_AlphaBeta; static PyObject *__pyx_n_s_AlphaBeta___init; static PyObject *__pyx_n_s_AlphaBeta__add_lemmas; static PyObject *__pyx_n_s_AlphaBeta__arg_type; static PyObject *__pyx_n_s_AlphaBeta__auxiliary_type_and_su; static PyObject *__pyx_n_s_AlphaBeta__before_parse_sentence; static PyObject *__pyx_n_s_AlphaBeta__build_atom; static PyObject *__pyx_n_s_AlphaBeta__build_atom_auxiliary; static PyObject *__pyx_n_s_AlphaBeta__build_atom_predicate; static PyObject *__pyx_n_s_AlphaBeta__build_atom_subpredica; static PyObject *__pyx_n_s_AlphaBeta__builder_arg_roles; static PyObject *__pyx_n_s_AlphaBeta__builder_type_and_subt; static PyObject *__pyx_n_s_AlphaBeta__compose_concepts; static PyObject *__pyx_n_s_AlphaBeta__concept_role; static PyObject *__pyx_n_s_AlphaBeta__concept_type_and_subt; static PyObject *__pyx_n_s_AlphaBeta__is_compound; static PyObject *__pyx_n_s_AlphaBeta__is_noun; static PyObject *__pyx_n_s_AlphaBeta__is_post_parse_token_n; static PyObject *__pyx_n_s_AlphaBeta__is_relative_concept; static PyObject *__pyx_n_s_AlphaBeta__is_verb; static PyObject *__pyx_n_s_AlphaBeta__modifier_type_and_sub; static PyObject *__pyx_n_s_AlphaBeta__parse_token; static PyObject *__pyx_n_s_AlphaBeta__parse_token_children; static PyObject *__pyx_n_s_AlphaBeta__post_parse_token; static PyObject *__pyx_n_s_AlphaBeta__post_process; static PyObject *__pyx_n_s_AlphaBeta__predicate_post_type_a; static PyObject *__pyx_n_s_AlphaBeta__token_head_type; static PyObject *__pyx_n_s_AlphaBeta__token_type; static PyObject *__pyx_n_s_AlphaBeta__verb_features; static PyObject *__pyx_n_u_DATE; static PyObject *__pyx_kp_u_Failed_to_parse_token__parse_tok; static PyObject *__pyx_n_s_NotImplementedError; static PyObject *__pyx_n_s_Parser; static PyObject *__pyx_n_u_TIME; static PyObject *__pyx_n_s__10; static PyObject *__pyx_kp_u__3; static PyObject *__pyx_kp_u__4; static PyObject *__pyx_kp_u__5; static PyObject *__pyx_kp_u__6; static PyObject *__pyx_n_s__64; static PyObject *__pyx_kp_u__7; static PyObject *__pyx_kp_u__8; static PyObject *__pyx_n_u_a; static PyObject *__pyx_n_s_add; static PyObject *__pyx_n_s_add_lemmas; static PyObject *__pyx_n_s_any; static PyObject *__pyx_n_s_apply_aux_concept_list_to_conce; static PyObject *__pyx_n_s_arg_pos; static PyObject *__pyx_n_s_arg_role; static PyObject *__pyx_n_s_arg_roles; static PyObject *__pyx_n_s_arg_type; static PyObject *__pyx_n_s_args; static PyObject *__pyx_n_s_args_string; static PyObject *__pyx_n_s_atom; static PyObject *__pyx_n_s_atom2token; static PyObject *__pyx_n_s_atom_with_type; static PyObject *__pyx_n_s_auxiliary_type_and_subtype; static PyObject *__pyx_kp_u_av; static PyObject *__pyx_kp_u_b; static PyObject *__pyx_n_u_b_2; static PyObject *__pyx_kp_u_b_3; static PyObject *__pyx_kp_u_b_4; static PyObject *__pyx_kp_u_b_am; static PyObject *__pyx_n_s_before; static PyObject *__pyx_n_s_before_parse_sentence; static PyObject *__pyx_n_s_build_atom; static PyObject *__pyx_n_s_build_atom_2; static PyObject *__pyx_n_s_build_atom_auxiliary; static PyObject *__pyx_n_s_build_atom_predicate; static PyObject *__pyx_n_s_build_atom_subpredicate; static PyObject *__pyx_n_s_builder; static PyObject *__pyx_n_s_builder_arg_roles; static PyObject *__pyx_n_s_builder_type_and_subtype; static PyObject *__pyx_n_u_c; static PyObject *__pyx_n_s_child; static PyObject *__pyx_kp_u_child_s_s; static PyObject *__pyx_n_s_child_token; static PyObject *__pyx_n_s_child_tokens; static PyObject *__pyx_n_s_child_type; static PyObject *__pyx_n_s_children; static PyObject *__pyx_kp_u_choice_1; static PyObject *__pyx_kp_u_choice_10; static PyObject *__pyx_kp_u_choice_11; static PyObject *__pyx_kp_u_choice_12; static PyObject *__pyx_kp_u_choice_13; static PyObject *__pyx_kp_u_choice_14; static PyObject *__pyx_kp_u_choice_15; static PyObject *__pyx_kp_u_choice_16; static PyObject *__pyx_kp_u_choice_17; static PyObject *__pyx_kp_u_choice_18; static PyObject *__pyx_kp_u_choice_19; static PyObject *__pyx_kp_u_choice_2; static PyObject *__pyx_kp_u_choice_20; static PyObject *__pyx_kp_u_choice_3; static PyObject *__pyx_kp_u_choice_4a; static PyObject *__pyx_kp_u_choice_4b; static PyObject *__pyx_kp_u_choice_5; static PyObject *__pyx_kp_u_choice_6; static PyObject *__pyx_kp_u_choice_7; static PyObject *__pyx_kp_u_choice_8; static PyObject *__pyx_kp_u_choice_9; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_u_cm; static PyObject *__pyx_n_s_compose_concepts; static PyObject *__pyx_n_s_con_list; static PyObject *__pyx_n_s_concept; static PyObject *__pyx_n_s_concept_role; static PyObject *__pyx_n_s_concept_roles; static PyObject *__pyx_n_s_concept_type_and_subtype; static PyObject *__pyx_n_s_concepts; static PyObject *__pyx_n_s_connect; static PyObject *__pyx_n_s_connector_type; static PyObject *__pyx_n_s_const; static PyObject *__pyx_n_s_contains_atom_type; static PyObject *__pyx_n_s_ct; static PyObject *__pyx_n_s_cur_text; static PyObject *__pyx_n_u_d; static PyObject *__pyx_n_s_debug; static PyObject *__pyx_n_s_dep; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_edge; static PyObject *__pyx_n_s_ent_type; static PyObject *__pyx_n_s_ent_type_2; static PyObject *__pyx_n_s_entity; static PyObject *__pyx_kp_u_entity_s_s; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_et; static PyObject *__pyx_n_s_extra_edges; static PyObject *__pyx_n_s_first; static PyObject *__pyx_n_s_first_rel; static PyObject *__pyx_n_s_flat; static PyObject *__pyx_n_s_format; static PyObject *__pyx_n_s_get; static PyObject *__pyx_n_s_graphbrain; static PyObject *__pyx_n_s_graphbrain_constants; static PyObject *__pyx_n_s_graphbrain_parsers_alpha_beta; static PyObject *__pyx_kp_s_graphbrain_parsers_alpha_beta_py; static PyObject *__pyx_n_s_head; static PyObject *__pyx_n_s_hedge; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_init; static PyObject *__pyx_n_s_inner; static PyObject *__pyx_n_s_inner_rel; static PyObject *__pyx_n_s_insert_after_predicate; static PyObject *__pyx_kp_u_insert_after_predicate_failedwit; static PyObject *__pyx_n_s_insert_first_argument; static PyObject *__pyx_n_s_is_atom; static PyObject *__pyx_n_s_is_compound; static PyObject *__pyx_n_s_is_noun; static PyObject *__pyx_n_s_is_post_parse_token_necessary; static PyObject *__pyx_n_s_is_relative_concept; static PyObject *__pyx_n_s_is_verb; static PyObject *__pyx_n_s_item; static PyObject *__pyx_n_s_itertools; static PyObject *__pyx_n_s_lang; static PyObject *__pyx_n_s_last_token; static PyObject *__pyx_n_s_lefts; static PyObject *__pyx_n_s_lemma; static PyObject *__pyx_n_s_lemma_2; static PyObject *__pyx_n_s_lemma_edge; static PyObject *__pyx_n_s_lemma_pred; static PyObject *__pyx_n_s_lemmas; static PyObject *__pyx_n_s_logging; static PyObject *__pyx_n_s_lower; static PyObject *__pyx_n_u_m; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_metaclass; static PyObject *__pyx_n_s_modifier_type_and_subtype; static PyObject *__pyx_n_s_module; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_nest; static PyObject *__pyx_n_s_nest_predicate; static PyObject *__pyx_n_s_new_args; static PyObject *__pyx_n_s_new_child; static PyObject *__pyx_n_s_new_entity; static PyObject *__pyx_n_s_new_part; static PyObject *__pyx_n_s_new_pred; static PyObject *__pyx_n_s_newparts; static PyObject *__pyx_n_s_orig; static PyObject *__pyx_n_s_outer; static PyObject *__pyx_n_u_p; static PyObject *__pyx_kp_u_p_2; static PyObject *__pyx_n_s_param; static PyObject *__pyx_n_s_parse_token; static PyObject *__pyx_n_s_parse_token_children; static PyObject *__pyx_n_s_parser; static PyObject *__pyx_n_s_parts; static PyObject *__pyx_n_u_pc; static PyObject *__pyx_n_u_pd; static PyObject *__pyx_n_u_pm; static PyObject *__pyx_n_s_pos; static PyObject *__pyx_n_s_pos_dict; static PyObject *__pyx_n_s_post_parse_token; static PyObject *__pyx_n_s_post_process; static PyObject *__pyx_n_u_pr; static PyObject *__pyx_n_s_pred; static PyObject *__pyx_n_s_predicate; static PyObject *__pyx_n_s_predicate_post_type_and_subtype; static PyObject *__pyx_n_s_prepare; static PyObject *__pyx_n_s_proc_edge; static PyObject *__pyx_n_s_ps; static PyObject *__pyx_n_s_pt; static PyObject *__pyx_n_u_punct; static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_u_r; static PyObject *__pyx_n_s_relative_to_concept; static PyObject *__pyx_n_s_repeat; static PyObject *__pyx_n_s_replace_atom; static PyObject *__pyx_n_s_replace_atom_part; static PyObject *__pyx_n_s_result; static PyObject *__pyx_kp_u_result_s_s; static PyObject *__pyx_n_s_rights; static PyObject *__pyx_n_u_rm; static PyObject *__pyx_n_s_role; static PyObject *__pyx_n_u_s; static PyObject *__pyx_n_s_self; static PyObject *__pyx_n_s_sequence; static PyObject *__pyx_n_s_split; static PyObject *__pyx_n_s_strip; static PyObject *__pyx_n_s_subentity; static PyObject *__pyx_n_s_subparts; static PyObject *__pyx_n_s_super; static PyObject *__pyx_n_u_t; static PyObject *__pyx_kp_u_t_t; static PyObject *__pyx_kp_u_t_tt; static PyObject *__pyx_n_s_tag; static PyObject *__pyx_n_s_targ; static PyObject *__pyx_n_s_targ_type; static PyObject *__pyx_n_s_tedge; static PyObject *__pyx_n_s_temporal; static PyObject *__pyx_n_s_temps; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_text; static PyObject *__pyx_n_s_token; static PyObject *__pyx_n_s_token_dict; static PyObject *__pyx_n_s_token_head_type; static PyObject *__pyx_n_s_token_type; static PyObject *__pyx_n_s_trigger; static PyObject *__pyx_n_s_trigger_atom; static PyObject *__pyx_n_s_triparts; static PyObject *__pyx_n_u_tt; static PyObject *__pyx_n_s_type; static PyObject *__pyx_n_s_verb_features; static PyObject *__pyx_n_s_verb_features_2; static PyObject *__pyx_n_u_w; static PyObject *__pyx_n_s_warning; static PyObject *__pyx_n_u_x; static PyObject *__pyx_kp_u_xv; static PyObject *__pyx_n_s_zip; static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_insert_after_predicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_targ, PyObject *__pyx_v_orig); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_2nest_predicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_inner, PyObject *__pyx_v_outer, PyObject *__pyx_v_before); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_4_apply_aux_concept_list_to_concept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_con_list, PyObject *__pyx_v_concept); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_lemmas); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_2_arg_type(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_4_token_type(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_6_concept_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_8_modifier_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_10_builder_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_12_auxiliary_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_14_predicate_post_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_edge, CYTHON_UNUSED PyObject *__pyx_v_subparts, CYTHON_UNUSED PyObject *__pyx_v_args_string); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_16_concept_role(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_concept); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_18_builder_arg_roles(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_edge); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_20_is_noun(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_22_is_compound(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_24_is_relative_concept(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_26_is_verb(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_28_verb_features(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_30_token_head_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_32_build_atom(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type, PyObject *__pyx_v_last_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_34_build_atom_predicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type, PyObject *__pyx_v_last_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_36_build_atom_subpredicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_38_build_atom_auxiliary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_40_compose_concepts(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_concepts); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_42_post_process(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_entity); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_44_before_parse_sentence(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_46_parse_token_children(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_48_add_lemmas(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_entity, PyObject *__pyx_v_ent_type); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_50_is_post_parse_token_necessary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_entity); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_52_post_parse_token(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_entity, PyObject *__pyx_v_token_dict); /* proto */ static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_54_parse_token(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token); /* proto */ static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; static PyObject *__pyx_slice_; static PyObject *__pyx_slice__2; static PyObject *__pyx_tuple__9; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__15; static PyObject *__pyx_tuple__17; static PyObject *__pyx_tuple__19; static PyObject *__pyx_tuple__20; static PyObject *__pyx_tuple__22; static PyObject *__pyx_tuple__24; static PyObject *__pyx_tuple__26; static PyObject *__pyx_tuple__28; static PyObject *__pyx_tuple__30; static PyObject *__pyx_tuple__32; static PyObject *__pyx_tuple__34; static PyObject *__pyx_tuple__36; static PyObject *__pyx_tuple__38; static PyObject *__pyx_tuple__40; static PyObject *__pyx_tuple__42; static PyObject *__pyx_tuple__44; static PyObject *__pyx_tuple__46; static PyObject *__pyx_tuple__48; static PyObject *__pyx_tuple__50; static PyObject *__pyx_tuple__52; static PyObject *__pyx_tuple__54; static PyObject *__pyx_tuple__56; static PyObject *__pyx_tuple__58; static PyObject *__pyx_tuple__60; static PyObject *__pyx_tuple__62; static PyObject *__pyx_tuple__65; static PyObject *__pyx_tuple__67; static PyObject *__pyx_tuple__69; static PyObject *__pyx_tuple__71; static PyObject *__pyx_tuple__73; static PyObject *__pyx_codeobj__12; static PyObject *__pyx_codeobj__14; static PyObject *__pyx_codeobj__16; static PyObject *__pyx_codeobj__18; static PyObject *__pyx_codeobj__21; static PyObject *__pyx_codeobj__23; static PyObject *__pyx_codeobj__25; static PyObject *__pyx_codeobj__27; static PyObject *__pyx_codeobj__29; static PyObject *__pyx_codeobj__31; static PyObject *__pyx_codeobj__33; static PyObject *__pyx_codeobj__35; static PyObject *__pyx_codeobj__37; static PyObject *__pyx_codeobj__39; static PyObject *__pyx_codeobj__41; static PyObject *__pyx_codeobj__43; static PyObject *__pyx_codeobj__45; static PyObject *__pyx_codeobj__47; static PyObject *__pyx_codeobj__49; static PyObject *__pyx_codeobj__51; static PyObject *__pyx_codeobj__53; static PyObject *__pyx_codeobj__55; static PyObject *__pyx_codeobj__57; static PyObject *__pyx_codeobj__59; static PyObject *__pyx_codeobj__61; static PyObject *__pyx_codeobj__63; static PyObject *__pyx_codeobj__66; static PyObject *__pyx_codeobj__68; static PyObject *__pyx_codeobj__70; static PyObject *__pyx_codeobj__72; static PyObject *__pyx_codeobj__74; /* Late includes */ /* "graphbrain/parsers/alpha_beta.pyx":8 * * * def insert_after_predicate(targ, orig): # <<<<<<<<<<<<<< * targ_type = targ.type() * if targ_type[0] == 'p': */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_1insert_after_predicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_1insert_after_predicate = {"insert_after_predicate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_1insert_after_predicate, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_1insert_after_predicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_targ = 0; PyObject *__pyx_v_orig = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("insert_after_predicate (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_targ,&__pyx_n_s_orig,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_targ)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_orig)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("insert_after_predicate", 1, 2, 2, 1); __PYX_ERR(0, 8, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "insert_after_predicate") < 0)) __PYX_ERR(0, 8, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_targ = values[0]; __pyx_v_orig = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("insert_after_predicate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 8, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.insert_after_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_insert_after_predicate(__pyx_self, __pyx_v_targ, __pyx_v_orig); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_insert_after_predicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_targ, PyObject *__pyx_v_orig) { PyObject *__pyx_v_targ_type = NULL; PyObject *__pyx_v_inner_rel = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("insert_after_predicate", 0); /* "graphbrain/parsers/alpha_beta.pyx":9 * * def insert_after_predicate(targ, orig): * targ_type = targ.type() # <<<<<<<<<<<<<< * if targ_type[0] == 'p': * return hedge((targ, orig)) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_targ, __pyx_n_s_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_targ_type = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":10 * def insert_after_predicate(targ, orig): * targ_type = targ.type() * if targ_type[0] == 'p': # <<<<<<<<<<<<<< * return hedge((targ, orig)) * elif targ_type[0] == 'r': */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_targ_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":11 * targ_type = targ.type() * if targ_type[0] == 'p': * return hedge((targ, orig)) # <<<<<<<<<<<<<< * elif targ_type[0] == 'r': * if targ_type == 'rm': */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_hedge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_targ); __Pyx_GIVEREF(__pyx_v_targ); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_targ); __Pyx_INCREF(__pyx_v_orig); __Pyx_GIVEREF(__pyx_v_orig); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_orig); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":10 * def insert_after_predicate(targ, orig): * targ_type = targ.type() * if targ_type[0] == 'p': # <<<<<<<<<<<<<< * return hedge((targ, orig)) * elif targ_type[0] == 'r': */ } /* "graphbrain/parsers/alpha_beta.pyx":12 * if targ_type[0] == 'p': * return hedge((targ, orig)) * elif targ_type[0] == 'r': # <<<<<<<<<<<<<< * if targ_type == 'rm': * inner_rel = insert_after_predicate(targ[1], orig) */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_targ_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_r, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":13 * return hedge((targ, orig)) * elif targ_type[0] == 'r': * if targ_type == 'rm': # <<<<<<<<<<<<<< * inner_rel = insert_after_predicate(targ[1], orig) * if inner_rel: */ __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_targ_type, __pyx_n_u_rm, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 13, __pyx_L1_error) if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":14 * elif targ_type[0] == 'r': * if targ_type == 'rm': * inner_rel = insert_after_predicate(targ[1], orig) # <<<<<<<<<<<<<< * if inner_rel: * return hedge((targ[0], inner_rel) + tuple(targ[2:])) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_insert_after_predicate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_targ, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_orig}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_v_orig}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_v_orig); __Pyx_GIVEREF(__pyx_v_orig); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_orig); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_inner_rel = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":15 * if targ_type == 'rm': * inner_rel = insert_after_predicate(targ[1], orig) * if inner_rel: # <<<<<<<<<<<<<< * return hedge((targ[0], inner_rel) + tuple(targ[2:])) * else: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_inner_rel); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 15, __pyx_L1_error) if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":16 * inner_rel = insert_after_predicate(targ[1], orig) * if inner_rel: * return hedge((targ[0], inner_rel) + tuple(targ[2:])) # <<<<<<<<<<<<<< * else: * return None */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_hedge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_targ, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __Pyx_INCREF(__pyx_v_inner_rel); __Pyx_GIVEREF(__pyx_v_inner_rel); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_inner_rel); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_targ, 2, 0, NULL, NULL, &__pyx_slice_, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Add(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":15 * if targ_type == 'rm': * inner_rel = insert_after_predicate(targ[1], orig) * if inner_rel: # <<<<<<<<<<<<<< * return hedge((targ[0], inner_rel) + tuple(targ[2:])) * else: */ } /* "graphbrain/parsers/alpha_beta.pyx":18 * return hedge((targ[0], inner_rel) + tuple(targ[2:])) * else: * return None # <<<<<<<<<<<<<< * else: * return targ.insert_first_argument(orig) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; } /* "graphbrain/parsers/alpha_beta.pyx":13 * return hedge((targ, orig)) * elif targ_type[0] == 'r': * if targ_type == 'rm': # <<<<<<<<<<<<<< * inner_rel = insert_after_predicate(targ[1], orig) * if inner_rel: */ } /* "graphbrain/parsers/alpha_beta.pyx":20 * return None * else: * return targ.insert_first_argument(orig) # <<<<<<<<<<<<<< * else: * return targ.insert_first_argument(orig) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_targ, __pyx_n_s_insert_first_argument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_v_orig) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_orig); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; } /* "graphbrain/parsers/alpha_beta.pyx":12 * if targ_type[0] == 'p': * return hedge((targ, orig)) * elif targ_type[0] == 'r': # <<<<<<<<<<<<<< * if targ_type == 'rm': * inner_rel = insert_after_predicate(targ[1], orig) */ } /* "graphbrain/parsers/alpha_beta.pyx":22 * return targ.insert_first_argument(orig) * else: * return targ.insert_first_argument(orig) # <<<<<<<<<<<<<< * # else: * # logging.warning(('Wrong target type (insert_after_predicate).' */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_targ, __pyx_n_s_insert_first_argument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_v_orig) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_orig); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; } /* "graphbrain/parsers/alpha_beta.pyx":8 * * * def insert_after_predicate(targ, orig): # <<<<<<<<<<<<<< * targ_type = targ.type() * if targ_type[0] == 'p': */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.insert_after_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_targ_type); __Pyx_XDECREF(__pyx_v_inner_rel); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":29 * * * def nest_predicate(inner, outer, before): # <<<<<<<<<<<<<< * if inner.type() == 'rm': * first_rel = nest_predicate(inner[1], outer, before) */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_3nest_predicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_3nest_predicate = {"nest_predicate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_3nest_predicate, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_3nest_predicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_inner = 0; PyObject *__pyx_v_outer = 0; PyObject *__pyx_v_before = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("nest_predicate (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inner,&__pyx_n_s_outer,&__pyx_n_s_before,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inner)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_outer)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("nest_predicate", 1, 3, 3, 1); __PYX_ERR(0, 29, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_before)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("nest_predicate", 1, 3, 3, 2); __PYX_ERR(0, 29, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "nest_predicate") < 0)) __PYX_ERR(0, 29, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_inner = values[0]; __pyx_v_outer = values[1]; __pyx_v_before = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("nest_predicate", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 29, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.nest_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_2nest_predicate(__pyx_self, __pyx_v_inner, __pyx_v_outer, __pyx_v_before); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_2nest_predicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_inner, PyObject *__pyx_v_outer, PyObject *__pyx_v_before) { PyObject *__pyx_v_first_rel = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; __Pyx_RefNannySetupContext("nest_predicate", 0); /* "graphbrain/parsers/alpha_beta.pyx":30 * * def nest_predicate(inner, outer, before): * if inner.type() == 'rm': # <<<<<<<<<<<<<< * first_rel = nest_predicate(inner[1], outer, before) * return hedge((inner[0], first_rel) + tuple(inner[2:])) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_inner, __pyx_n_s_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_rm, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":31 * def nest_predicate(inner, outer, before): * if inner.type() == 'rm': * first_rel = nest_predicate(inner[1], outer, before) # <<<<<<<<<<<<<< * return hedge((inner[0], first_rel) + tuple(inner[2:])) * elif inner.is_atom() or inner.type()[0] == 'p': */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_nest_predicate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_inner, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, __pyx_v_outer, __pyx_v_before}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, __pyx_v_outer, __pyx_v_before}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_v_outer); __Pyx_GIVEREF(__pyx_v_outer); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_outer); __Pyx_INCREF(__pyx_v_before); __Pyx_GIVEREF(__pyx_v_before); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_before); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_first_rel = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":32 * if inner.type() == 'rm': * first_rel = nest_predicate(inner[1], outer, before) * return hedge((inner[0], first_rel) + tuple(inner[2:])) # <<<<<<<<<<<<<< * elif inner.is_atom() or inner.type()[0] == 'p': * return hedge((outer, inner)) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_hedge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_inner, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __Pyx_INCREF(__pyx_v_first_rel); __Pyx_GIVEREF(__pyx_v_first_rel); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_first_rel); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_inner, 2, 0, NULL, NULL, &__pyx_slice_, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Add(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":30 * * def nest_predicate(inner, outer, before): * if inner.type() == 'rm': # <<<<<<<<<<<<<< * first_rel = nest_predicate(inner[1], outer, before) * return hedge((inner[0], first_rel) + tuple(inner[2:])) */ } /* "graphbrain/parsers/alpha_beta.pyx":33 * first_rel = nest_predicate(inner[1], outer, before) * return hedge((inner[0], first_rel) + tuple(inner[2:])) * elif inner.is_atom() or inner.type()[0] == 'p': # <<<<<<<<<<<<<< * return hedge((outer, inner)) * else: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_inner, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_inner, __pyx_n_s_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_8; __pyx_L4_bool_binop_done:; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":34 * return hedge((inner[0], first_rel) + tuple(inner[2:])) * elif inner.is_atom() or inner.type()[0] == 'p': * return hedge((outer, inner)) # <<<<<<<<<<<<<< * else: * return hedge(((outer, inner[0]),) + inner[1:]) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_hedge); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_outer); __Pyx_GIVEREF(__pyx_v_outer); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_outer); __Pyx_INCREF(__pyx_v_inner); __Pyx_GIVEREF(__pyx_v_inner); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_inner); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":33 * first_rel = nest_predicate(inner[1], outer, before) * return hedge((inner[0], first_rel) + tuple(inner[2:])) * elif inner.is_atom() or inner.type()[0] == 'p': # <<<<<<<<<<<<<< * return hedge((outer, inner)) * else: */ } /* "graphbrain/parsers/alpha_beta.pyx":36 * return hedge((outer, inner)) * else: * return hedge(((outer, inner[0]),) + inner[1:]) # <<<<<<<<<<<<<< * * */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_hedge); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_inner, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_outer); __Pyx_GIVEREF(__pyx_v_outer); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_outer); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_inner, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyNumber_Add(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "graphbrain/parsers/alpha_beta.pyx":29 * * * def nest_predicate(inner, outer, before): # <<<<<<<<<<<<<< * if inner.type() == 'rm': * first_rel = nest_predicate(inner[1], outer, before) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.nest_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_first_rel); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":45 * # (+/b.am bank/c records/cn.p) * # (+/b.am (credit/cn.s card/cn.s) records/cn.p)) * def _apply_aux_concept_list_to_concept(con_list, concept): # <<<<<<<<<<<<<< * concepts = tuple([('+/b.am', item, concept) for item in con_list[1:]]) * return hedge((con_list[0],) + concepts) */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_5_apply_aux_concept_list_to_concept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_5_apply_aux_concept_list_to_concept = {"_apply_aux_concept_list_to_concept", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_5_apply_aux_concept_list_to_concept, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_5_apply_aux_concept_list_to_concept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_con_list = 0; PyObject *__pyx_v_concept = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_apply_aux_concept_list_to_concept (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_con_list,&__pyx_n_s_concept,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_con_list)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_concept)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_apply_aux_concept_list_to_concept", 1, 2, 2, 1); __PYX_ERR(0, 45, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_apply_aux_concept_list_to_concept") < 0)) __PYX_ERR(0, 45, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_con_list = values[0]; __pyx_v_concept = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_apply_aux_concept_list_to_concept", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 45, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta._apply_aux_concept_list_to_concept", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_4_apply_aux_concept_list_to_concept(__pyx_self, __pyx_v_con_list, __pyx_v_concept); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_4_apply_aux_concept_list_to_concept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_con_list, PyObject *__pyx_v_concept) { PyObject *__pyx_v_concepts = NULL; PyObject *__pyx_7genexpr__pyx_v_item = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("_apply_aux_concept_list_to_concept", 0); /* "graphbrain/parsers/alpha_beta.pyx":46 * # (+/b.am (credit/cn.s card/cn.s) records/cn.p)) * def _apply_aux_concept_list_to_concept(con_list, concept): * concepts = tuple([('+/b.am', item, concept) for item in con_list[1:]]) # <<<<<<<<<<<<<< * return hedge((con_list[0],) + concepts) * */ { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_con_list, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L5_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 46, __pyx_L5_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 46, __pyx_L5_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 46, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_item, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_kp_u_b_am); __Pyx_GIVEREF(__pyx_kp_u_b_am); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_b_am); __Pyx_INCREF(__pyx_7genexpr__pyx_v_item); __Pyx_GIVEREF(__pyx_7genexpr__pyx_v_item); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_7genexpr__pyx_v_item); __Pyx_INCREF(__pyx_v_concept); __Pyx_GIVEREF(__pyx_v_concept); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_concept); if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 46, __pyx_L5_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_item); __pyx_7genexpr__pyx_v_item = 0; goto __pyx_L8_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_item); __pyx_7genexpr__pyx_v_item = 0; goto __pyx_L1_error; __pyx_L8_exit_scope:; } /* exit inner scope */ __pyx_t_3 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_concepts = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":47 * def _apply_aux_concept_list_to_concept(con_list, concept): * concepts = tuple([('+/b.am', item, concept) for item in con_list[1:]]) * return hedge((con_list[0],) + concepts) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_hedge); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_con_list, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Add(__pyx_t_6, __pyx_v_concepts); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":45 * # (+/b.am bank/c records/cn.p) * # (+/b.am (credit/cn.s card/cn.s) records/cn.p)) * def _apply_aux_concept_list_to_concept(con_list, concept): # <<<<<<<<<<<<<< * concepts = tuple([('+/b.am', item, concept) for item in con_list[1:]]) * return hedge((con_list[0],) + concepts) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta._apply_aux_concept_list_to_concept", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_concepts); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":51 * * class AlphaBeta(Parser): * def __init__(self, lemmas=False): # <<<<<<<<<<<<<< * super().__init__(lemmas=lemmas) * self.extra_edges = set() */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_1__init__, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_lemmas = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_lemmas,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)((PyObject *)Py_False)); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lemmas); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 51, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_self = values[0]; __pyx_v_lemmas = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 51, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta___init__(__pyx_self, __pyx_v_self, __pyx_v_lemmas); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_lemmas) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("__init__", 0); /* "graphbrain/parsers/alpha_beta.pyx":52 * class AlphaBeta(Parser): * def __init__(self, lemmas=False): * super().__init__(lemmas=lemmas) # <<<<<<<<<<<<<< * self.extra_edges = set() * */ __pyx_t_1 = __Pyx_CyFunction_GetClassObj(__pyx_self); if (!__pyx_t_1) { PyErr_SetString(PyExc_SystemError, "super(): empty __class__ cell"); __PYX_ERR(0, 52, __pyx_L1_error) } __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_INCREF(__pyx_v_self); __Pyx_GIVEREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_lemmas, __pyx_v_lemmas) < 0) __PYX_ERR(0, 52, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":53 * def __init__(self, lemmas=False): * super().__init__(lemmas=lemmas) * self.extra_edges = set() # <<<<<<<<<<<<<< * * # ======================================================================== */ __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_extra_edges, __pyx_t_3) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":51 * * class AlphaBeta(Parser): * def __init__(self, lemmas=False): # <<<<<<<<<<<<<< * super().__init__(lemmas=lemmas) * self.extra_edges = set() */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":59 * # ======================================================================== * * def _arg_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_3_arg_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_3_arg_type = {"_arg_type", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_3_arg_type, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_3_arg_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_arg_type (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_arg_type", 1, 2, 2, 1); __PYX_ERR(0, 59, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_arg_type") < 0)) __PYX_ERR(0, 59, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_arg_type", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 59, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._arg_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_2_arg_type(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_2_arg_type(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_arg_type", 0); /* "graphbrain/parsers/alpha_beta.pyx":60 * * def _arg_type(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _token_type(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 60, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":59 * # ======================================================================== * * def _arg_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._arg_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":62 * raise NotImplementedError() * * def _token_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_5_token_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_5_token_type = {"_token_type", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_5_token_type, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_5_token_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_token_type (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_token_type", 1, 2, 2, 1); __PYX_ERR(0, 62, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_token_type") < 0)) __PYX_ERR(0, 62, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_token_type", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 62, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._token_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_4_token_type(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_4_token_type(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_token_type", 0); /* "graphbrain/parsers/alpha_beta.pyx":63 * * def _token_type(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _concept_type_and_subtype(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 63, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":62 * raise NotImplementedError() * * def _token_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._token_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":65 * raise NotImplementedError() * * def _concept_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_7_concept_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_7_concept_type_and_subtype = {"_concept_type_and_subtype", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_7_concept_type_and_subtype, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_7_concept_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_concept_type_and_subtype (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_concept_type_and_subtype", 1, 2, 2, 1); __PYX_ERR(0, 65, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_concept_type_and_subtype") < 0)) __PYX_ERR(0, 65, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_concept_type_and_subtype", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 65, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._concept_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_6_concept_type_and_subtype(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_6_concept_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_concept_type_and_subtype", 0); /* "graphbrain/parsers/alpha_beta.pyx":66 * * def _concept_type_and_subtype(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _modifier_type_and_subtype(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 66, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":65 * raise NotImplementedError() * * def _concept_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._concept_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":68 * raise NotImplementedError() * * def _modifier_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_9_modifier_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_9_modifier_type_and_subtype = {"_modifier_type_and_subtype", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_9_modifier_type_and_subtype, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_9_modifier_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_modifier_type_and_subtype (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_modifier_type_and_subtype", 1, 2, 2, 1); __PYX_ERR(0, 68, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_modifier_type_and_subtype") < 0)) __PYX_ERR(0, 68, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_modifier_type_and_subtype", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 68, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._modifier_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_8_modifier_type_and_subtype(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_8_modifier_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_modifier_type_and_subtype", 0); /* "graphbrain/parsers/alpha_beta.pyx":69 * * def _modifier_type_and_subtype(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _builder_type_and_subtype(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 69, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":68 * raise NotImplementedError() * * def _modifier_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._modifier_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":71 * raise NotImplementedError() * * def _builder_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_11_builder_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_11_builder_type_and_subtype = {"_builder_type_and_subtype", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_11_builder_type_and_subtype, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_11_builder_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_builder_type_and_subtype (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_builder_type_and_subtype", 1, 2, 2, 1); __PYX_ERR(0, 71, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_builder_type_and_subtype") < 0)) __PYX_ERR(0, 71, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_builder_type_and_subtype", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 71, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._builder_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_10_builder_type_and_subtype(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_10_builder_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_builder_type_and_subtype", 0); /* "graphbrain/parsers/alpha_beta.pyx":72 * * def _builder_type_and_subtype(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _auxiliary_type_and_subtype(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 72, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":71 * raise NotImplementedError() * * def _builder_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._builder_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":74 * raise NotImplementedError() * * def _auxiliary_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_13_auxiliary_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_13_auxiliary_type_and_subtype = {"_auxiliary_type_and_subtype", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_13_auxiliary_type_and_subtype, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_13_auxiliary_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_auxiliary_type_and_subtype (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_auxiliary_type_and_subtype", 1, 2, 2, 1); __PYX_ERR(0, 74, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_auxiliary_type_and_subtype") < 0)) __PYX_ERR(0, 74, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_auxiliary_type_and_subtype", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 74, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._auxiliary_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_12_auxiliary_type_and_subtype(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_12_auxiliary_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_auxiliary_type_and_subtype", 0); /* "graphbrain/parsers/alpha_beta.pyx":75 * * def _auxiliary_type_and_subtype(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _predicate_post_type_and_subtype(self, edge, subparts, args_string): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 75, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":74 * raise NotImplementedError() * * def _auxiliary_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._auxiliary_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":77 * raise NotImplementedError() * * def _predicate_post_type_and_subtype(self, edge, subparts, args_string): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_15_predicate_post_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_15_predicate_post_type_and_subtype = {"_predicate_post_type_and_subtype", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_15_predicate_post_type_and_subtype, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_15_predicate_post_type_and_subtype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_edge = 0; CYTHON_UNUSED PyObject *__pyx_v_subparts = 0; CYTHON_UNUSED PyObject *__pyx_v_args_string = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_predicate_post_type_and_subtype (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_edge,&__pyx_n_s_subparts,&__pyx_n_s_args_string,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_edge)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_predicate_post_type_and_subtype", 1, 4, 4, 1); __PYX_ERR(0, 77, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subparts)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_predicate_post_type_and_subtype", 1, 4, 4, 2); __PYX_ERR(0, 77, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args_string)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_predicate_post_type_and_subtype", 1, 4, 4, 3); __PYX_ERR(0, 77, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_predicate_post_type_and_subtype") < 0)) __PYX_ERR(0, 77, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_self = values[0]; __pyx_v_edge = values[1]; __pyx_v_subparts = values[2]; __pyx_v_args_string = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_predicate_post_type_and_subtype", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 77, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._predicate_post_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_14_predicate_post_type_and_subtype(__pyx_self, __pyx_v_self, __pyx_v_edge, __pyx_v_subparts, __pyx_v_args_string); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_14_predicate_post_type_and_subtype(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_edge, CYTHON_UNUSED PyObject *__pyx_v_subparts, CYTHON_UNUSED PyObject *__pyx_v_args_string) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_predicate_post_type_and_subtype", 0); /* "graphbrain/parsers/alpha_beta.pyx":78 * * def _predicate_post_type_and_subtype(self, edge, subparts, args_string): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _concept_role(self, concept): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 78, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":77 * raise NotImplementedError() * * def _predicate_post_type_and_subtype(self, edge, subparts, args_string): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._predicate_post_type_and_subtype", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":80 * raise NotImplementedError() * * def _concept_role(self, concept): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_17_concept_role(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_17_concept_role = {"_concept_role", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_17_concept_role, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_17_concept_role(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_concept = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_concept_role (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_concept,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_concept)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_concept_role", 1, 2, 2, 1); __PYX_ERR(0, 80, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_concept_role") < 0)) __PYX_ERR(0, 80, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_concept = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_concept_role", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 80, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._concept_role", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_16_concept_role(__pyx_self, __pyx_v_self, __pyx_v_concept); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_16_concept_role(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_concept) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_concept_role", 0); /* "graphbrain/parsers/alpha_beta.pyx":81 * * def _concept_role(self, concept): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _builder_arg_roles(self, edge): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 81, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":80 * raise NotImplementedError() * * def _concept_role(self, concept): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._concept_role", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":83 * raise NotImplementedError() * * def _builder_arg_roles(self, edge): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_19_builder_arg_roles(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_19_builder_arg_roles = {"_builder_arg_roles", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_19_builder_arg_roles, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_19_builder_arg_roles(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_edge = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_builder_arg_roles (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_edge,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_edge)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_builder_arg_roles", 1, 2, 2, 1); __PYX_ERR(0, 83, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_builder_arg_roles") < 0)) __PYX_ERR(0, 83, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_edge = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_builder_arg_roles", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 83, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._builder_arg_roles", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_18_builder_arg_roles(__pyx_self, __pyx_v_self, __pyx_v_edge); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_18_builder_arg_roles(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_edge) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_builder_arg_roles", 0); /* "graphbrain/parsers/alpha_beta.pyx":84 * * def _builder_arg_roles(self, edge): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _is_noun(token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 84, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":83 * raise NotImplementedError() * * def _builder_arg_roles(self, edge): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._builder_arg_roles", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":86 * raise NotImplementedError() * * def _is_noun(token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_21_is_noun(PyObject *__pyx_self, PyObject *__pyx_v_token); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_21_is_noun = {"_is_noun", (PyCFunction)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_21_is_noun, METH_O, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_21_is_noun(PyObject *__pyx_self, PyObject *__pyx_v_token) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_is_noun (wrapper)", 0); __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_20_is_noun(__pyx_self, ((PyObject *)__pyx_v_token)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_20_is_noun(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_is_noun", 0); /* "graphbrain/parsers/alpha_beta.pyx":87 * * def _is_noun(token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _is_compound(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 87, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":86 * raise NotImplementedError() * * def _is_noun(token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_noun", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":89 * raise NotImplementedError() * * def _is_compound(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_23_is_compound(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_23_is_compound = {"_is_compound", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_23_is_compound, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_23_is_compound(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_is_compound (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_is_compound", 1, 2, 2, 1); __PYX_ERR(0, 89, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_is_compound") < 0)) __PYX_ERR(0, 89, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_is_compound", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 89, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_compound", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_22_is_compound(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_22_is_compound(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_is_compound", 0); /* "graphbrain/parsers/alpha_beta.pyx":90 * * def _is_compound(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _is_relative_concept(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 90, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":89 * raise NotImplementedError() * * def _is_compound(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_compound", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":92 * raise NotImplementedError() * * def _is_relative_concept(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_25_is_relative_concept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_25_is_relative_concept = {"_is_relative_concept", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_25_is_relative_concept, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_25_is_relative_concept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_is_relative_concept (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_is_relative_concept", 1, 2, 2, 1); __PYX_ERR(0, 92, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_is_relative_concept") < 0)) __PYX_ERR(0, 92, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_is_relative_concept", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 92, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_relative_concept", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_24_is_relative_concept(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_24_is_relative_concept(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_is_relative_concept", 0); /* "graphbrain/parsers/alpha_beta.pyx":93 * * def _is_relative_concept(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _is_verb(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 93, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":92 * raise NotImplementedError() * * def _is_relative_concept(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_relative_concept", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":95 * raise NotImplementedError() * * def _is_verb(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_27_is_verb(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_27_is_verb = {"_is_verb", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_27_is_verb, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_27_is_verb(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_is_verb (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_is_verb", 1, 2, 2, 1); __PYX_ERR(0, 95, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_is_verb") < 0)) __PYX_ERR(0, 95, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_is_verb", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 95, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_verb", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_26_is_verb(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_26_is_verb(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_is_verb", 0); /* "graphbrain/parsers/alpha_beta.pyx":96 * * def _is_verb(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * def _verb_features(self, token): */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 96, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":95 * raise NotImplementedError() * * def _is_verb(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_verb", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":98 * raise NotImplementedError() * * def _verb_features(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_29_verb_features(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_29_verb_features = {"_verb_features", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_29_verb_features, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_29_verb_features(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_verb_features (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_verb_features", 1, 2, 2, 1); __PYX_ERR(0, 98, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_verb_features") < 0)) __PYX_ERR(0, 98, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_verb_features", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 98, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._verb_features", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_28_verb_features(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_28_verb_features(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_token) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_verb_features", 0); /* "graphbrain/parsers/alpha_beta.pyx":99 * * def _verb_features(self, token): * raise NotImplementedError() # <<<<<<<<<<<<<< * * # ========================= */ __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 99, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":98 * raise NotImplementedError() * * def _verb_features(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._verb_features", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":105 * # ========================= * * def _token_head_type(self, token): # <<<<<<<<<<<<<< * head = token.head * if head and head != token: */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_31_token_head_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_31_token_head_type = {"_token_head_type", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_31_token_head_type, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_31_token_head_type(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_token_head_type (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_token_head_type", 1, 2, 2, 1); __PYX_ERR(0, 105, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_token_head_type") < 0)) __PYX_ERR(0, 105, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_token_head_type", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 105, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._token_head_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_30_token_head_type(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_30_token_head_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token) { PyObject *__pyx_v_head = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("_token_head_type", 0); /* "graphbrain/parsers/alpha_beta.pyx":106 * * def _token_head_type(self, token): * head = token.head # <<<<<<<<<<<<<< * if head and head != token: * return self._token_type(head) */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_head); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_head = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":107 * def _token_head_type(self, token): * head = token.head * if head and head != token: # <<<<<<<<<<<<<< * return self._token_type(head) * else: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_head); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 107, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_1 = PyObject_RichCompare(__pyx_v_head, __pyx_v_token, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* "graphbrain/parsers/alpha_beta.pyx":108 * head = token.head * if head and head != token: * return self._token_type(head) # <<<<<<<<<<<<<< * else: * return '' */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_token_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_head) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_head); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":107 * def _token_head_type(self, token): * head = token.head * if head and head != token: # <<<<<<<<<<<<<< * return self._token_type(head) * else: */ } /* "graphbrain/parsers/alpha_beta.pyx":110 * return self._token_type(head) * else: * return '' # <<<<<<<<<<<<<< * * def _build_atom(self, token, ent_type, last_token): */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_kp_u__3); __pyx_r = __pyx_kp_u__3; goto __pyx_L0; } /* "graphbrain/parsers/alpha_beta.pyx":105 * # ========================= * * def _token_head_type(self, token): # <<<<<<<<<<<<<< * head = token.head * if head and head != token: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._token_head_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_head); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":112 * return '' * * def _build_atom(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_33_build_atom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_33_build_atom = {"_build_atom", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_33_build_atom, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_33_build_atom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_v_ent_type = 0; PyObject *__pyx_v_last_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_build_atom (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,&__pyx_n_s_ent_type,&__pyx_n_s_last_token,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom", 1, 4, 4, 1); __PYX_ERR(0, 112, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ent_type)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom", 1, 4, 4, 2); __PYX_ERR(0, 112, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_last_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom", 1, 4, 4, 3); __PYX_ERR(0, 112, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_build_atom") < 0)) __PYX_ERR(0, 112, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; __pyx_v_ent_type = values[2]; __pyx_v_last_token = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_build_atom", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 112, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_32_build_atom(__pyx_self, __pyx_v_self, __pyx_v_token, __pyx_v_ent_type, __pyx_v_last_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_32_build_atom(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type, PyObject *__pyx_v_last_token) { PyObject *__pyx_v_text = NULL; PyObject *__pyx_v_et = NULL; PyObject *__pyx_v_atom = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("_build_atom", 0); /* "graphbrain/parsers/alpha_beta.pyx":113 * * def _build_atom(self, token, ent_type, last_token): * text = token.text.lower() # <<<<<<<<<<<<<< * et = ent_type * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_text = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":114 * def _build_atom(self, token, ent_type, last_token): * text = token.text.lower() * et = ent_type # <<<<<<<<<<<<<< * * if ent_type[0] == 'p' and ent_type != 'pm': */ __Pyx_INCREF(__pyx_v_ent_type); __pyx_v_et = __pyx_v_ent_type; /* "graphbrain/parsers/alpha_beta.pyx":116 * et = ent_type * * if ent_type[0] == 'p' and ent_type != 'pm': # <<<<<<<<<<<<<< * atom = self._build_atom_predicate(token, ent_type, last_token) * elif ent_type[0] == 'x': */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ent_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_ent_type, __pyx_n_u_pm, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 116, __pyx_L1_error) __pyx_t_4 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":117 * * if ent_type[0] == 'p' and ent_type != 'pm': * atom = self._build_atom_predicate(token, ent_type, last_token) # <<<<<<<<<<<<<< * elif ent_type[0] == 'x': * atom = self._build_atom_subpredicate(token, ent_type) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_build_atom_predicate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_token, __pyx_v_ent_type, __pyx_v_last_token}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_token, __pyx_v_ent_type, __pyx_v_last_token}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_token); __Pyx_GIVEREF(__pyx_v_token); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_token); __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_ent_type); __Pyx_INCREF(__pyx_v_last_token); __Pyx_GIVEREF(__pyx_v_last_token); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_last_token); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_atom = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":116 * et = ent_type * * if ent_type[0] == 'p' and ent_type != 'pm': # <<<<<<<<<<<<<< * atom = self._build_atom_predicate(token, ent_type, last_token) * elif ent_type[0] == 'x': */ goto __pyx_L3; } /* "graphbrain/parsers/alpha_beta.pyx":118 * if ent_type[0] == 'p' and ent_type != 'pm': * atom = self._build_atom_predicate(token, ent_type, last_token) * elif ent_type[0] == 'x': # <<<<<<<<<<<<<< * atom = self._build_atom_subpredicate(token, ent_type) * elif ent_type[0] == 'a': */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ent_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_x, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":119 * atom = self._build_atom_predicate(token, ent_type, last_token) * elif ent_type[0] == 'x': * atom = self._build_atom_subpredicate(token, ent_type) # <<<<<<<<<<<<<< * elif ent_type[0] == 'a': * atom = self._build_atom_auxiliary(token, ent_type) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_build_atom_subpredicate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_token, __pyx_v_ent_type}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_token, __pyx_v_ent_type}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_token); __Pyx_GIVEREF(__pyx_v_token); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_6, __pyx_v_token); __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_6, __pyx_v_ent_type); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_atom = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":118 * if ent_type[0] == 'p' and ent_type != 'pm': * atom = self._build_atom_predicate(token, ent_type, last_token) * elif ent_type[0] == 'x': # <<<<<<<<<<<<<< * atom = self._build_atom_subpredicate(token, ent_type) * elif ent_type[0] == 'a': */ goto __pyx_L3; } /* "graphbrain/parsers/alpha_beta.pyx":120 * elif ent_type[0] == 'x': * atom = self._build_atom_subpredicate(token, ent_type) * elif ent_type[0] == 'a': # <<<<<<<<<<<<<< * atom = self._build_atom_auxiliary(token, ent_type) * else: */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ent_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_a, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":121 * atom = self._build_atom_subpredicate(token, ent_type) * elif ent_type[0] == 'a': * atom = self._build_atom_auxiliary(token, ent_type) # <<<<<<<<<<<<<< * else: * atom = build_atom(text, et, self.lang) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_build_atom_auxiliary); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_token, __pyx_v_ent_type}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_token, __pyx_v_ent_type}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_token); __Pyx_GIVEREF(__pyx_v_token); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_token); __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_ent_type); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_atom = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":120 * elif ent_type[0] == 'x': * atom = self._build_atom_subpredicate(token, ent_type) * elif ent_type[0] == 'a': # <<<<<<<<<<<<<< * atom = self._build_atom_auxiliary(token, ent_type) * else: */ goto __pyx_L3; } /* "graphbrain/parsers/alpha_beta.pyx":123 * atom = self._build_atom_auxiliary(token, ent_type) * else: * atom = build_atom(text, et, self.lang) # <<<<<<<<<<<<<< * * self.atom2token[atom] = token */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_build_atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lang); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_text, __pyx_v_et, __pyx_t_7}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_text, __pyx_v_et, __pyx_t_7}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_text); __Pyx_GIVEREF(__pyx_v_text); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, __pyx_v_text); __Pyx_INCREF(__pyx_v_et); __Pyx_GIVEREF(__pyx_v_et); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, __pyx_v_et); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_6, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_atom = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L3:; /* "graphbrain/parsers/alpha_beta.pyx":125 * atom = build_atom(text, et, self.lang) * * self.atom2token[atom] = token # <<<<<<<<<<<<<< * return atom * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_atom2token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_atom, __pyx_v_token) < 0)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":126 * * self.atom2token[atom] = token * return atom # <<<<<<<<<<<<<< * * def _build_atom_predicate(self, token, ent_type, last_token): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_atom); __pyx_r = __pyx_v_atom; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":112 * return '' * * def _build_atom(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_text); __Pyx_XDECREF(__pyx_v_et); __Pyx_XDECREF(__pyx_v_atom); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":128 * return atom * * def _build_atom_predicate(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_35_build_atom_predicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_35_build_atom_predicate = {"_build_atom_predicate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_35_build_atom_predicate, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_35_build_atom_predicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_v_ent_type = 0; PyObject *__pyx_v_last_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_build_atom_predicate (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,&__pyx_n_s_ent_type,&__pyx_n_s_last_token,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom_predicate", 1, 4, 4, 1); __PYX_ERR(0, 128, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ent_type)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom_predicate", 1, 4, 4, 2); __PYX_ERR(0, 128, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_last_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom_predicate", 1, 4, 4, 3); __PYX_ERR(0, 128, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_build_atom_predicate") < 0)) __PYX_ERR(0, 128, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; __pyx_v_ent_type = values[2]; __pyx_v_last_token = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_build_atom_predicate", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 128, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_34_build_atom_predicate(__pyx_self, __pyx_v_self, __pyx_v_token, __pyx_v_ent_type, __pyx_v_last_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_34_build_atom_predicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type, PyObject *__pyx_v_last_token) { PyObject *__pyx_v_text = NULL; PyObject *__pyx_v_et = NULL; PyObject *__pyx_v_verb_features = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("_build_atom_predicate", 0); __Pyx_INCREF(__pyx_v_ent_type); /* "graphbrain/parsers/alpha_beta.pyx":129 * * def _build_atom_predicate(self, token, ent_type, last_token): * text = token.text.lower() # <<<<<<<<<<<<<< * et = ent_type * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_text = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":130 * def _build_atom_predicate(self, token, ent_type, last_token): * text = token.text.lower() * et = ent_type # <<<<<<<<<<<<<< * * # create verb features string */ __Pyx_INCREF(__pyx_v_ent_type); __pyx_v_et = __pyx_v_ent_type; /* "graphbrain/parsers/alpha_beta.pyx":133 * * # create verb features string * verb_features = self._verb_features(token) # <<<<<<<<<<<<<< * * # first naive assignment of predicate subtype */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_verb_features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_verb_features = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":137 * # first naive assignment of predicate subtype * # (can be revised at post-processing stage) * if len(ent_type) == 1: # <<<<<<<<<<<<<< * # interrogative cases * if (last_token and */ __pyx_t_4 = PyObject_Length(__pyx_v_ent_type); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 137, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_4 == 1) != 0); if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":139 * if len(ent_type) == 1: * # interrogative cases * if (last_token and # <<<<<<<<<<<<<< * last_token.tag_ == '.' and * last_token.dep_ == 'punct' and */ __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_last_token); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 139, __pyx_L1_error) if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L5_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":140 * # interrogative cases * if (last_token and * last_token.tag_ == '.' and # <<<<<<<<<<<<<< * last_token.dep_ == 'punct' and * last_token.lemma_.strip() == '?'): */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_last_token, __pyx_n_s_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_kp_u__4, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L5_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":141 * if (last_token and * last_token.tag_ == '.' and * last_token.dep_ == 'punct' and # <<<<<<<<<<<<<< * last_token.lemma_.strip() == '?'): * ent_type = 'p?' */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_last_token, __pyx_n_s_dep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_punct, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L5_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":142 * last_token.tag_ == '.' and * last_token.dep_ == 'punct' and * last_token.lemma_.strip() == '?'): # <<<<<<<<<<<<<< * ent_type = 'p?' * # declarative (by default) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_last_token, __pyx_n_s_lemma); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_kp_u__5, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_6; __pyx_L5_bool_binop_done:; /* "graphbrain/parsers/alpha_beta.pyx":139 * if len(ent_type) == 1: * # interrogative cases * if (last_token and # <<<<<<<<<<<<<< * last_token.tag_ == '.' and * last_token.dep_ == 'punct' and */ if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":143 * last_token.dep_ == 'punct' and * last_token.lemma_.strip() == '?'): * ent_type = 'p?' # <<<<<<<<<<<<<< * # declarative (by default) * else: */ __Pyx_INCREF(__pyx_kp_u_p_2); __Pyx_DECREF_SET(__pyx_v_ent_type, __pyx_kp_u_p_2); /* "graphbrain/parsers/alpha_beta.pyx":139 * if len(ent_type) == 1: * # interrogative cases * if (last_token and # <<<<<<<<<<<<<< * last_token.tag_ == '.' and * last_token.dep_ == 'punct' and */ goto __pyx_L4; } /* "graphbrain/parsers/alpha_beta.pyx":146 * # declarative (by default) * else: * ent_type = 'pd' # <<<<<<<<<<<<<< * * et = '{}..{}'.format(ent_type, verb_features) */ /*else*/ { __Pyx_INCREF(__pyx_n_u_pd); __Pyx_DECREF_SET(__pyx_v_ent_type, __pyx_n_u_pd); } __pyx_L4:; /* "graphbrain/parsers/alpha_beta.pyx":137 * # first naive assignment of predicate subtype * # (can be revised at post-processing stage) * if len(ent_type) == 1: # <<<<<<<<<<<<<< * # interrogative cases * if (last_token and */ } /* "graphbrain/parsers/alpha_beta.pyx":148 * ent_type = 'pd' * * et = '{}..{}'.format(ent_type, verb_features) # <<<<<<<<<<<<<< * * return build_atom(text, et, self.lang) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__6, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_ent_type, __pyx_v_verb_features}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_ent_type, __pyx_v_verb_features}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_ent_type); __Pyx_INCREF(__pyx_v_verb_features); __Pyx_GIVEREF(__pyx_v_verb_features); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_verb_features); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_et, __pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":150 * et = '{}..{}'.format(ent_type, verb_features) * * return build_atom(text, et, self.lang) # <<<<<<<<<<<<<< * * def _build_atom_subpredicate(self, token, ent_type): */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_build_atom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lang); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_text, __pyx_v_et, __pyx_t_8}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_text, __pyx_v_et, __pyx_t_8}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_9 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_text); __Pyx_GIVEREF(__pyx_v_text); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_v_text); __Pyx_INCREF(__pyx_v_et); __Pyx_GIVEREF(__pyx_v_et); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_v_et); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":128 * return atom * * def _build_atom_predicate(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_text); __Pyx_XDECREF(__pyx_v_et); __Pyx_XDECREF(__pyx_v_verb_features); __Pyx_XDECREF(__pyx_v_ent_type); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":152 * return build_atom(text, et, self.lang) * * def _build_atom_subpredicate(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_37_build_atom_subpredicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_37_build_atom_subpredicate = {"_build_atom_subpredicate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_37_build_atom_subpredicate, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_37_build_atom_subpredicate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_v_ent_type = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_build_atom_subpredicate (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,&__pyx_n_s_ent_type,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom_subpredicate", 1, 3, 3, 1); __PYX_ERR(0, 152, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ent_type)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom_subpredicate", 1, 3, 3, 2); __PYX_ERR(0, 152, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_build_atom_subpredicate") < 0)) __PYX_ERR(0, 152, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; __pyx_v_ent_type = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_build_atom_subpredicate", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 152, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom_subpredicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_36_build_atom_subpredicate(__pyx_self, __pyx_v_self, __pyx_v_token, __pyx_v_ent_type); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_36_build_atom_subpredicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type) { PyObject *__pyx_v_text = NULL; PyObject *__pyx_v_et = NULL; PyObject *__pyx_v_verb_features = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_build_atom_subpredicate", 0); /* "graphbrain/parsers/alpha_beta.pyx":153 * * def _build_atom_subpredicate(self, token, ent_type): * text = token.text.lower() # <<<<<<<<<<<<<< * et = ent_type * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_text = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":154 * def _build_atom_subpredicate(self, token, ent_type): * text = token.text.lower() * et = ent_type # <<<<<<<<<<<<<< * * if self._is_verb(token): */ __Pyx_INCREF(__pyx_v_ent_type); __pyx_v_et = __pyx_v_ent_type; /* "graphbrain/parsers/alpha_beta.pyx":156 * et = ent_type * * if self._is_verb(token): # <<<<<<<<<<<<<< * # create verb features string * verb_features = self._verb_features(token) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_verb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":158 * if self._is_verb(token): * # create verb features string * verb_features = self._verb_features(token) # <<<<<<<<<<<<<< * et = 'xv.{}'.format(verb_features) * */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_verb_features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_verb_features = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":159 * # create verb features string * verb_features = self._verb_features(token) * et = 'xv.{}'.format(verb_features) # <<<<<<<<<<<<<< * * return build_atom(text, et, self.lang) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_xv, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_verb_features) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_verb_features); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_et, __pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":156 * et = ent_type * * if self._is_verb(token): # <<<<<<<<<<<<<< * # create verb features string * verb_features = self._verb_features(token) */ } /* "graphbrain/parsers/alpha_beta.pyx":161 * et = 'xv.{}'.format(verb_features) * * return build_atom(text, et, self.lang) # <<<<<<<<<<<<<< * * def _build_atom_auxiliary(self, token, ent_type): */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_build_atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lang); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_text, __pyx_v_et, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_text, __pyx_v_et, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_text); __Pyx_GIVEREF(__pyx_v_text); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_text); __Pyx_INCREF(__pyx_v_et); __Pyx_GIVEREF(__pyx_v_et); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_et); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":152 * return build_atom(text, et, self.lang) * * def _build_atom_subpredicate(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom_subpredicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_text); __Pyx_XDECREF(__pyx_v_et); __Pyx_XDECREF(__pyx_v_verb_features); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":163 * return build_atom(text, et, self.lang) * * def _build_atom_auxiliary(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_39_build_atom_auxiliary(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_39_build_atom_auxiliary = {"_build_atom_auxiliary", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_39_build_atom_auxiliary, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_39_build_atom_auxiliary(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_v_ent_type = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_build_atom_auxiliary (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,&__pyx_n_s_ent_type,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom_auxiliary", 1, 3, 3, 1); __PYX_ERR(0, 163, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ent_type)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_build_atom_auxiliary", 1, 3, 3, 2); __PYX_ERR(0, 163, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_build_atom_auxiliary") < 0)) __PYX_ERR(0, 163, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; __pyx_v_ent_type = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_build_atom_auxiliary", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom_auxiliary", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_38_build_atom_auxiliary(__pyx_self, __pyx_v_self, __pyx_v_token, __pyx_v_ent_type); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_38_build_atom_auxiliary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_ent_type) { PyObject *__pyx_v_text = NULL; PyObject *__pyx_v_verb_features = NULL; PyObject *__pyx_v_et = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_build_atom_auxiliary", 0); /* "graphbrain/parsers/alpha_beta.pyx":164 * * def _build_atom_auxiliary(self, token, ent_type): * text = token.text.lower() # <<<<<<<<<<<<<< * * if self._is_verb(token): */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_text = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":166 * text = token.text.lower() * * if self._is_verb(token): # <<<<<<<<<<<<<< * # create verb features string * verb_features = self._verb_features(token) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_verb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":168 * if self._is_verb(token): * # create verb features string * verb_features = self._verb_features(token) # <<<<<<<<<<<<<< * et = 'av.{}'.format(verb_features) # verbal subtype * else: */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_verb_features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_verb_features = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":169 * # create verb features string * verb_features = self._verb_features(token) * et = 'av.{}'.format(verb_features) # verbal subtype # <<<<<<<<<<<<<< * else: * et = self._auxiliary_type_and_subtype(token) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_av, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_verb_features) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_verb_features); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_et = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":166 * text = token.text.lower() * * if self._is_verb(token): # <<<<<<<<<<<<<< * # create verb features string * verb_features = self._verb_features(token) */ goto __pyx_L3; } /* "graphbrain/parsers/alpha_beta.pyx":171 * et = 'av.{}'.format(verb_features) # verbal subtype * else: * et = self._auxiliary_type_and_subtype(token) # <<<<<<<<<<<<<< * * if et == 'a': */ /*else*/ { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_auxiliary_type_and_subtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_et = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L3:; /* "graphbrain/parsers/alpha_beta.pyx":173 * et = self._auxiliary_type_and_subtype(token) * * if et == 'a': # <<<<<<<<<<<<<< * et = ent_type * */ __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_et, __pyx_n_u_a, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 173, __pyx_L1_error) if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":174 * * if et == 'a': * et = ent_type # <<<<<<<<<<<<<< * * return build_atom(text, et, self.lang) */ __Pyx_INCREF(__pyx_v_ent_type); __Pyx_DECREF_SET(__pyx_v_et, __pyx_v_ent_type); /* "graphbrain/parsers/alpha_beta.pyx":173 * et = self._auxiliary_type_and_subtype(token) * * if et == 'a': # <<<<<<<<<<<<<< * et = ent_type * */ } /* "graphbrain/parsers/alpha_beta.pyx":176 * et = ent_type * * return build_atom(text, et, self.lang) # <<<<<<<<<<<<<< * * def _compose_concepts(self, concepts): */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_build_atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lang); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_text, __pyx_v_et, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_text, __pyx_v_et, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_text); __Pyx_GIVEREF(__pyx_v_text); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_text); __Pyx_INCREF(__pyx_v_et); __Pyx_GIVEREF(__pyx_v_et); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_et); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":163 * return build_atom(text, et, self.lang) * * def _build_atom_auxiliary(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._build_atom_auxiliary", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_text); __Pyx_XDECREF(__pyx_v_verb_features); __Pyx_XDECREF(__pyx_v_et); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":178 * return build_atom(text, et, self.lang) * * def _compose_concepts(self, concepts): # <<<<<<<<<<<<<< * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_41_compose_concepts(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_41_compose_concepts = {"_compose_concepts", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_41_compose_concepts, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_41_compose_concepts(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_concepts = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_compose_concepts (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_concepts,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_concepts)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_compose_concepts", 1, 2, 2, 1); __PYX_ERR(0, 178, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_compose_concepts") < 0)) __PYX_ERR(0, 178, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_concepts = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_compose_concepts", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 178, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._compose_concepts", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_40_compose_concepts(__pyx_self, __pyx_v_self, __pyx_v_concepts); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_40_compose_concepts(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_concepts) { PyObject *__pyx_v_first = NULL; PyObject *__pyx_v_concept_roles = NULL; PyObject *__pyx_v_builder = NULL; PyObject *__pyx_8genexpr1__pyx_v_concept = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; Py_ssize_t __pyx_t_6; PyObject *(*__pyx_t_7)(PyObject *); PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("_compose_concepts", 0); /* "graphbrain/parsers/alpha_beta.pyx":179 * * def _compose_concepts(self, concepts): * first = concepts[0] # <<<<<<<<<<<<<< * if first.is_atom() or first[0].type()[0] != 'm': * concept_roles = [self._concept_role(concept) */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_concepts, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_first = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":180 * def _compose_concepts(self, concepts): * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': # <<<<<<<<<<<<<< * concept_roles = [self._concept_role(concept) * for concept in concepts] */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_first, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_first, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_m, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* "graphbrain/parsers/alpha_beta.pyx":181 * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': * concept_roles = [self._concept_role(concept) # <<<<<<<<<<<<<< * for concept in concepts] * builder = '+/b.{}/.'.format(''.join(concept_roles)) */ { /* enter inner scope */ __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); /* "graphbrain/parsers/alpha_beta.pyx":182 * if first.is_atom() or first[0].type()[0] != 'm': * concept_roles = [self._concept_role(concept) * for concept in concepts] # <<<<<<<<<<<<<< * builder = '+/b.{}/.'.format(''.join(concept_roles)) * return hedge(builder).connect(concepts) */ if (likely(PyList_CheckExact(__pyx_v_concepts)) || PyTuple_CheckExact(__pyx_v_concepts)) { __pyx_t_1 = __pyx_v_concepts; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_concepts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 182, __pyx_L8_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 182, __pyx_L8_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 182, __pyx_L8_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 182, __pyx_L8_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_concept, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":181 * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': * concept_roles = [self._concept_role(concept) # <<<<<<<<<<<<<< * for concept in concepts] * builder = '+/b.{}/.'.format(''.join(concept_roles)) */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_concept_role); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 181, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_8genexpr1__pyx_v_concept) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_8genexpr1__pyx_v_concept); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 181, __pyx_L8_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":182 * if first.is_atom() or first[0].type()[0] != 'm': * concept_roles = [self._concept_role(concept) * for concept in concepts] # <<<<<<<<<<<<<< * builder = '+/b.{}/.'.format(''.join(concept_roles)) * return hedge(builder).connect(concepts) */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_concept); __pyx_8genexpr1__pyx_v_concept = 0; goto __pyx_L11_exit_scope; __pyx_L8_error:; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_concept); __pyx_8genexpr1__pyx_v_concept = 0; goto __pyx_L1_error; __pyx_L11_exit_scope:; } /* exit inner scope */ __pyx_v_concept_roles = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "graphbrain/parsers/alpha_beta.pyx":183 * concept_roles = [self._concept_role(concept) * for concept in concepts] * builder = '+/b.{}/.'.format(''.join(concept_roles)) # <<<<<<<<<<<<<< * return hedge(builder).connect(concepts) * else: */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_b, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__3, __pyx_v_concept_roles); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_8, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_builder = __pyx_t_4; __pyx_t_4 = 0; /* "graphbrain/parsers/alpha_beta.pyx":184 * for concept in concepts] * builder = '+/b.{}/.'.format(''.join(concept_roles)) * return hedge(builder).connect(concepts) # <<<<<<<<<<<<<< * else: * return hedge((first[0], */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_hedge); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_v_builder) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_builder); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_connect); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_v_concepts) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_concepts); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":180 * def _compose_concepts(self, concepts): * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': # <<<<<<<<<<<<<< * concept_roles = [self._concept_role(concept) * for concept in concepts] */ } /* "graphbrain/parsers/alpha_beta.pyx":186 * return hedge(builder).connect(concepts) * else: * return hedge((first[0], # <<<<<<<<<<<<<< * self._compose_concepts(first[1:] + concepts[1:]))) * */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_hedge); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_first, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* "graphbrain/parsers/alpha_beta.pyx":187 * else: * return hedge((first[0], * self._compose_concepts(first[1:] + concepts[1:]))) # <<<<<<<<<<<<<< * * def _post_process(self, entity): */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compose_concepts); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetSlice(__pyx_v_first, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetSlice(__pyx_v_concepts, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = PyNumber_Add(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_8 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_11, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "graphbrain/parsers/alpha_beta.pyx":186 * return hedge(builder).connect(concepts) * else: * return hedge((first[0], # <<<<<<<<<<<<<< * self._compose_concepts(first[1:] + concepts[1:]))) * */ __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8); __pyx_t_1 = 0; __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; } /* "graphbrain/parsers/alpha_beta.pyx":178 * return build_atom(text, et, self.lang) * * def _compose_concepts(self, concepts): # <<<<<<<<<<<<<< * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._compose_concepts", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_first); __Pyx_XDECREF(__pyx_v_concept_roles); __Pyx_XDECREF(__pyx_v_builder); __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_concept); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":189 * self._compose_concepts(first[1:] + concepts[1:]))) * * def _post_process(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * token = self.atom2token.get(entity) */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_43_post_process(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_43_post_process = {"_post_process", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_43_post_process, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_43_post_process(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_entity = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_post_process (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_entity,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_entity)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_post_process", 1, 2, 2, 1); __PYX_ERR(0, 189, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_post_process") < 0)) __PYX_ERR(0, 189, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_entity = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_post_process", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 189, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._post_process", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_42_post_process(__pyx_self, __pyx_v_self, __pyx_v_entity); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_42_post_process(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_entity) { PyObject *__pyx_v_token = NULL; PyObject *__pyx_v_ent_type = NULL; PyObject *__pyx_v_temporal = NULL; PyObject *__pyx_v_temps = NULL; PyObject *__pyx_v_ct = NULL; PyObject *__pyx_v_ps = NULL; PyObject *__pyx_v_pred = NULL; PyObject *__pyx_v_role = NULL; PyObject *__pyx_v_arg_roles = NULL; PyObject *__pyx_v_proc_edge = NULL; PyObject *__pyx_v_trigger = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_arg_role = NULL; PyObject *__pyx_v_arg_pos = NULL; PyObject *__pyx_v_tedge = NULL; PyObject *__pyx_v_trigger_atom = NULL; PyObject *__pyx_v_triparts = NULL; PyObject *__pyx_v_newparts = NULL; PyObject *__pyx_8genexpr2__pyx_v_item = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; Py_ssize_t __pyx_t_6; PyObject *(*__pyx_t_7)(PyObject *); PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *(*__pyx_t_10)(PyObject *); int __pyx_t_11; Py_ssize_t __pyx_t_12; int __pyx_t_13; __Pyx_RefNannySetupContext("_post_process", 0); __Pyx_INCREF(__pyx_v_entity); /* "graphbrain/parsers/alpha_beta.pyx":190 * * def _post_process(self, entity): * if entity.is_atom(): # <<<<<<<<<<<<<< * token = self.atom2token.get(entity) * if token: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":191 * def _post_process(self, entity): * if entity.is_atom(): * token = self.atom2token.get(entity) # <<<<<<<<<<<<<< * if token: * ent_type = self.atom2token[entity].ent_type_ */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_atom2token); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_entity) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_entity); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_token = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":192 * if entity.is_atom(): * token = self.atom2token.get(entity) * if token: # <<<<<<<<<<<<<< * ent_type = self.atom2token[entity].ent_type_ * temporal = ent_type in {'DATE', 'TIME'} */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_token); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 192, __pyx_L1_error) if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":193 * token = self.atom2token.get(entity) * if token: * ent_type = self.atom2token[entity].ent_type_ # <<<<<<<<<<<<<< * temporal = ent_type in {'DATE', 'TIME'} * else: */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_atom2token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_entity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ent_type_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_ent_type = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":194 * if token: * ent_type = self.atom2token[entity].ent_type_ * temporal = ent_type in {'DATE', 'TIME'} # <<<<<<<<<<<<<< * else: * temporal = False */ __Pyx_INCREF(__pyx_v_ent_type); __pyx_t_1 = __pyx_v_ent_type; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_DATE, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 194, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L5_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_TIME, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 194, __pyx_L1_error) __pyx_t_4 = __pyx_t_5; __pyx_L5_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_temporal = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":192 * if entity.is_atom(): * token = self.atom2token.get(entity) * if token: # <<<<<<<<<<<<<< * ent_type = self.atom2token[entity].ent_type_ * temporal = ent_type in {'DATE', 'TIME'} */ goto __pyx_L4; } /* "graphbrain/parsers/alpha_beta.pyx":196 * temporal = ent_type in {'DATE', 'TIME'} * else: * temporal = False # <<<<<<<<<<<<<< * return entity, temporal * else: */ /*else*/ { __Pyx_INCREF(Py_False); __pyx_v_temporal = Py_False; } __pyx_L4:; /* "graphbrain/parsers/alpha_beta.pyx":197 * else: * temporal = False * return entity, temporal # <<<<<<<<<<<<<< * else: * entity, temps = zip(*[self._post_process(item) for item in entity]) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_entity); __Pyx_INCREF(__pyx_v_temporal); __Pyx_GIVEREF(__pyx_v_temporal); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_temporal); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":190 * * def _post_process(self, entity): * if entity.is_atom(): # <<<<<<<<<<<<<< * token = self.atom2token.get(entity) * if token: */ } /* "graphbrain/parsers/alpha_beta.pyx":199 * return entity, temporal * else: * entity, temps = zip(*[self._post_process(item) for item in entity]) # <<<<<<<<<<<<<< * entity = hedge(entity) * temporal = True in temps */ /*else*/ { { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_entity)) || PyTuple_CheckExact(__pyx_v_entity)) { __pyx_t_3 = __pyx_v_entity; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_entity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 199, __pyx_L9_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 199, __pyx_L9_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 199, __pyx_L9_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 199, __pyx_L9_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_item, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_process); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_2 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_8genexpr2__pyx_v_item) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_8genexpr2__pyx_v_item); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 199, __pyx_L9_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_item); __pyx_8genexpr2__pyx_v_item = 0; goto __pyx_L12_exit_scope; __pyx_L9_error:; __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_item); __pyx_8genexpr2__pyx_v_item = 0; goto __pyx_L1_error; __pyx_L12_exit_scope:; } /* exit inner scope */ __pyx_t_3 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 199, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_3)) goto __pyx_L13_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L13_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 2) < 0) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L14_unpacking_done; __pyx_L13_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 199, __pyx_L1_error) __pyx_L14_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_3); __pyx_t_3 = 0; __pyx_v_temps = __pyx_t_2; __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":200 * else: * entity, temps = zip(*[self._post_process(item) for item in entity]) * entity = hedge(entity) # <<<<<<<<<<<<<< * temporal = True in temps * ct = entity.connector_type() */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_hedge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_entity) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_entity); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":201 * entity, temps = zip(*[self._post_process(item) for item in entity]) * entity = hedge(entity) * temporal = True in temps # <<<<<<<<<<<<<< * ct = entity.connector_type() * */ __pyx_t_4 = (__Pyx_PySequence_ContainsTF(Py_True, __pyx_v_temps, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 201, __pyx_L1_error) __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_temporal = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":202 * entity = hedge(entity) * temporal = True in temps * ct = entity.connector_type() # <<<<<<<<<<<<<< * * # Multi-noun concept, e.g.: (south america) -> (+ south america) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_ct = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":205 * * # Multi-noun concept, e.g.: (south america) -> (+ south america) * if ct[0] == 'c': # <<<<<<<<<<<<<< * return self._compose_concepts(entity), temporal * */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":206 * # Multi-noun concept, e.g.: (south america) -> (+ south america) * if ct[0] == 'c': * return self._compose_concepts(entity), temporal # <<<<<<<<<<<<<< * * # Assign concept roles where possible */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compose_concepts); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_entity) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_entity); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_INCREF(__pyx_v_temporal); __Pyx_GIVEREF(__pyx_v_temporal); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_temporal); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":205 * * # Multi-noun concept, e.g.: (south america) -> (+ south america) * if ct[0] == 'c': # <<<<<<<<<<<<<< * return self._compose_concepts(entity), temporal * */ } /* "graphbrain/parsers/alpha_beta.pyx":211 * # e.g. (on/br referendum/c (gradual/m (nuclear/m phaseout/c))) -> * # (on/br.ma referendum/c (gradual/m (nuclear/m phaseout/c))) * elif ct[0] == 'b' and len(entity) == 3: # <<<<<<<<<<<<<< * return self._builder_arg_roles(entity), temporal * */ __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_b_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L16_bool_binop_done; } __pyx_t_6 = PyObject_Length(__pyx_v_entity); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 211, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_6 == 3) != 0); __pyx_t_4 = __pyx_t_5; __pyx_L16_bool_binop_done:; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":212 * # (on/br.ma referendum/c (gradual/m (nuclear/m phaseout/c))) * elif ct[0] == 'b' and len(entity) == 3: * return self._builder_arg_roles(entity), temporal # <<<<<<<<<<<<<< * * # Builders with one argument become modifiers */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_builder_arg_roles); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_entity) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_entity); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_INCREF(__pyx_v_temporal); __Pyx_GIVEREF(__pyx_v_temporal); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_temporal); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":211 * # e.g. (on/br referendum/c (gradual/m (nuclear/m phaseout/c))) -> * # (on/br.ma referendum/c (gradual/m (nuclear/m phaseout/c))) * elif ct[0] == 'b' and len(entity) == 3: # <<<<<<<<<<<<<< * return self._builder_arg_roles(entity), temporal * */ } /* "graphbrain/parsers/alpha_beta.pyx":216 * # Builders with one argument become modifiers * # e.g. (on/b ice) -> (on/m ice) * elif ct[0] == 'b' and entity[0].is_atom() and len(entity) == 2: # <<<<<<<<<<<<<< * ps = entity[0].parts() * ps[1] = 'm' + ct[1:] */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_b_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L18_bool_binop_done; } __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_entity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L18_bool_binop_done; } __pyx_t_6 = PyObject_Length(__pyx_v_entity); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 216, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_6 == 2) != 0); __pyx_t_4 = __pyx_t_5; __pyx_L18_bool_binop_done:; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":217 * # e.g. (on/b ice) -> (on/m ice) * elif ct[0] == 'b' and entity[0].is_atom() and len(entity) == 2: * ps = entity[0].parts() # <<<<<<<<<<<<<< * ps[1] = 'm' + ct[1:] * return hedge(('/'.join(ps),) + entity[1:]), temporal */ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_entity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_parts); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_ps = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":218 * elif ct[0] == 'b' and entity[0].is_atom() and len(entity) == 2: * ps = entity[0].parts() * ps[1] = 'm' + ct[1:] # <<<<<<<<<<<<<< * return hedge(('/'.join(ps),) + entity[1:]), temporal * */ __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_ct, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Add(__pyx_n_u_m, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__Pyx_SetItemInt(__pyx_v_ps, 1, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":219 * ps = entity[0].parts() * ps[1] = 'm' + ct[1:] * return hedge(('/'.join(ps),) + entity[1:]), temporal # <<<<<<<<<<<<<< * * # A meta-modifier applied to a concept defined my a modifier */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_hedge); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__7, __pyx_v_ps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_entity, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_INCREF(__pyx_v_temporal); __Pyx_GIVEREF(__pyx_v_temporal); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_temporal); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":216 * # Builders with one argument become modifiers * # e.g. (on/b ice) -> (on/m ice) * elif ct[0] == 'b' and entity[0].is_atom() and len(entity) == 2: # <<<<<<<<<<<<<< * ps = entity[0].parts() * ps[1] = 'm' + ct[1:] */ } /* "graphbrain/parsers/alpha_beta.pyx":224 * # should apply to the modifier instead. * # e.g.: (stricking/w (red/m dress)) -> ((stricking/w red/m) dress) * elif (ct[0] == 'w' and # <<<<<<<<<<<<<< * entity[0].is_atom() and * len(entity) == 2 and */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_w, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L21_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":225 * # e.g.: (stricking/w (red/m dress)) -> ((stricking/w red/m) dress) * elif (ct[0] == 'w' and * entity[0].is_atom() and # <<<<<<<<<<<<<< * len(entity) == 2 and * not entity[1].is_atom() and */ __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_entity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_9); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L21_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":226 * elif (ct[0] == 'w' and * entity[0].is_atom() and * len(entity) == 2 and # <<<<<<<<<<<<<< * not entity[1].is_atom() and * entity[1].connector_type()[0] == 'm'): */ __pyx_t_6 = PyObject_Length(__pyx_v_entity); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 226, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_6 == 2) != 0); if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L21_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":227 * entity[0].is_atom() and * len(entity) == 2 and * not entity[1].is_atom() and # <<<<<<<<<<<<<< * entity[1].connector_type()[0] == 'm'): * return (hedge(((entity[0], entity[1][0]),) + entity[1][1:]), */ __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_entity, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = ((!__pyx_t_5) != 0); if (__pyx_t_11) { } else { __pyx_t_4 = __pyx_t_11; goto __pyx_L21_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":228 * len(entity) == 2 and * not entity[1].is_atom() and * entity[1].connector_type()[0] == 'm'): # <<<<<<<<<<<<<< * return (hedge(((entity[0], entity[1][0]),) + entity[1][1:]), * temporal) */ __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_entity, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_9); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_m, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_4 = __pyx_t_11; __pyx_L21_bool_binop_done:; /* "graphbrain/parsers/alpha_beta.pyx":224 * # should apply to the modifier instead. * # e.g.: (stricking/w (red/m dress)) -> ((stricking/w red/m) dress) * elif (ct[0] == 'w' and # <<<<<<<<<<<<<< * entity[0].is_atom() and * len(entity) == 2 and */ if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":229 * not entity[1].is_atom() and * entity[1].connector_type()[0] == 'm'): * return (hedge(((entity[0], entity[1][0]),) + entity[1][1:]), # <<<<<<<<<<<<<< * temporal) * */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_hedge); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_entity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_entity, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); __pyx_t_2 = 0; __pyx_t_8 = 0; __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_entity, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_3, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_9 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":230 * entity[1].connector_type()[0] == 'm'): * return (hedge(((entity[0], entity[1][0]),) + entity[1][1:]), * temporal) # <<<<<<<<<<<<<< * * # Make sure that specifier arguments are of the specifier type, */ __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __Pyx_INCREF(__pyx_v_temporal); __Pyx_GIVEREF(__pyx_v_temporal); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_temporal); __pyx_t_9 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":224 * # should apply to the modifier instead. * # e.g.: (stricking/w (red/m dress)) -> ((stricking/w red/m) dress) * elif (ct[0] == 'w' and # <<<<<<<<<<<<<< * entity[0].is_atom() and * len(entity) == 2 and */ } /* "graphbrain/parsers/alpha_beta.pyx":235 * # entities are surrounded by an edge with a trigger connector * # if necessary. E.g.: today -> {t/t/. today} * elif ct[0] == 'p': # <<<<<<<<<<<<<< * pred = entity.predicate() * if pred: */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":236 * # if necessary. E.g.: today -> {t/t/. today} * elif ct[0] == 'p': * pred = entity.predicate() # <<<<<<<<<<<<<< * if pred: * role = pred.role() */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_predicate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_pred = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":237 * elif ct[0] == 'p': * pred = entity.predicate() * if pred: # <<<<<<<<<<<<<< * role = pred.role() * if len(role) > 2: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_pred); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 237, __pyx_L1_error) if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":238 * pred = entity.predicate() * if pred: * role = pred.role() # <<<<<<<<<<<<<< * if len(role) > 2: * arg_roles = role[2] */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_role); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_role = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":239 * if pred: * role = pred.role() * if len(role) > 2: # <<<<<<<<<<<<<< * arg_roles = role[2] * if 'x' in arg_roles: */ __pyx_t_6 = PyObject_Length(__pyx_v_role); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 239, __pyx_L1_error) __pyx_t_4 = ((__pyx_t_6 > 2) != 0); if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":240 * role = pred.role() * if len(role) > 2: * arg_roles = role[2] # <<<<<<<<<<<<<< * if 'x' in arg_roles: * proc_edge = list(entity) */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_role, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_roles = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":241 * if len(role) > 2: * arg_roles = role[2] * if 'x' in arg_roles: # <<<<<<<<<<<<<< * proc_edge = list(entity) * trigger = 't/tt/.' if temporal else 't/t/.' */ __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_x, __pyx_v_arg_roles, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 241, __pyx_L1_error) __pyx_t_11 = (__pyx_t_4 != 0); if (__pyx_t_11) { /* "graphbrain/parsers/alpha_beta.pyx":242 * arg_roles = role[2] * if 'x' in arg_roles: * proc_edge = list(entity) # <<<<<<<<<<<<<< * trigger = 't/tt/.' if temporal else 't/t/.' * for i, arg_role in enumerate(arg_roles): */ __pyx_t_1 = PySequence_List(__pyx_v_entity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_proc_edge = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":243 * if 'x' in arg_roles: * proc_edge = list(entity) * trigger = 't/tt/.' if temporal else 't/t/.' # <<<<<<<<<<<<<< * for i, arg_role in enumerate(arg_roles): * arg_pos = i + 1 */ __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_temporal); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 243, __pyx_L1_error) if (__pyx_t_11) { __Pyx_INCREF(__pyx_kp_u_t_tt); __pyx_t_1 = __pyx_kp_u_t_tt; } else { __Pyx_INCREF(__pyx_kp_u_t_t); __pyx_t_1 = __pyx_kp_u_t_t; } __pyx_v_trigger = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":244 * proc_edge = list(entity) * trigger = 't/tt/.' if temporal else 't/t/.' * for i, arg_role in enumerate(arg_roles): # <<<<<<<<<<<<<< * arg_pos = i + 1 * if (arg_role == 'x' and */ __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_arg_roles)) || PyTuple_CheckExact(__pyx_v_arg_roles)) { __pyx_t_9 = __pyx_v_arg_roles; __Pyx_INCREF(__pyx_t_9); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_arg_roles); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 244, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_9))) { if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 244, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 244, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 244, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_arg_role, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1); __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":245 * trigger = 't/tt/.' if temporal else 't/t/.' * for i, arg_role in enumerate(arg_roles): * arg_pos = i + 1 # <<<<<<<<<<<<<< * if (arg_role == 'x' and * arg_pos < len(proc_edge) and */ __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_arg_pos, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":246 * for i, arg_role in enumerate(arg_roles): * arg_pos = i + 1 * if (arg_role == 'x' and # <<<<<<<<<<<<<< * arg_pos < len(proc_edge) and * proc_edge[arg_pos].is_atom()): */ __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_arg_role, __pyx_n_u_x, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 246, __pyx_L1_error) if (__pyx_t_4) { } else { __pyx_t_11 = __pyx_t_4; goto __pyx_L32_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":247 * arg_pos = i + 1 * if (arg_role == 'x' and * arg_pos < len(proc_edge) and # <<<<<<<<<<<<<< * proc_edge[arg_pos].is_atom()): * tedge = (hedge(trigger), */ __pyx_t_12 = PyList_GET_SIZE(__pyx_v_proc_edge); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 247, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyObject_RichCompare(__pyx_v_arg_pos, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_4) { } else { __pyx_t_11 = __pyx_t_4; goto __pyx_L32_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":248 * if (arg_role == 'x' and * arg_pos < len(proc_edge) and * proc_edge[arg_pos].is_atom()): # <<<<<<<<<<<<<< * tedge = (hedge(trigger), * proc_edge[arg_pos]) */ __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_proc_edge, __pyx_v_arg_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_8); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = __pyx_t_4; __pyx_L32_bool_binop_done:; /* "graphbrain/parsers/alpha_beta.pyx":246 * for i, arg_role in enumerate(arg_roles): * arg_pos = i + 1 * if (arg_role == 'x' and # <<<<<<<<<<<<<< * arg_pos < len(proc_edge) and * proc_edge[arg_pos].is_atom()): */ if (__pyx_t_11) { /* "graphbrain/parsers/alpha_beta.pyx":249 * arg_pos < len(proc_edge) and * proc_edge[arg_pos].is_atom()): * tedge = (hedge(trigger), # <<<<<<<<<<<<<< * proc_edge[arg_pos]) * proc_edge[arg_pos] = hedge(tedge) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_hedge); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_v_trigger) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_trigger); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":250 * proc_edge[arg_pos].is_atom()): * tedge = (hedge(trigger), * proc_edge[arg_pos]) # <<<<<<<<<<<<<< * proc_edge[arg_pos] = hedge(tedge) * return hedge(proc_edge), False */ __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_proc_edge, __pyx_v_arg_pos); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); /* "graphbrain/parsers/alpha_beta.pyx":249 * arg_pos < len(proc_edge) and * proc_edge[arg_pos].is_atom()): * tedge = (hedge(trigger), # <<<<<<<<<<<<<< * proc_edge[arg_pos]) * proc_edge[arg_pos] = hedge(tedge) */ __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); __pyx_t_2 = 0; __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_tedge, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":251 * tedge = (hedge(trigger), * proc_edge[arg_pos]) * proc_edge[arg_pos] = hedge(tedge) # <<<<<<<<<<<<<< * return hedge(proc_edge), False * return entity, temporal */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_hedge); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, __pyx_v_tedge) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_tedge); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(PyObject_SetItem(__pyx_v_proc_edge, __pyx_v_arg_pos, __pyx_t_3) < 0)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":246 * for i, arg_role in enumerate(arg_roles): * arg_pos = i + 1 * if (arg_role == 'x' and # <<<<<<<<<<<<<< * arg_pos < len(proc_edge) and * proc_edge[arg_pos].is_atom()): */ } /* "graphbrain/parsers/alpha_beta.pyx":244 * proc_edge = list(entity) * trigger = 't/tt/.' if temporal else 't/t/.' * for i, arg_role in enumerate(arg_roles): # <<<<<<<<<<<<<< * arg_pos = i + 1 * if (arg_role == 'x' and */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":252 * proc_edge[arg_pos]) * proc_edge[arg_pos] = hedge(tedge) * return hedge(proc_edge), False # <<<<<<<<<<<<<< * return entity, temporal * */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_hedge); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_3, __pyx_v_proc_edge) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_proc_edge); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __Pyx_INCREF(Py_False); __Pyx_GIVEREF(Py_False); PyTuple_SET_ITEM(__pyx_t_9, 1, Py_False); __pyx_t_1 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":241 * if len(role) > 2: * arg_roles = role[2] * if 'x' in arg_roles: # <<<<<<<<<<<<<< * proc_edge = list(entity) * trigger = 't/tt/.' if temporal else 't/t/.' */ } /* "graphbrain/parsers/alpha_beta.pyx":239 * if pred: * role = pred.role() * if len(role) > 2: # <<<<<<<<<<<<<< * arg_roles = role[2] * if 'x' in arg_roles: */ } /* "graphbrain/parsers/alpha_beta.pyx":237 * elif ct[0] == 'p': * pred = entity.predicate() * if pred: # <<<<<<<<<<<<<< * role = pred.role() * if len(role) > 2: */ } /* "graphbrain/parsers/alpha_beta.pyx":253 * proc_edge[arg_pos] = hedge(tedge) * return hedge(proc_edge), False * return entity, temporal # <<<<<<<<<<<<<< * * # Make triggers temporal, if appropriate. */ __Pyx_XDECREF(__pyx_r); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_entity); __Pyx_INCREF(__pyx_v_temporal); __Pyx_GIVEREF(__pyx_v_temporal); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_temporal); __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":235 * # entities are surrounded by an edge with a trigger connector * # if necessary. E.g.: today -> {t/t/. today} * elif ct[0] == 'p': # <<<<<<<<<<<<<< * pred = entity.predicate() * if pred: */ } /* "graphbrain/parsers/alpha_beta.pyx":257 * # Make triggers temporal, if appropriate. * # e.g.: (in/t 1976) -> (in/tt 1976) * elif ct[0] == 't': # <<<<<<<<<<<<<< * if temporal: * trigger_atom = entity[0].atom_with_type('t') */ __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_t, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_11) { /* "graphbrain/parsers/alpha_beta.pyx":258 * # e.g.: (in/t 1976) -> (in/tt 1976) * elif ct[0] == 't': * if temporal: # <<<<<<<<<<<<<< * trigger_atom = entity[0].atom_with_type('t') * triparts = trigger_atom.parts() */ __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_temporal); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 258, __pyx_L1_error) if (__pyx_t_11) { /* "graphbrain/parsers/alpha_beta.pyx":259 * elif ct[0] == 't': * if temporal: * trigger_atom = entity[0].atom_with_type('t') # <<<<<<<<<<<<<< * triparts = trigger_atom.parts() * newparts = (triparts[0], 'tt') */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_entity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_atom_with_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_n_u_t) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_n_u_t); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_trigger_atom = __pyx_t_9; __pyx_t_9 = 0; /* "graphbrain/parsers/alpha_beta.pyx":260 * if temporal: * trigger_atom = entity[0].atom_with_type('t') * triparts = trigger_atom.parts() # <<<<<<<<<<<<<< * newparts = (triparts[0], 'tt') * if len(triparts) > 2: */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_trigger_atom, __pyx_n_s_parts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_triparts = __pyx_t_9; __pyx_t_9 = 0; /* "graphbrain/parsers/alpha_beta.pyx":261 * trigger_atom = entity[0].atom_with_type('t') * triparts = trigger_atom.parts() * newparts = (triparts[0], 'tt') # <<<<<<<<<<<<<< * if len(triparts) > 2: * newparts += tuple(triparts[2:]) */ __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_triparts, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __Pyx_INCREF(__pyx_n_u_tt); __Pyx_GIVEREF(__pyx_n_u_tt); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_u_tt); __pyx_t_9 = 0; __pyx_v_newparts = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":262 * triparts = trigger_atom.parts() * newparts = (triparts[0], 'tt') * if len(triparts) > 2: # <<<<<<<<<<<<<< * newparts += tuple(triparts[2:]) * trigger = hedge('/'.join(newparts)) */ __pyx_t_6 = PyObject_Length(__pyx_v_triparts); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 262, __pyx_L1_error) __pyx_t_11 = ((__pyx_t_6 > 2) != 0); if (__pyx_t_11) { /* "graphbrain/parsers/alpha_beta.pyx":263 * newparts = (triparts[0], 'tt') * if len(triparts) > 2: * newparts += tuple(triparts[2:]) # <<<<<<<<<<<<<< * trigger = hedge('/'.join(newparts)) * entity = entity.replace_atom(trigger_atom, trigger) */ __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_triparts, 2, 0, NULL, NULL, &__pyx_slice_, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_newparts, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_newparts, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":262 * triparts = trigger_atom.parts() * newparts = (triparts[0], 'tt') * if len(triparts) > 2: # <<<<<<<<<<<<<< * newparts += tuple(triparts[2:]) * trigger = hedge('/'.join(newparts)) */ } /* "graphbrain/parsers/alpha_beta.pyx":264 * if len(triparts) > 2: * newparts += tuple(triparts[2:]) * trigger = hedge('/'.join(newparts)) # <<<<<<<<<<<<<< * entity = entity.replace_atom(trigger_atom, trigger) * return entity, False */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_hedge); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__7, __pyx_v_newparts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_1); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_trigger = __pyx_t_3; __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":265 * newparts += tuple(triparts[2:]) * trigger = hedge('/'.join(newparts)) * entity = entity.replace_atom(trigger_atom, trigger) # <<<<<<<<<<<<<< * return entity, False * else: */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_replace_atom); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = NULL; __pyx_t_13 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_13 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_trigger_atom, __pyx_v_trigger}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_trigger_atom, __pyx_v_trigger}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_INCREF(__pyx_v_trigger_atom); __Pyx_GIVEREF(__pyx_v_trigger_atom); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_13, __pyx_v_trigger_atom); __Pyx_INCREF(__pyx_v_trigger); __Pyx_GIVEREF(__pyx_v_trigger); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_13, __pyx_v_trigger); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":258 * # e.g.: (in/t 1976) -> (in/tt 1976) * elif ct[0] == 't': * if temporal: # <<<<<<<<<<<<<< * trigger_atom = entity[0].atom_with_type('t') * triparts = trigger_atom.parts() */ } /* "graphbrain/parsers/alpha_beta.pyx":266 * trigger = hedge('/'.join(newparts)) * entity = entity.replace_atom(trigger_atom, trigger) * return entity, False # <<<<<<<<<<<<<< * else: * return entity, temporal */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_entity); __Pyx_INCREF(Py_False); __Pyx_GIVEREF(Py_False); PyTuple_SET_ITEM(__pyx_t_3, 1, Py_False); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":257 * # Make triggers temporal, if appropriate. * # e.g.: (in/t 1976) -> (in/tt 1976) * elif ct[0] == 't': # <<<<<<<<<<<<<< * if temporal: * trigger_atom = entity[0].atom_with_type('t') */ } /* "graphbrain/parsers/alpha_beta.pyx":268 * return entity, False * else: * return entity, temporal # <<<<<<<<<<<<<< * * def _before_parse_sentence(self): */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_entity); __Pyx_INCREF(__pyx_v_temporal); __Pyx_GIVEREF(__pyx_v_temporal); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_temporal); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; } } /* "graphbrain/parsers/alpha_beta.pyx":189 * self._compose_concepts(first[1:] + concepts[1:]))) * * def _post_process(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * token = self.atom2token.get(entity) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._post_process", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_token); __Pyx_XDECREF(__pyx_v_ent_type); __Pyx_XDECREF(__pyx_v_temporal); __Pyx_XDECREF(__pyx_v_temps); __Pyx_XDECREF(__pyx_v_ct); __Pyx_XDECREF(__pyx_v_ps); __Pyx_XDECREF(__pyx_v_pred); __Pyx_XDECREF(__pyx_v_role); __Pyx_XDECREF(__pyx_v_arg_roles); __Pyx_XDECREF(__pyx_v_proc_edge); __Pyx_XDECREF(__pyx_v_trigger); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_arg_role); __Pyx_XDECREF(__pyx_v_arg_pos); __Pyx_XDECREF(__pyx_v_tedge); __Pyx_XDECREF(__pyx_v_trigger_atom); __Pyx_XDECREF(__pyx_v_triparts); __Pyx_XDECREF(__pyx_v_newparts); __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_item); __Pyx_XDECREF(__pyx_v_entity); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":270 * return entity, temporal * * def _before_parse_sentence(self): # <<<<<<<<<<<<<< * self.extra_edges = set() * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_45_before_parse_sentence(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_45_before_parse_sentence = {"_before_parse_sentence", (PyCFunction)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_45_before_parse_sentence, METH_O, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_45_before_parse_sentence(PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_before_parse_sentence (wrapper)", 0); __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_44_before_parse_sentence(__pyx_self, ((PyObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_44_before_parse_sentence(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_before_parse_sentence", 0); /* "graphbrain/parsers/alpha_beta.pyx":271 * * def _before_parse_sentence(self): * self.extra_edges = set() # <<<<<<<<<<<<<< * * def _parse_token_children(self, token): */ __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_extra_edges, __pyx_t_1) < 0) __PYX_ERR(0, 271, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":270 * return entity, temporal * * def _before_parse_sentence(self): # <<<<<<<<<<<<<< * self.extra_edges = set() * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._before_parse_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":273 * self.extra_edges = set() * * def _parse_token_children(self, token): # <<<<<<<<<<<<<< * children = [] * token_dict = {} */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_47_parse_token_children(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_47_parse_token_children = {"_parse_token_children", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_47_parse_token_children, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_47_parse_token_children(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_parse_token_children (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_parse_token_children", 1, 2, 2, 1); __PYX_ERR(0, 273, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_token_children") < 0)) __PYX_ERR(0, 273, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_parse_token_children", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 273, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._parse_token_children", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_46_parse_token_children(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_46_parse_token_children(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token) { PyObject *__pyx_v_children = NULL; PyObject *__pyx_v_token_dict = NULL; PyObject *__pyx_v_pos_dict = NULL; PyObject *__pyx_v_child_tokens = NULL; PyObject *__pyx_v_child_token = NULL; PyObject *__pyx_v_pos = NULL; PyObject *__pyx_v_child = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_child_type = NULL; PyObject *__pyx_v_last_token = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; PyObject *(*__pyx_t_7)(PyObject *); int __pyx_t_8; int __pyx_t_9; __Pyx_RefNannySetupContext("_parse_token_children", 0); /* "graphbrain/parsers/alpha_beta.pyx":274 * * def _parse_token_children(self, token): * children = [] # <<<<<<<<<<<<<< * token_dict = {} * pos_dict = {} */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_children = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":275 * def _parse_token_children(self, token): * children = [] * token_dict = {} # <<<<<<<<<<<<<< * pos_dict = {} * */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_token_dict = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":276 * children = [] * token_dict = {} * pos_dict = {} # <<<<<<<<<<<<<< * * child_tokens = (tuple(zip(token.lefts, repeat(True))) + */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_pos_dict = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":278 * pos_dict = {} * * child_tokens = (tuple(zip(token.lefts, repeat(True))) + # <<<<<<<<<<<<<< * tuple(zip(token.rights, repeat(False)))) * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_lefts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_repeat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, Py_True) : __Pyx_PyObject_CallOneArg(__pyx_t_3, Py_True); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":279 * * child_tokens = (tuple(zip(token.lefts, repeat(True))) + * tuple(zip(token.rights, repeat(False)))) # <<<<<<<<<<<<<< * * for child_token, pos in child_tokens: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_rights); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_repeat); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, Py_False) : __Pyx_PyObject_CallOneArg(__pyx_t_4, Py_False); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":278 * pos_dict = {} * * child_tokens = (tuple(zip(token.lefts, repeat(True))) + # <<<<<<<<<<<<<< * tuple(zip(token.rights, repeat(False)))) * */ __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_child_tokens = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":281 * tuple(zip(token.rights, repeat(False)))) * * for child_token, pos in child_tokens: # <<<<<<<<<<<<<< * child, _ = self._parse_token(child_token) * if child: */ __pyx_t_1 = __pyx_v_child_tokens; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; for (;;) { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 281, __pyx_L1_error) #else __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 281, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_2 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_5), 2) < 0) __PYX_ERR(0, 281, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 281, __pyx_L1_error) __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_child_token, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":282 * * for child_token, pos in child_tokens: * child, _ = self._parse_token(child_token) # <<<<<<<<<<<<<< * if child: * child_type = child.type() */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_token); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_child_token) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_child_token); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 282, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_5), 2) < 0) __PYX_ERR(0, 282, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 282, __pyx_L1_error) __pyx_L8_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_child, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":283 * for child_token, pos in child_tokens: * child, _ = self._parse_token(child_token) * if child: # <<<<<<<<<<<<<< * child_type = child.type() * if child_type: */ __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_child); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 283, __pyx_L1_error) if (__pyx_t_8) { /* "graphbrain/parsers/alpha_beta.pyx":284 * child, _ = self._parse_token(child_token) * if child: * child_type = child.type() # <<<<<<<<<<<<<< * if child_type: * children.append(child) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_child_type, __pyx_t_4); __pyx_t_4 = 0; /* "graphbrain/parsers/alpha_beta.pyx":285 * if child: * child_type = child.type() * if child_type: # <<<<<<<<<<<<<< * children.append(child) * token_dict[child] = child_token */ __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_child_type); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 285, __pyx_L1_error) if (__pyx_t_8) { /* "graphbrain/parsers/alpha_beta.pyx":286 * child_type = child.type() * if child_type: * children.append(child) # <<<<<<<<<<<<<< * token_dict[child] = child_token * pos_dict[child] = pos */ __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_children, __pyx_v_child); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 286, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":287 * if child_type: * children.append(child) * token_dict[child] = child_token # <<<<<<<<<<<<<< * pos_dict[child] = pos * */ if (unlikely(PyDict_SetItem(__pyx_v_token_dict, __pyx_v_child, __pyx_v_child_token) < 0)) __PYX_ERR(0, 287, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":288 * children.append(child) * token_dict[child] = child_token * pos_dict[child] = pos # <<<<<<<<<<<<<< * * children.reverse() */ if (unlikely(PyDict_SetItem(__pyx_v_pos_dict, __pyx_v_child, __pyx_v_pos) < 0)) __PYX_ERR(0, 288, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":285 * if child: * child_type = child.type() * if child_type: # <<<<<<<<<<<<<< * children.append(child) * token_dict[child] = child_token */ } /* "graphbrain/parsers/alpha_beta.pyx":283 * for child_token, pos in child_tokens: * child, _ = self._parse_token(child_token) * if child: # <<<<<<<<<<<<<< * child_type = child.type() * if child_type: */ } /* "graphbrain/parsers/alpha_beta.pyx":281 * tuple(zip(token.rights, repeat(False)))) * * for child_token, pos in child_tokens: # <<<<<<<<<<<<<< * child, _ = self._parse_token(child_token) * if child: */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":290 * pos_dict[child] = pos * * children.reverse() # <<<<<<<<<<<<<< * * if len(child_tokens) > 0: */ __pyx_t_9 = PyList_Reverse(__pyx_v_children); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":292 * children.reverse() * * if len(child_tokens) > 0: # <<<<<<<<<<<<<< * last_token = child_tokens[-1][0] * else: */ __pyx_t_6 = PyTuple_GET_SIZE(__pyx_v_child_tokens); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 292, __pyx_L1_error) __pyx_t_8 = ((__pyx_t_6 > 0) != 0); if (__pyx_t_8) { /* "graphbrain/parsers/alpha_beta.pyx":293 * * if len(child_tokens) > 0: * last_token = child_tokens[-1][0] # <<<<<<<<<<<<<< * else: * last_token = None */ __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_child_tokens, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_last_token = __pyx_t_4; __pyx_t_4 = 0; /* "graphbrain/parsers/alpha_beta.pyx":292 * children.reverse() * * if len(child_tokens) > 0: # <<<<<<<<<<<<<< * last_token = child_tokens[-1][0] * else: */ goto __pyx_L11; } /* "graphbrain/parsers/alpha_beta.pyx":295 * last_token = child_tokens[-1][0] * else: * last_token = None # <<<<<<<<<<<<<< * * return children, token_dict, pos_dict, last_token */ /*else*/ { __Pyx_INCREF(Py_None); __pyx_v_last_token = Py_None; } __pyx_L11:; /* "graphbrain/parsers/alpha_beta.pyx":297 * last_token = None * * return children, token_dict, pos_dict, last_token # <<<<<<<<<<<<<< * * def _add_lemmas(self, token, entity, ent_type): */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_children); __Pyx_GIVEREF(__pyx_v_children); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_children); __Pyx_INCREF(__pyx_v_token_dict); __Pyx_GIVEREF(__pyx_v_token_dict); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_token_dict); __Pyx_INCREF(__pyx_v_pos_dict); __Pyx_GIVEREF(__pyx_v_pos_dict); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_pos_dict); __Pyx_INCREF(__pyx_v_last_token); __Pyx_GIVEREF(__pyx_v_last_token); PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_last_token); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":273 * self.extra_edges = set() * * def _parse_token_children(self, token): # <<<<<<<<<<<<<< * children = [] * token_dict = {} */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._parse_token_children", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_children); __Pyx_XDECREF(__pyx_v_token_dict); __Pyx_XDECREF(__pyx_v_pos_dict); __Pyx_XDECREF(__pyx_v_child_tokens); __Pyx_XDECREF(__pyx_v_child_token); __Pyx_XDECREF(__pyx_v_pos); __Pyx_XDECREF(__pyx_v_child); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_child_type); __Pyx_XDECREF(__pyx_v_last_token); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":299 * return children, token_dict, pos_dict, last_token * * def _add_lemmas(self, token, entity, ent_type): # <<<<<<<<<<<<<< * text = token.lemma_.lower() * if text != token.text.lower(): */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_49_add_lemmas(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_49_add_lemmas = {"_add_lemmas", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_49_add_lemmas, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_49_add_lemmas(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_v_entity = 0; PyObject *__pyx_v_ent_type = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_add_lemmas (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,&__pyx_n_s_entity,&__pyx_n_s_ent_type,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_add_lemmas", 1, 4, 4, 1); __PYX_ERR(0, 299, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_entity)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_add_lemmas", 1, 4, 4, 2); __PYX_ERR(0, 299, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ent_type)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_add_lemmas", 1, 4, 4, 3); __PYX_ERR(0, 299, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_add_lemmas") < 0)) __PYX_ERR(0, 299, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; __pyx_v_entity = values[2]; __pyx_v_ent_type = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_add_lemmas", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 299, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._add_lemmas", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_48_add_lemmas(__pyx_self, __pyx_v_self, __pyx_v_token, __pyx_v_entity, __pyx_v_ent_type); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_48_add_lemmas(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token, PyObject *__pyx_v_entity, PyObject *__pyx_v_ent_type) { PyObject *__pyx_v_text = NULL; PyObject *__pyx_v_lemma = NULL; PyObject *__pyx_v_lemma_edge = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("_add_lemmas", 0); /* "graphbrain/parsers/alpha_beta.pyx":300 * * def _add_lemmas(self, token, entity, ent_type): * text = token.lemma_.lower() # <<<<<<<<<<<<<< * if text != token.text.lower(): * lemma = build_atom(text, ent_type[0], self.lang) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_lemma); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_text = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":301 * def _add_lemmas(self, token, entity, ent_type): * text = token.lemma_.lower() * if text != token.text.lower(): # <<<<<<<<<<<<<< * lemma = build_atom(text, ent_type[0], self.lang) * lemma_edge = hedge((const.lemma_pred, entity, lemma)) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_token, __pyx_n_s_text); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_v_text, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":302 * text = token.lemma_.lower() * if text != token.text.lower(): * lemma = build_atom(text, ent_type[0], self.lang) # <<<<<<<<<<<<<< * lemma_edge = hedge((const.lemma_pred, entity, lemma)) * self.extra_edges.add(lemma_edge) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_build_atom); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_ent_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lang); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_text, __pyx_t_3, __pyx_t_5}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_text, __pyx_t_3, __pyx_t_5}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_text); __Pyx_GIVEREF(__pyx_v_text); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_text); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_lemma = __pyx_t_2; __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":303 * if text != token.text.lower(): * lemma = build_atom(text, ent_type[0], self.lang) * lemma_edge = hedge((const.lemma_pred, entity, lemma)) # <<<<<<<<<<<<<< * self.extra_edges.add(lemma_edge) * */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_hedge); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_const); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_lemma_pred); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_entity); __Pyx_INCREF(__pyx_v_lemma); __Pyx_GIVEREF(__pyx_v_lemma); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_lemma); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_lemma_edge = __pyx_t_2; __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":304 * lemma = build_atom(text, ent_type[0], self.lang) * lemma_edge = hedge((const.lemma_pred, entity, lemma)) * self.extra_edges.add(lemma_edge) # <<<<<<<<<<<<<< * * def _is_post_parse_token_necessary(self, entity): */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_extra_edges); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_add); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_1, __pyx_v_lemma_edge) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_lemma_edge); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":301 * def _add_lemmas(self, token, entity, ent_type): * text = token.lemma_.lower() * if text != token.text.lower(): # <<<<<<<<<<<<<< * lemma = build_atom(text, ent_type[0], self.lang) * lemma_edge = hedge((const.lemma_pred, entity, lemma)) */ } /* "graphbrain/parsers/alpha_beta.pyx":299 * return children, token_dict, pos_dict, last_token * * def _add_lemmas(self, token, entity, ent_type): # <<<<<<<<<<<<<< * text = token.lemma_.lower() * if text != token.text.lower(): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._add_lemmas", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_text); __Pyx_XDECREF(__pyx_v_lemma); __Pyx_XDECREF(__pyx_v_lemma_edge); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":306 * self.extra_edges.add(lemma_edge) * * def _is_post_parse_token_necessary(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * return False */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_51_is_post_parse_token_necessary(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_51_is_post_parse_token_necessary = {"_is_post_parse_token_necessary", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_51_is_post_parse_token_necessary, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_51_is_post_parse_token_necessary(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_entity = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_is_post_parse_token_necessary (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_entity,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_entity)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_is_post_parse_token_necessary", 1, 2, 2, 1); __PYX_ERR(0, 306, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_is_post_parse_token_necessary") < 0)) __PYX_ERR(0, 306, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_entity = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_is_post_parse_token_necessary", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 306, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_post_parse_token_necessary", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_50_is_post_parse_token_necessary(__pyx_self, __pyx_v_self, __pyx_v_entity); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_50_is_post_parse_token_necessary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_entity) { PyObject *__pyx_v_ct = NULL; PyObject *__pyx_v_pred = NULL; PyObject *__pyx_v_subparts = NULL; PyObject *__pyx_8genexpr3__pyx_v_subentity = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; Py_ssize_t __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("_is_post_parse_token_necessary", 0); /* "graphbrain/parsers/alpha_beta.pyx":307 * * def _is_post_parse_token_necessary(self, entity): * if entity.is_atom(): # <<<<<<<<<<<<<< * return False * else: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_is_atom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":308 * def _is_post_parse_token_necessary(self, entity): * if entity.is_atom(): * return False # <<<<<<<<<<<<<< * else: * ct = entity.connector_type() */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":307 * * def _is_post_parse_token_necessary(self, entity): * if entity.is_atom(): # <<<<<<<<<<<<<< * return False * else: */ } /* "graphbrain/parsers/alpha_beta.pyx":310 * return False * else: * ct = entity.connector_type() # <<<<<<<<<<<<<< * if ct[0] == 'p': * # Extend predicate atom with argument types */ /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_ct = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":311 * else: * ct = entity.connector_type() * if ct[0] == 'p': # <<<<<<<<<<<<<< * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 311, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":313 * if ct[0] == 'p': * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': # <<<<<<<<<<<<<< * pred = entity.atom_with_type('p') * subparts = pred.parts()[1].split('.') */ __pyx_t_5 = PyObject_Length(__pyx_v_ct); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 313, __pyx_L1_error) __pyx_t_6 = ((__pyx_t_5 < 2) != 0); if (!__pyx_t_6) { } else { __pyx_t_4 = __pyx_t_6; goto __pyx_L6_bool_binop_done; } __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_m, Py_NE)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 313, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __pyx_t_6; __pyx_L6_bool_binop_done:; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":314 * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': * pred = entity.atom_with_type('p') # <<<<<<<<<<<<<< * subparts = pred.parts()[1].split('.') * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_atom_with_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_u_p) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_p); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_pred = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":315 * if len(ct) < 2 or ct[1] != 'm': * pred = entity.atom_with_type('p') * subparts = pred.parts()[1].split('.') # <<<<<<<<<<<<<< * * if subparts[1] == '': */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_parts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u__4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_subparts = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":317 * subparts = pred.parts()[1].split('.') * * if subparts[1] == '': # <<<<<<<<<<<<<< * return True * */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_subparts, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_kp_u__3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":318 * * if subparts[1] == '': * return True # <<<<<<<<<<<<<< * * return any([self._is_post_parse_token_necessary(subentity) */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":317 * subparts = pred.parts()[1].split('.') * * if subparts[1] == '': # <<<<<<<<<<<<<< * return True * */ } /* "graphbrain/parsers/alpha_beta.pyx":313 * if ct[0] == 'p': * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': # <<<<<<<<<<<<<< * pred = entity.atom_with_type('p') * subparts = pred.parts()[1].split('.') */ } /* "graphbrain/parsers/alpha_beta.pyx":311 * else: * ct = entity.connector_type() * if ct[0] == 'p': # <<<<<<<<<<<<<< * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': */ } /* "graphbrain/parsers/alpha_beta.pyx":320 * return True * * return any([self._is_post_parse_token_necessary(subentity) # <<<<<<<<<<<<<< * for subentity in entity]) * */ __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); /* "graphbrain/parsers/alpha_beta.pyx":321 * * return any([self._is_post_parse_token_necessary(subentity) * for subentity in entity]) # <<<<<<<<<<<<<< * * def _post_parse_token(self, entity, token_dict): */ if (likely(PyList_CheckExact(__pyx_v_entity)) || PyTuple_CheckExact(__pyx_v_entity)) { __pyx_t_2 = __pyx_v_entity; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; __pyx_t_8 = NULL; } else { __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_entity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 321, __pyx_L11_error) } for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 321, __pyx_L11_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 321, __pyx_L11_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 321, __pyx_L11_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_subentity, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":320 * return True * * return any([self._is_post_parse_token_necessary(subentity) # <<<<<<<<<<<<<< * for subentity in entity]) * */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_post_parse_token_necessary); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 320, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_8genexpr3__pyx_v_subentity) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_8genexpr3__pyx_v_subentity); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 320, __pyx_L11_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":321 * * return any([self._is_post_parse_token_necessary(subentity) * for subentity in entity]) # <<<<<<<<<<<<<< * * def _post_parse_token(self, entity, token_dict): */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_subentity); __pyx_8genexpr3__pyx_v_subentity = 0; goto __pyx_L14_exit_scope; __pyx_L11_error:; __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_subentity); __pyx_8genexpr3__pyx_v_subentity = 0; goto __pyx_L1_error; __pyx_L14_exit_scope:; } /* exit inner scope */ /* "graphbrain/parsers/alpha_beta.pyx":320 * return True * * return any([self._is_post_parse_token_necessary(subentity) # <<<<<<<<<<<<<< * for subentity in entity]) * */ __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_any, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "graphbrain/parsers/alpha_beta.pyx":306 * self.extra_edges.add(lemma_edge) * * def _is_post_parse_token_necessary(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * return False */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._is_post_parse_token_necessary", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ct); __Pyx_XDECREF(__pyx_v_pred); __Pyx_XDECREF(__pyx_v_subparts); __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_subentity); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":323 * for subentity in entity]) * * def _post_parse_token(self, entity, token_dict): # <<<<<<<<<<<<<< * new_entity = entity * */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_53_post_parse_token(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_53_post_parse_token = {"_post_parse_token", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_53_post_parse_token, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_53_post_parse_token(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_entity = 0; PyObject *__pyx_v_token_dict = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_post_parse_token (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_entity,&__pyx_n_s_token_dict,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_entity)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_post_parse_token", 1, 3, 3, 1); __PYX_ERR(0, 323, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token_dict)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_post_parse_token", 1, 3, 3, 2); __PYX_ERR(0, 323, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_post_parse_token") < 0)) __PYX_ERR(0, 323, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_self = values[0]; __pyx_v_entity = values[1]; __pyx_v_token_dict = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_post_parse_token", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 323, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._post_parse_token", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_52_post_parse_token(__pyx_self, __pyx_v_self, __pyx_v_entity, __pyx_v_token_dict); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_52_post_parse_token(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_entity, PyObject *__pyx_v_token_dict) { PyObject *__pyx_v_new_entity = NULL; PyObject *__pyx_v_ct = NULL; PyObject *__pyx_v_pred = NULL; PyObject *__pyx_v_subparts = NULL; PyObject *__pyx_v_args = NULL; PyObject *__pyx_v_args_string = NULL; PyObject *__pyx_v_pt = NULL; PyObject *__pyx_v_new_part = NULL; PyObject *__pyx_v_new_pred = NULL; PyObject *__pyx_v_new_args = NULL; PyObject *__pyx_8genexpr4__pyx_v_param = NULL; PyObject *__pyx_8genexpr5__pyx_v_subentity = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; Py_ssize_t __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; __Pyx_RefNannySetupContext("_post_parse_token", 0); /* "graphbrain/parsers/alpha_beta.pyx":324 * * def _post_parse_token(self, entity, token_dict): * new_entity = entity # <<<<<<<<<<<<<< * * if self._is_post_parse_token_necessary(entity): */ __Pyx_INCREF(__pyx_v_entity); __pyx_v_new_entity = __pyx_v_entity; /* "graphbrain/parsers/alpha_beta.pyx":326 * new_entity = entity * * if self._is_post_parse_token_necessary(entity): # <<<<<<<<<<<<<< * ct = entity.connector_type() * if ct[0] == 'p': */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_post_parse_token_necessary); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_entity) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_entity); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":327 * * if self._is_post_parse_token_necessary(entity): * ct = entity.connector_type() # <<<<<<<<<<<<<< * if ct[0] == 'p': * # Extend predicate atom with argument types */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_ct = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":328 * if self._is_post_parse_token_necessary(entity): * ct = entity.connector_type() * if ct[0] == 'p': # <<<<<<<<<<<<<< * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 328, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":330 * if ct[0] == 'p': * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': # <<<<<<<<<<<<<< * pred = entity.atom_with_type('p') * subparts = pred.parts()[1].split('.') */ __pyx_t_5 = PyObject_Length(__pyx_v_ct); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 330, __pyx_L1_error) __pyx_t_6 = ((__pyx_t_5 < 2) != 0); if (!__pyx_t_6) { } else { __pyx_t_4 = __pyx_t_6; goto __pyx_L6_bool_binop_done; } __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ct, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_m, Py_NE)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 330, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __pyx_t_6; __pyx_L6_bool_binop_done:; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":331 * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': * pred = entity.atom_with_type('p') # <<<<<<<<<<<<<< * subparts = pred.parts()[1].split('.') * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_atom_with_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_u_p) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_p); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_pred = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":332 * if len(ct) < 2 or ct[1] != 'm': * pred = entity.atom_with_type('p') * subparts = pred.parts()[1].split('.') # <<<<<<<<<<<<<< * * if subparts[1] == '': */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_parts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u__4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_subparts = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":334 * subparts = pred.parts()[1].split('.') * * if subparts[1] == '': # <<<<<<<<<<<<<< * args = [self._arg_type(token_dict[param]) * for param in entity[1:]] */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_subparts, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_kp_u__3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":335 * * if subparts[1] == '': * args = [self._arg_type(token_dict[param]) # <<<<<<<<<<<<<< * for param in entity[1:]] * args_string = ''.join(args) */ { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); /* "graphbrain/parsers/alpha_beta.pyx":336 * if subparts[1] == '': * args = [self._arg_type(token_dict[param]) * for param in entity[1:]] # <<<<<<<<<<<<<< * args_string = ''.join(args) * pt = self._predicate_post_type_and_subtype( */ __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_entity, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0; __pyx_t_8 = NULL; } else { __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 336, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 336, __pyx_L11_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 336, __pyx_L11_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 336, __pyx_L11_error) #else __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_8(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 336, __pyx_L11_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_param, __pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":335 * * if subparts[1] == '': * args = [self._arg_type(token_dict[param]) # <<<<<<<<<<<<<< * for param in entity[1:]] * args_string = ''.join(args) */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_arg_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 335, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_token_dict, __pyx_8genexpr4__pyx_v_param); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 335, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_2 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_10, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 335, __pyx_L11_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":336 * if subparts[1] == '': * args = [self._arg_type(token_dict[param]) * for param in entity[1:]] # <<<<<<<<<<<<<< * args_string = ''.join(args) * pt = self._predicate_post_type_and_subtype( */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_param); __pyx_8genexpr4__pyx_v_param = 0; goto __pyx_L14_exit_scope; __pyx_L11_error:; __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_param); __pyx_8genexpr4__pyx_v_param = 0; goto __pyx_L1_error; __pyx_L14_exit_scope:; } /* exit inner scope */ __pyx_v_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":337 * args = [self._arg_type(token_dict[param]) * for param in entity[1:]] * args_string = ''.join(args) # <<<<<<<<<<<<<< * pt = self._predicate_post_type_and_subtype( * entity, subparts, args_string) */ __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__3, __pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_args_string = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":338 * for param in entity[1:]] * args_string = ''.join(args) * pt = self._predicate_post_type_and_subtype( # <<<<<<<<<<<<<< * entity, subparts, args_string) * new_part = '{}.{}.{}'.format(pt, */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_predicate_post_type_and_subtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "graphbrain/parsers/alpha_beta.pyx":339 * args_string = ''.join(args) * pt = self._predicate_post_type_and_subtype( * entity, subparts, args_string) # <<<<<<<<<<<<<< * new_part = '{}.{}.{}'.format(pt, * args_string, */ __pyx_t_2 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_entity, __pyx_v_subparts, __pyx_v_args_string}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_entity, __pyx_v_subparts, __pyx_v_args_string}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_v_entity); __Pyx_INCREF(__pyx_v_subparts); __Pyx_GIVEREF(__pyx_v_subparts); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_v_subparts); __Pyx_INCREF(__pyx_v_args_string); __Pyx_GIVEREF(__pyx_v_args_string); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_11, __pyx_v_args_string); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_pt = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":340 * pt = self._predicate_post_type_and_subtype( * entity, subparts, args_string) * new_part = '{}.{}.{}'.format(pt, # <<<<<<<<<<<<<< * args_string, * subparts[2]) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__8, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "graphbrain/parsers/alpha_beta.pyx":342 * new_part = '{}.{}.{}'.format(pt, * args_string, * subparts[2]) # <<<<<<<<<<<<<< * new_pred = pred.replace_atom_part(1, new_part) * new_entity = entity.replace_atom(pred, new_pred) */ __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_subparts, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_pt, __pyx_v_args_string, __pyx_t_7}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_pt, __pyx_v_args_string, __pyx_t_7}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_9 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_pt); __Pyx_GIVEREF(__pyx_v_pt); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_pt); __Pyx_INCREF(__pyx_v_args_string); __Pyx_GIVEREF(__pyx_v_args_string); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_args_string); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_11, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_new_part = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":343 * args_string, * subparts[2]) * new_pred = pred.replace_atom_part(1, new_part) # <<<<<<<<<<<<<< * new_entity = entity.replace_atom(pred, new_pred) * */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_replace_atom_part); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_int_1, __pyx_v_new_part}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_int_1, __pyx_v_new_part}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_int_1); __Pyx_INCREF(__pyx_v_new_part); __Pyx_GIVEREF(__pyx_v_new_part); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_v_new_part); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_new_pred = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":344 * subparts[2]) * new_pred = pred.replace_atom_part(1, new_part) * new_entity = entity.replace_atom(pred, new_pred) # <<<<<<<<<<<<<< * * new_args = [self._post_parse_token(subentity, token_dict) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_replace_atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 344, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_pred, __pyx_v_new_pred}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_pred, __pyx_v_new_pred}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 344, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_pred); __Pyx_GIVEREF(__pyx_v_pred); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_pred); __Pyx_INCREF(__pyx_v_new_pred); __Pyx_GIVEREF(__pyx_v_new_pred); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_new_pred); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_new_entity, __pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":334 * subparts = pred.parts()[1].split('.') * * if subparts[1] == '': # <<<<<<<<<<<<<< * args = [self._arg_type(token_dict[param]) * for param in entity[1:]] */ } /* "graphbrain/parsers/alpha_beta.pyx":330 * if ct[0] == 'p': * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': # <<<<<<<<<<<<<< * pred = entity.atom_with_type('p') * subparts = pred.parts()[1].split('.') */ } /* "graphbrain/parsers/alpha_beta.pyx":328 * if self._is_post_parse_token_necessary(entity): * ct = entity.connector_type() * if ct[0] == 'p': # <<<<<<<<<<<<<< * # Extend predicate atom with argument types * if len(ct) < 2 or ct[1] != 'm': */ } /* "graphbrain/parsers/alpha_beta.pyx":346 * new_entity = entity.replace_atom(pred, new_pred) * * new_args = [self._post_parse_token(subentity, token_dict) # <<<<<<<<<<<<<< * for subentity in new_entity[1:]] * new_entity = hedge([new_entity[0]] + new_args) */ { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); /* "graphbrain/parsers/alpha_beta.pyx":347 * * new_args = [self._post_parse_token(subentity, token_dict) * for subentity in new_entity[1:]] # <<<<<<<<<<<<<< * new_entity = hedge([new_entity[0]] + new_args) * */ __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_new_entity, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_9 = __pyx_t_3; __Pyx_INCREF(__pyx_t_9); __pyx_t_5 = 0; __pyx_t_8 = NULL; } else { __pyx_t_5 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 347, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 347, __pyx_L17_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_9))) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 347, __pyx_L17_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 347, __pyx_L17_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_8(__pyx_t_9); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 347, __pyx_L17_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_subentity, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":346 * new_entity = entity.replace_atom(pred, new_pred) * * new_args = [self._post_parse_token(subentity, token_dict) # <<<<<<<<<<<<<< * for subentity in new_entity[1:]] * new_entity = hedge([new_entity[0]] + new_args) */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_parse_token); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 346, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_8genexpr5__pyx_v_subentity, __pyx_v_token_dict}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L17_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_8genexpr5__pyx_v_subentity, __pyx_v_token_dict}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L17_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 346, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_8genexpr5__pyx_v_subentity); __Pyx_GIVEREF(__pyx_8genexpr5__pyx_v_subentity); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_8genexpr5__pyx_v_subentity); __Pyx_INCREF(__pyx_v_token_dict); __Pyx_GIVEREF(__pyx_v_token_dict); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_v_token_dict); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 346, __pyx_L17_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":347 * * new_args = [self._post_parse_token(subentity, token_dict) * for subentity in new_entity[1:]] # <<<<<<<<<<<<<< * new_entity = hedge([new_entity[0]] + new_args) * */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_subentity); __pyx_8genexpr5__pyx_v_subentity = 0; goto __pyx_L20_exit_scope; __pyx_L17_error:; __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_subentity); __pyx_8genexpr5__pyx_v_subentity = 0; goto __pyx_L1_error; __pyx_L20_exit_scope:; } /* exit inner scope */ __pyx_v_new_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":348 * new_args = [self._post_parse_token(subentity, token_dict) * for subentity in new_entity[1:]] * new_entity = hedge([new_entity[0]] + new_args) # <<<<<<<<<<<<<< * * return new_entity */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_hedge); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_new_entity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_7, __pyx_v_new_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_7, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_new_entity, __pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":326 * new_entity = entity * * if self._is_post_parse_token_necessary(entity): # <<<<<<<<<<<<<< * ct = entity.connector_type() * if ct[0] == 'p': */ } /* "graphbrain/parsers/alpha_beta.pyx":350 * new_entity = hedge([new_entity[0]] + new_args) * * return new_entity # <<<<<<<<<<<<<< * * def _parse_token(self, token): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_entity); __pyx_r = __pyx_v_new_entity; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":323 * for subentity in entity]) * * def _post_parse_token(self, entity, token_dict): # <<<<<<<<<<<<<< * new_entity = entity * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._post_parse_token", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_new_entity); __Pyx_XDECREF(__pyx_v_ct); __Pyx_XDECREF(__pyx_v_pred); __Pyx_XDECREF(__pyx_v_subparts); __Pyx_XDECREF(__pyx_v_args); __Pyx_XDECREF(__pyx_v_args_string); __Pyx_XDECREF(__pyx_v_pt); __Pyx_XDECREF(__pyx_v_new_part); __Pyx_XDECREF(__pyx_v_new_pred); __Pyx_XDECREF(__pyx_v_new_args); __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_param); __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_subentity); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "graphbrain/parsers/alpha_beta.pyx":352 * return new_entity * * def _parse_token(self, token): # <<<<<<<<<<<<<< * # check what type token maps to, return None if if maps to nothing * ent_type = self._token_type(token) */ /* Python wrapper */ static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_55_parse_token(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_55_parse_token = {"_parse_token", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_55_parse_token, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_55_parse_token(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_token = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_parse_token (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_token,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_token)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("_parse_token", 1, 2, 2, 1); __PYX_ERR(0, 352, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_token") < 0)) __PYX_ERR(0, 352, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_token = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_parse_token", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 352, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._parse_token", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_54_parse_token(__pyx_self, __pyx_v_self, __pyx_v_token); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_54_parse_token(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_token) { PyObject *__pyx_v_ent_type = NULL; PyObject *__pyx_v_children = NULL; PyObject *__pyx_v_token_dict = NULL; PyObject *__pyx_v_pos_dict = NULL; PyObject *__pyx_v_last_token = NULL; PyObject *__pyx_v_atom = NULL; PyObject *__pyx_v_entity = NULL; PyObject *__pyx_v_relative_to_concept = NULL; PyObject *__pyx_v_child = NULL; PyObject *__pyx_v_child_token = NULL; PyObject *__pyx_v_pos = NULL; PyObject *__pyx_v_child_type = NULL; PyObject *__pyx_v_new_child = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *(*__pyx_t_10)(PyObject *); int __pyx_t_11; Py_ssize_t __pyx_t_12; PyObject *(*__pyx_t_13)(PyObject *); int __pyx_t_14; Py_ssize_t __pyx_t_15; PyObject *__pyx_t_16 = NULL; __Pyx_RefNannySetupContext("_parse_token", 0); /* "graphbrain/parsers/alpha_beta.pyx":354 * def _parse_token(self, token): * # check what type token maps to, return None if if maps to nothing * ent_type = self._token_type(token) # <<<<<<<<<<<<<< * if ent_type == '' or ent_type is None: * return None, None */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_token_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_token); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_ent_type = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":355 * # check what type token maps to, return None if if maps to nothing * ent_type = self._token_type(token) * if ent_type == '' or ent_type is None: # <<<<<<<<<<<<<< * return None, None * */ __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_ent_type, __pyx_kp_u__3, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 355, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = (__pyx_v_ent_type == Py_None); __pyx_t_6 = (__pyx_t_5 != 0); __pyx_t_4 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":356 * ent_type = self._token_type(token) * if ent_type == '' or ent_type is None: * return None, None # <<<<<<<<<<<<<< * * # parse token children */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_tuple__9); __pyx_r = __pyx_tuple__9; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":355 * # check what type token maps to, return None if if maps to nothing * ent_type = self._token_type(token) * if ent_type == '' or ent_type is None: # <<<<<<<<<<<<<< * return None, None * */ } /* "graphbrain/parsers/alpha_beta.pyx":360 * # parse token children * children, token_dict, pos_dict, last_token =\ * self._parse_token_children(token) # <<<<<<<<<<<<<< * * atom = self._build_atom(token, ent_type, last_token) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_token_children); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_token); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 359, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); __pyx_t_7 = PyList_GET_ITEM(sequence, 2); __pyx_t_8 = PyList_GET_ITEM(sequence, 3); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_7,&__pyx_t_8}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 359, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_7,&__pyx_t_8}; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; for (index=0; index < 4; index++) { PyObject* item = __pyx_t_10(__pyx_t_9); if (unlikely(!item)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 4) < 0) __PYX_ERR(0, 359, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 359, __pyx_L1_error) __pyx_L7_unpacking_done:; } /* "graphbrain/parsers/alpha_beta.pyx":359 * * # parse token children * children, token_dict, pos_dict, last_token =\ # <<<<<<<<<<<<<< * self._parse_token_children(token) * */ __pyx_v_children = __pyx_t_2; __pyx_t_2 = 0; __pyx_v_token_dict = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_pos_dict = __pyx_t_7; __pyx_t_7 = 0; __pyx_v_last_token = __pyx_t_8; __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":362 * self._parse_token_children(token) * * atom = self._build_atom(token, ent_type, last_token) # <<<<<<<<<<<<<< * entity = atom * logging.debug('ATOM: {}'.format(atom)) */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_build_atom_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_token, __pyx_v_ent_type, __pyx_v_last_token}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_token, __pyx_v_ent_type, __pyx_v_last_token}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_token); __Pyx_GIVEREF(__pyx_v_token); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_token); __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_ent_type); __Pyx_INCREF(__pyx_v_last_token); __Pyx_GIVEREF(__pyx_v_last_token); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_11, __pyx_v_last_token); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_atom = __pyx_t_1; __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":363 * * atom = self._build_atom(token, ent_type, last_token) * entity = atom # <<<<<<<<<<<<<< * logging.debug('ATOM: {}'.format(atom)) * */ __Pyx_INCREF(__pyx_v_atom); __pyx_v_entity = __pyx_v_atom; /* "graphbrain/parsers/alpha_beta.pyx":364 * atom = self._build_atom(token, ent_type, last_token) * entity = atom * logging.debug('ATOM: {}'.format(atom)) # <<<<<<<<<<<<<< * * # lemmas */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_ATOM, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_8 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_2, __pyx_v_atom) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_atom); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":367 * * # lemmas * if self.lemmas: # <<<<<<<<<<<<<< * self._add_lemmas(token, entity, ent_type) * */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lemmas); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "graphbrain/parsers/alpha_beta.pyx":368 * # lemmas * if self.lemmas: * self._add_lemmas(token, entity, ent_type) # <<<<<<<<<<<<<< * * # process children */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_add_lemmas); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_v_token, __pyx_v_entity, __pyx_v_ent_type}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_v_token, __pyx_v_entity, __pyx_v_ent_type}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_token); __Pyx_GIVEREF(__pyx_v_token); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_v_token); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_v_entity); __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_11, __pyx_v_ent_type); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":367 * * # lemmas * if self.lemmas: # <<<<<<<<<<<<<< * self._add_lemmas(token, entity, ent_type) * */ } /* "graphbrain/parsers/alpha_beta.pyx":371 * * # process children * relative_to_concept = [] # <<<<<<<<<<<<<< * for child in children: * child_token = token_dict[child] */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_relative_to_concept = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":372 * # process children * relative_to_concept = [] * for child in children: # <<<<<<<<<<<<<< * child_token = token_dict[child] * pos = pos_dict[child] */ if (likely(PyList_CheckExact(__pyx_v_children)) || PyTuple_CheckExact(__pyx_v_children)) { __pyx_t_1 = __pyx_v_children; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_children); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 372, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_3); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 372, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_3); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 372, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 372, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_child, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":373 * relative_to_concept = [] * for child in children: * child_token = token_dict[child] # <<<<<<<<<<<<<< * pos = pos_dict[child] * */ __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_token_dict, __pyx_v_child); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_child_token, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":374 * for child in children: * child_token = token_dict[child] * pos = pos_dict[child] # <<<<<<<<<<<<<< * * child_type = child.type() */ __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_pos_dict, __pyx_v_child); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":376 * pos = pos_dict[child] * * child_type = child.type() # <<<<<<<<<<<<<< * * logging.debug('entity: [%s] %s', ent_type, entity) */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_child_type, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":378 * child_type = child.type() * * logging.debug('entity: [%s] %s', ent_type, entity) # <<<<<<<<<<<<<< * logging.debug('child: [%s] %s', child_type, child) * */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_logging); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_kp_u_entity_s_s, __pyx_v_ent_type, __pyx_v_entity}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_kp_u_entity_s_s, __pyx_v_ent_type, __pyx_v_entity}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_2 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_kp_u_entity_s_s); __Pyx_GIVEREF(__pyx_kp_u_entity_s_s); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, __pyx_kp_u_entity_s_s); __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, __pyx_v_ent_type); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_11, __pyx_v_entity); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":379 * * logging.debug('entity: [%s] %s', ent_type, entity) * logging.debug('child: [%s] %s', child_type, child) # <<<<<<<<<<<<<< * * if child_type[0] in {'c', 'r', 'd', 's'}: */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_u_child_s_s, __pyx_v_child_type, __pyx_v_child}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_u_child_s_s, __pyx_v_child_type, __pyx_v_child}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_kp_u_child_s_s); __Pyx_GIVEREF(__pyx_kp_u_child_s_s); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_kp_u_child_s_s); __Pyx_INCREF(__pyx_v_child_type); __Pyx_GIVEREF(__pyx_v_child_type); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_v_child_type); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_11, __pyx_v_child); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":381 * logging.debug('child: [%s] %s', child_type, child) * * if child_type[0] in {'c', 'r', 'd', 's'}: # <<<<<<<<<<<<<< * if ent_type[0] == 'c': * if (child.connector_type() in {'pc', 'pr'} or */ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_child_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 381, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_4 = __pyx_t_6; goto __pyx_L12_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_r, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 381, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_4 = __pyx_t_6; goto __pyx_L12_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 381, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_4 = __pyx_t_6; goto __pyx_L12_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_s, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 381, __pyx_L1_error) __pyx_t_4 = __pyx_t_6; __pyx_L12_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = (__pyx_t_4 != 0); if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":382 * * if child_type[0] in {'c', 'r', 'd', 's'}: * if ent_type[0] == 'c': # <<<<<<<<<<<<<< * if (child.connector_type() in {'pc', 'pr'} or * self._is_relative_concept(child_token)): */ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_ent_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 382, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":383 * if child_type[0] in {'c', 'r', 'd', 's'}: * if ent_type[0] == 'c': * if (child.connector_type() in {'pc', 'pr'} or # <<<<<<<<<<<<<< * self._is_relative_concept(child_token)): * logging.debug('choice: 1') */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_pc, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 383, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L20_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_pr, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 383, __pyx_L1_error) __pyx_t_4 = __pyx_t_5; __pyx_L20_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (__pyx_t_4 != 0); if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L18_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":384 * if ent_type[0] == 'c': * if (child.connector_type() in {'pc', 'pr'} or * self._is_relative_concept(child_token)): # <<<<<<<<<<<<<< * logging.debug('choice: 1') * # RELATIVE TO CONCEPT */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_relative_concept); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_v_child_token) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_child_token); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __pyx_t_5; __pyx_L18_bool_binop_done:; /* "graphbrain/parsers/alpha_beta.pyx":383 * if child_type[0] in {'c', 'r', 'd', 's'}: * if ent_type[0] == 'c': * if (child.connector_type() in {'pc', 'pr'} or # <<<<<<<<<<<<<< * self._is_relative_concept(child_token)): * logging.debug('choice: 1') */ if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":385 * if (child.connector_type() in {'pc', 'pr'} or * self._is_relative_concept(child_token)): * logging.debug('choice: 1') # <<<<<<<<<<<<<< * # RELATIVE TO CONCEPT * relative_to_concept.append(child) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_2, __pyx_kp_u_choice_1) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_kp_u_choice_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":387 * logging.debug('choice: 1') * # RELATIVE TO CONCEPT * relative_to_concept.append(child) # <<<<<<<<<<<<<< * elif child.connector_type()[0] == 'b': * if (child.connector_type() == 'b+' and */ __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_relative_to_concept, __pyx_v_child); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 387, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":383 * if child_type[0] in {'c', 'r', 'd', 's'}: * if ent_type[0] == 'c': * if (child.connector_type() in {'pc', 'pr'} or # <<<<<<<<<<<<<< * self._is_relative_concept(child_token)): * logging.debug('choice: 1') */ goto __pyx_L17; } /* "graphbrain/parsers/alpha_beta.pyx":388 * # RELATIVE TO CONCEPT * relative_to_concept.append(child) * elif child.connector_type()[0] == 'b': # <<<<<<<<<<<<<< * if (child.connector_type() == 'b+' and * child.contains_atom_type('cm')): */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_n_u_b_2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":389 * relative_to_concept.append(child) * elif child.connector_type()[0] == 'b': * if (child.connector_type() == 'b+' and # <<<<<<<<<<<<<< * child.contains_atom_type('cm')): * logging.debug('choice: 2') */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_7 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_kp_u_b_3, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L23_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":390 * elif child.connector_type()[0] == 'b': * if (child.connector_type() == 'b+' and * child.contains_atom_type('cm')): # <<<<<<<<<<<<<< * logging.debug('choice: 2') * # CONCEPT LIST */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_contains_atom_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_7 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_n_u_cm) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_n_u_cm); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = __pyx_t_5; __pyx_L23_bool_binop_done:; /* "graphbrain/parsers/alpha_beta.pyx":389 * relative_to_concept.append(child) * elif child.connector_type()[0] == 'b': * if (child.connector_type() == 'b+' and # <<<<<<<<<<<<<< * child.contains_atom_type('cm')): * logging.debug('choice: 2') */ if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":391 * if (child.connector_type() == 'b+' and * child.contains_atom_type('cm')): * logging.debug('choice: 2') # <<<<<<<<<<<<<< * # CONCEPT LIST * entity = _apply_aux_concept_list_to_concept(child, */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_choice_2) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_choice_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "graphbrain/parsers/alpha_beta.pyx":393 * logging.debug('choice: 2') * # CONCEPT LIST * entity = _apply_aux_concept_list_to_concept(child, # <<<<<<<<<<<<<< * entity) * elif entity.connector_type()[0] == 'c': */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_apply_aux_concept_list_to_conce); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* "graphbrain/parsers/alpha_beta.pyx":394 * # CONCEPT LIST * entity = _apply_aux_concept_list_to_concept(child, * entity) # <<<<<<<<<<<<<< * elif entity.connector_type()[0] == 'c': * logging.debug('choice: 3') */ __pyx_t_3 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_entity}; __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_7); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_entity}; __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_7); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_v_entity); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_7); __pyx_t_7 = 0; /* "graphbrain/parsers/alpha_beta.pyx":389 * relative_to_concept.append(child) * elif child.connector_type()[0] == 'b': * if (child.connector_type() == 'b+' and # <<<<<<<<<<<<<< * child.contains_atom_type('cm')): * logging.debug('choice: 2') */ goto __pyx_L22; } /* "graphbrain/parsers/alpha_beta.pyx":395 * entity = _apply_aux_concept_list_to_concept(child, * entity) * elif entity.connector_type()[0] == 'c': # <<<<<<<<<<<<<< * logging.debug('choice: 3') * # NEST */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":396 * entity) * elif entity.connector_type()[0] == 'c': * logging.debug('choice: 3') # <<<<<<<<<<<<<< * # NEST * new_child = child */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_logging); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_kp_u_choice_3) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_kp_u_choice_3); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":398 * logging.debug('choice: 3') * # NEST * new_child = child # <<<<<<<<<<<<<< * if len(child) > 2: * new_child = hedge((child[0], child[1:])) */ __Pyx_INCREF(__pyx_v_child); __Pyx_XDECREF_SET(__pyx_v_new_child, __pyx_v_child); /* "graphbrain/parsers/alpha_beta.pyx":399 * # NEST * new_child = child * if len(child) > 2: # <<<<<<<<<<<<<< * new_child = hedge((child[0], child[1:])) * entity = entity.nest(new_child, pos) */ __pyx_t_15 = PyObject_Length(__pyx_v_child); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 399, __pyx_L1_error) __pyx_t_6 = ((__pyx_t_15 > 2) != 0); if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":400 * new_child = child * if len(child) > 2: * new_child = hedge((child[0], child[1:])) # <<<<<<<<<<<<<< * entity = entity.nest(new_child, pos) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_hedge); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_child, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_child, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3); __pyx_t_7 = 0; __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_new_child, __pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":399 * # NEST * new_child = child * if len(child) > 2: # <<<<<<<<<<<<<< * new_child = hedge((child[0], child[1:])) * entity = entity.nest(new_child, pos) */ } /* "graphbrain/parsers/alpha_beta.pyx":401 * if len(child) > 2: * new_child = hedge((child[0], child[1:])) * entity = entity.nest(new_child, pos) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 4a') */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_nest); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_new_child, __pyx_v_pos}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_new_child, __pyx_v_pos}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_new_child); __Pyx_GIVEREF(__pyx_v_new_child); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_new_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":395 * entity = _apply_aux_concept_list_to_concept(child, * entity) * elif entity.connector_type()[0] == 'c': # <<<<<<<<<<<<<< * logging.debug('choice: 3') * # NEST */ goto __pyx_L22; } /* "graphbrain/parsers/alpha_beta.pyx":403 * entity = entity.nest(new_child, pos) * else: * logging.debug('choice: 4a') # <<<<<<<<<<<<<< * # NEST AROUND ORIGINAL ATOM * if atom.type()[0] == 'c' and len(child) > 2: */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_choice_4a) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_choice_4a); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":405 * logging.debug('choice: 4a') * # NEST AROUND ORIGINAL ATOM * if atom.type()[0] == 'c' and len(child) > 2: # <<<<<<<<<<<<<< * new_child = hedge((child[0], child[1:])) * entity = entity.replace_atom( */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L27_bool_binop_done; } __pyx_t_15 = PyObject_Length(__pyx_v_child); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 405, __pyx_L1_error) __pyx_t_5 = ((__pyx_t_15 > 2) != 0); __pyx_t_6 = __pyx_t_5; __pyx_L27_bool_binop_done:; if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":406 * # NEST AROUND ORIGINAL ATOM * if atom.type()[0] == 'c' and len(child) > 2: * new_child = hedge((child[0], child[1:])) # <<<<<<<<<<<<<< * entity = entity.replace_atom( * atom, */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_hedge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_child, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetSlice(__pyx_v_child, 1, 0, NULL, NULL, &__pyx_slice__2, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_new_child, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":407 * if atom.type()[0] == 'c' and len(child) > 2: * new_child = hedge((child[0], child[1:])) * entity = entity.replace_atom( # <<<<<<<<<<<<<< * atom, * atom.nest(new_child, pos)) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_replace_atom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* "graphbrain/parsers/alpha_beta.pyx":409 * entity = entity.replace_atom( * atom, * atom.nest(new_child, pos)) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 4b') */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s_nest); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_new_child, __pyx_v_pos}; __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_7); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_new_child, __pyx_v_pos}; __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_7); } else #endif { __pyx_t_16 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_new_child); __Pyx_GIVEREF(__pyx_v_new_child); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_11, __pyx_v_new_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_16, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_atom, __pyx_t_7}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_atom, __pyx_t_7}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_16 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_atom); __Pyx_GIVEREF(__pyx_v_atom); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_11, __pyx_v_atom); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_11, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":405 * logging.debug('choice: 4a') * # NEST AROUND ORIGINAL ATOM * if atom.type()[0] == 'c' and len(child) > 2: # <<<<<<<<<<<<<< * new_child = hedge((child[0], child[1:])) * entity = entity.replace_atom( */ goto __pyx_L26; } /* "graphbrain/parsers/alpha_beta.pyx":411 * atom.nest(new_child, pos)) * else: * logging.debug('choice: 4b') # <<<<<<<<<<<<<< * # NEST AROUND ORIGINAL ATOM * entity = entity.replace_atom( */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_2, __pyx_kp_u_choice_4b) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_kp_u_choice_4b); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "graphbrain/parsers/alpha_beta.pyx":413 * logging.debug('choice: 4b') * # NEST AROUND ORIGINAL ATOM * entity = entity.replace_atom( # <<<<<<<<<<<<<< * atom, * atom.nest(child, pos)) */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_replace_atom); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); /* "graphbrain/parsers/alpha_beta.pyx":415 * entity = entity.replace_atom( * atom, * atom.nest(child, pos)) # <<<<<<<<<<<<<< * elif child.connector_type()[0] in {'x', 't'}: * logging.debug('choice: 5') */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s_nest); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_child, __pyx_v_pos}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_child, __pyx_v_pos}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_atom, __pyx_t_2}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_atom, __pyx_t_2}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_atom); __Pyx_GIVEREF(__pyx_v_atom); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_atom); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_3); __pyx_t_3 = 0; } __pyx_L26:; } __pyx_L22:; /* "graphbrain/parsers/alpha_beta.pyx":388 * # RELATIVE TO CONCEPT * relative_to_concept.append(child) * elif child.connector_type()[0] == 'b': # <<<<<<<<<<<<<< * if (child.connector_type() == 'b+' and * child.contains_atom_type('cm')): */ goto __pyx_L17; } /* "graphbrain/parsers/alpha_beta.pyx":416 * atom, * atom.nest(child, pos)) * elif child.connector_type()[0] in {'x', 't'}: # <<<<<<<<<<<<<< * logging.debug('choice: 5') * # NEST */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_16); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_x, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 416, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L29_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_t, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 416, __pyx_L1_error) __pyx_t_6 = __pyx_t_5; __pyx_L29_bool_binop_done:; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_5 = (__pyx_t_6 != 0); if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":417 * atom.nest(child, pos)) * elif child.connector_type()[0] in {'x', 't'}: * logging.debug('choice: 5') # <<<<<<<<<<<<<< * # NEST * entity = entity.nest(child, pos) */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_kp_u_choice_5) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_kp_u_choice_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":419 * logging.debug('choice: 5') * # NEST * entity = entity.nest(child, pos) # <<<<<<<<<<<<<< * else: * if ((atom.type()[0] == 'c' and */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_nest); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_2, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":416 * atom, * atom.nest(child, pos)) * elif child.connector_type()[0] in {'x', 't'}: # <<<<<<<<<<<<<< * logging.debug('choice: 5') * # NEST */ goto __pyx_L17; } /* "graphbrain/parsers/alpha_beta.pyx":421 * entity = entity.nest(child, pos) * else: * if ((atom.type()[0] == 'c' and # <<<<<<<<<<<<<< * child.connector_type()[0] == 'c') or * self._is_compound(child_token)): */ /*else*/ { /* "graphbrain/parsers/alpha_beta.pyx":422 * else: * if ((atom.type()[0] == 'c' and * child.connector_type()[0] == 'c') or # <<<<<<<<<<<<<< * self._is_compound(child_token)): * if entity.connector_type()[0] == 'c': */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":421 * entity = entity.nest(child, pos) * else: * if ((atom.type()[0] == 'c' and # <<<<<<<<<<<<<< * child.connector_type()[0] == 'c') or * self._is_compound(child_token)): */ __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_16, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (!__pyx_t_6) { goto __pyx_L33_next_or; } else { } /* "graphbrain/parsers/alpha_beta.pyx":422 * else: * if ((atom.type()[0] == 'c' and * child.connector_type()[0] == 'c') or # <<<<<<<<<<<<<< * self._is_compound(child_token)): * if entity.connector_type()[0] == 'c': */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_8 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_16); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L32_bool_binop_done; } __pyx_L33_next_or:; /* "graphbrain/parsers/alpha_beta.pyx":423 * if ((atom.type()[0] == 'c' and * child.connector_type()[0] == 'c') or * self._is_compound(child_token)): # <<<<<<<<<<<<<< * if entity.connector_type()[0] == 'c': * if (child.connector_type()[0] == 'c' and */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_compound); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, __pyx_v_child_token) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_child_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_16); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_5 = __pyx_t_6; __pyx_L32_bool_binop_done:; /* "graphbrain/parsers/alpha_beta.pyx":421 * entity = entity.nest(child, pos) * else: * if ((atom.type()[0] == 'c' and # <<<<<<<<<<<<<< * child.connector_type()[0] == 'c') or * self._is_compound(child_token)): */ if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":424 * child.connector_type()[0] == 'c') or * self._is_compound(child_token)): * if entity.connector_type()[0] == 'c': # <<<<<<<<<<<<<< * if (child.connector_type()[0] == 'c' and * entity.connector_type() != 'cm'): */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_16, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 424, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":425 * self._is_compound(child_token)): * if entity.connector_type()[0] == 'c': * if (child.connector_type()[0] == 'c' and # <<<<<<<<<<<<<< * entity.connector_type() != 'cm'): * logging.debug('choice: 6') */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_8 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_16); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 425, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L37_bool_binop_done; } /* "graphbrain/parsers/alpha_beta.pyx":426 * if entity.connector_type()[0] == 'c': * if (child.connector_type()[0] == 'c' and * entity.connector_type() != 'cm'): # <<<<<<<<<<<<<< * logging.debug('choice: 6') * # SEQUENCE */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_cm, Py_NE)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_5 = __pyx_t_6; __pyx_L37_bool_binop_done:; /* "graphbrain/parsers/alpha_beta.pyx":425 * self._is_compound(child_token)): * if entity.connector_type()[0] == 'c': * if (child.connector_type()[0] == 'c' and # <<<<<<<<<<<<<< * entity.connector_type() != 'cm'): * logging.debug('choice: 6') */ if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":427 * if (child.connector_type()[0] == 'c' and * entity.connector_type() != 'cm'): * logging.debug('choice: 6') # <<<<<<<<<<<<<< * # SEQUENCE * entity = entity.sequence(child, pos) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, __pyx_kp_u_choice_6) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_choice_6); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":429 * logging.debug('choice: 6') * # SEQUENCE * entity = entity.sequence(child, pos) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 7') */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_sequence); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 429, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 429, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 429, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 429, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":425 * self._is_compound(child_token)): * if entity.connector_type()[0] == 'c': * if (child.connector_type()[0] == 'c' and # <<<<<<<<<<<<<< * entity.connector_type() != 'cm'): * logging.debug('choice: 6') */ goto __pyx_L36; } /* "graphbrain/parsers/alpha_beta.pyx":431 * entity = entity.sequence(child, pos) * else: * logging.debug('choice: 7') # <<<<<<<<<<<<<< * # FLAT SEQUENCE * entity = entity.sequence( */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_16 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_u_choice_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_choice_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":433 * logging.debug('choice: 7') * # FLAT SEQUENCE * entity = entity.sequence( # <<<<<<<<<<<<<< * child, pos, flat=False) * else: */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_sequence); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); /* "graphbrain/parsers/alpha_beta.pyx":434 * # FLAT SEQUENCE * entity = entity.sequence( * child, pos, flat=False) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 8') */ __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_pos); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_flat, Py_False) < 0) __PYX_ERR(0, 434, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":433 * logging.debug('choice: 7') * # FLAT SEQUENCE * entity = entity.sequence( # <<<<<<<<<<<<<< * child, pos, flat=False) * else: */ __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L36:; /* "graphbrain/parsers/alpha_beta.pyx":424 * child.connector_type()[0] == 'c') or * self._is_compound(child_token)): * if entity.connector_type()[0] == 'c': # <<<<<<<<<<<<<< * if (child.connector_type()[0] == 'c' and * entity.connector_type() != 'cm'): */ goto __pyx_L35; } /* "graphbrain/parsers/alpha_beta.pyx":436 * child, pos, flat=False) * else: * logging.debug('choice: 8') # <<<<<<<<<<<<<< * # SEQUENCE IN ORIGINAL ATOM * entity = entity.replace_atom( */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_8 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_u_choice_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_choice_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":438 * logging.debug('choice: 8') * # SEQUENCE IN ORIGINAL ATOM * entity = entity.replace_atom( # <<<<<<<<<<<<<< * atom, * atom.sequence(child, pos)) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_replace_atom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "graphbrain/parsers/alpha_beta.pyx":440 * entity = entity.replace_atom( * atom, * atom.sequence(child, pos)) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 9') */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s_sequence); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_7 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_child, __pyx_v_pos}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_child, __pyx_v_pos}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_v_atom, __pyx_t_2}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_v_atom, __pyx_t_2}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_16) { __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_16); __pyx_t_16 = NULL; } __Pyx_INCREF(__pyx_v_atom); __Pyx_GIVEREF(__pyx_v_atom); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_atom); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L35:; /* "graphbrain/parsers/alpha_beta.pyx":421 * entity = entity.nest(child, pos) * else: * if ((atom.type()[0] == 'c' and # <<<<<<<<<<<<<< * child.connector_type()[0] == 'c') or * self._is_compound(child_token)): */ goto __pyx_L31; } /* "graphbrain/parsers/alpha_beta.pyx":442 * atom.sequence(child, pos)) * else: * logging.debug('choice: 9') # <<<<<<<<<<<<<< * entity = entity.replace_atom( * atom, atom.connect((child,))) */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_8 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_3, __pyx_kp_u_choice_9) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_kp_u_choice_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":443 * else: * logging.debug('choice: 9') * entity = entity.replace_atom( # <<<<<<<<<<<<<< * atom, atom.connect((child,))) * elif ent_type[0] in {'p', 'r', 'd', 's'}: */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_replace_atom); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); /* "graphbrain/parsers/alpha_beta.pyx":444 * logging.debug('choice: 9') * entity = entity.replace_atom( * atom, atom.connect((child,))) # <<<<<<<<<<<<<< * elif ent_type[0] in {'p', 'r', 'd', 's'}: * logging.debug('choice: 10') */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s_connect); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 444, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 444, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_v_child); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_16); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 444, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_atom, __pyx_t_3}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_atom, __pyx_t_3}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_16 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_atom); __Pyx_GIVEREF(__pyx_v_atom); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_11, __pyx_v_atom); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_11, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_16, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L31:; } __pyx_L17:; /* "graphbrain/parsers/alpha_beta.pyx":382 * * if child_type[0] in {'c', 'r', 'd', 's'}: * if ent_type[0] == 'c': # <<<<<<<<<<<<<< * if (child.connector_type() in {'pc', 'pr'} or * self._is_relative_concept(child_token)): */ goto __pyx_L16; } /* "graphbrain/parsers/alpha_beta.pyx":445 * entity = entity.replace_atom( * atom, atom.connect((child,))) * elif ent_type[0] in {'p', 'r', 'd', 's'}: # <<<<<<<<<<<<<< * logging.debug('choice: 10') * # INSERT AFTER PREDICATE */ __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_ent_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 445, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L39_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_r, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 445, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L39_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 445, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L39_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_s, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 445, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L39_bool_binop_done:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = (__pyx_t_5 != 0); if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":446 * atom, atom.connect((child,))) * elif ent_type[0] in {'p', 'r', 'd', 's'}: * logging.debug('choice: 10') # <<<<<<<<<<<<<< * # INSERT AFTER PREDICATE * result = insert_after_predicate(entity, child) */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_logging); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_debug); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_9, __pyx_kp_u_choice_10) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_kp_u_choice_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":448 * logging.debug('choice: 10') * # INSERT AFTER PREDICATE * result = insert_after_predicate(entity, child) # <<<<<<<<<<<<<< * if result: * entity = result */ __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_insert_after_predicate); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_entity, __pyx_v_child}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 448, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_entity, __pyx_v_child}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 448, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_8); } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_entity); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_child); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF_SET(__pyx_v_result, __pyx_t_8); __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":449 * # INSERT AFTER PREDICATE * result = insert_after_predicate(entity, child) * if result: # <<<<<<<<<<<<<< * entity = result * else: */ __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_result); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 449, __pyx_L1_error) if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":450 * result = insert_after_predicate(entity, child) * if result: * entity = result # <<<<<<<<<<<<<< * else: * logging.warning(('insert_after_predicate failed' */ __Pyx_INCREF(__pyx_v_result); __Pyx_DECREF_SET(__pyx_v_entity, __pyx_v_result); /* "graphbrain/parsers/alpha_beta.pyx":449 * # INSERT AFTER PREDICATE * result = insert_after_predicate(entity, child) * if result: # <<<<<<<<<<<<<< * entity = result * else: */ goto __pyx_L43; } /* "graphbrain/parsers/alpha_beta.pyx":452 * entity = result * else: * logging.warning(('insert_after_predicate failed' # <<<<<<<<<<<<<< * 'with: {}').format(self.cur_text)) * else: */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_logging); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":453 * else: * logging.warning(('insert_after_predicate failed' * 'with: {}').format(self.cur_text)) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 11') */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_insert_after_predicate_failedwit, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cur_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_16 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_9, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_16); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_L43:; /* "graphbrain/parsers/alpha_beta.pyx":445 * entity = entity.replace_atom( * atom, atom.connect((child,))) * elif ent_type[0] in {'p', 'r', 'd', 's'}: # <<<<<<<<<<<<<< * logging.debug('choice: 10') * # INSERT AFTER PREDICATE */ goto __pyx_L16; } /* "graphbrain/parsers/alpha_beta.pyx":455 * 'with: {}').format(self.cur_text)) * else: * logging.debug('choice: 11') # <<<<<<<<<<<<<< * # INSERT FIRST ARGUMENT * entity = entity.insert_first_argument(child) */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_8 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_3, __pyx_kp_u_choice_11) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_kp_u_choice_11); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "graphbrain/parsers/alpha_beta.pyx":457 * logging.debug('choice: 11') * # INSERT FIRST ARGUMENT * entity = entity.insert_first_argument(child) # <<<<<<<<<<<<<< * elif child_type[0] == 'b': * if entity.connector_type()[0] == 'c': */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_insert_first_argument); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_8 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_3, __pyx_v_child) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_v_child); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L16:; /* "graphbrain/parsers/alpha_beta.pyx":381 * logging.debug('child: [%s] %s', child_type, child) * * if child_type[0] in {'c', 'r', 'd', 's'}: # <<<<<<<<<<<<<< * if ent_type[0] == 'c': * if (child.connector_type() in {'pc', 'pr'} or */ goto __pyx_L11; } /* "graphbrain/parsers/alpha_beta.pyx":458 * # INSERT FIRST ARGUMENT * entity = entity.insert_first_argument(child) * elif child_type[0] == 'b': # <<<<<<<<<<<<<< * if entity.connector_type()[0] == 'c': * logging.debug('choice: 12') */ __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_child_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_b_2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 458, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":459 * entity = entity.insert_first_argument(child) * elif child_type[0] == 'b': * if entity.connector_type()[0] == 'c': # <<<<<<<<<<<<<< * logging.debug('choice: 12') * # CONNECT */ __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connector_type); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_8 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_16); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":460 * elif child_type[0] == 'b': * if entity.connector_type()[0] == 'c': * logging.debug('choice: 12') # <<<<<<<<<<<<<< * # CONNECT * entity = child.connect(entity) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_choice_12) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_choice_12); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":462 * logging.debug('choice: 12') * # CONNECT * entity = child.connect(entity) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 13') */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_child, __pyx_n_s_connect); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_v_entity) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_entity); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":459 * entity = entity.insert_first_argument(child) * elif child_type[0] == 'b': * if entity.connector_type()[0] == 'c': # <<<<<<<<<<<<<< * logging.debug('choice: 12') * # CONNECT */ goto __pyx_L44; } /* "graphbrain/parsers/alpha_beta.pyx":464 * entity = child.connect(entity) * else: * logging.debug('choice: 13') # <<<<<<<<<<<<<< * entity = entity.nest(child, pos) * elif child_type[0] == 'p': */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_kp_u_choice_13) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_kp_u_choice_13); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":465 * else: * logging.debug('choice: 13') * entity = entity.nest(child, pos) # <<<<<<<<<<<<<< * elif child_type[0] == 'p': * # TODO: Pathological case */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_nest); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; } __pyx_L44:; /* "graphbrain/parsers/alpha_beta.pyx":458 * # INSERT FIRST ARGUMENT * entity = entity.insert_first_argument(child) * elif child_type[0] == 'b': # <<<<<<<<<<<<<< * if entity.connector_type()[0] == 'c': * logging.debug('choice: 12') */ goto __pyx_L11; } /* "graphbrain/parsers/alpha_beta.pyx":466 * logging.debug('choice: 13') * entity = entity.nest(child, pos) * elif child_type[0] == 'p': # <<<<<<<<<<<<<< * # TODO: Pathological case * # e.g. "Some subspecies of mosquito might be 1s..." */ __pyx_t_16 = __Pyx_GetItemInt(__pyx_v_child_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_p, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":469 * # TODO: Pathological case * # e.g. "Some subspecies of mosquito might be 1s..." * if child_type == 'pm': # <<<<<<<<<<<<<< * logging.debug('choice: 14') * # ? */ __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_child_type, __pyx_n_u_pm, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 469, __pyx_L1_error) if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":470 * # e.g. "Some subspecies of mosquito might be 1s..." * if child_type == 'pm': * logging.debug('choice: 14') # <<<<<<<<<<<<<< * # ? * entity = child + entity */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, __pyx_kp_u_choice_14) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_kp_u_choice_14); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":472 * logging.debug('choice: 14') * # ? * entity = child + entity # <<<<<<<<<<<<<< * else: * logging.debug('choice: 15') */ __pyx_t_16 = PyNumber_Add(__pyx_v_child, __pyx_v_entity); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":469 * # TODO: Pathological case * # e.g. "Some subspecies of mosquito might be 1s..." * if child_type == 'pm': # <<<<<<<<<<<<<< * logging.debug('choice: 14') * # ? */ goto __pyx_L45; } /* "graphbrain/parsers/alpha_beta.pyx":474 * entity = child + entity * else: * logging.debug('choice: 15') # <<<<<<<<<<<<<< * # CONNECT * entity = entity.connect((child,)) */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_logging); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_kp_u_choice_15) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_kp_u_choice_15); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":476 * logging.debug('choice: 15') * # CONNECT * entity = entity.connect((child,)) # <<<<<<<<<<<<<< * elif child_type[0] in {'m', 'x', 't'}: * logging.debug('choice: 16') */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_connect); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_child); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; } __pyx_L45:; /* "graphbrain/parsers/alpha_beta.pyx":466 * logging.debug('choice: 13') * entity = entity.nest(child, pos) * elif child_type[0] == 'p': # <<<<<<<<<<<<<< * # TODO: Pathological case * # e.g. "Some subspecies of mosquito might be 1s..." */ goto __pyx_L11; } /* "graphbrain/parsers/alpha_beta.pyx":477 * # CONNECT * entity = entity.connect((child,)) * elif child_type[0] in {'m', 'x', 't'}: # <<<<<<<<<<<<<< * logging.debug('choice: 16') * # ? */ __pyx_t_16 = __Pyx_GetItemInt(__pyx_v_child_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_m, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 477, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L46_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_x, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 477, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L46_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_t, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 477, __pyx_L1_error) __pyx_t_6 = __pyx_t_5; __pyx_L46_bool_binop_done:; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_5 = (__pyx_t_6 != 0); if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":478 * entity = entity.connect((child,)) * elif child_type[0] in {'m', 'x', 't'}: * logging.debug('choice: 16') # <<<<<<<<<<<<<< * # ? * entity = hedge((child, entity)) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, __pyx_kp_u_choice_16) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_kp_u_choice_16); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":480 * logging.debug('choice: 16') * # ? * entity = hedge((child, entity)) # <<<<<<<<<<<<<< * elif child_type[0] == 'a': * logging.debug('choice: 17') */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_hedge); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_child); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_entity); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_16 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_3, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":477 * # CONNECT * entity = entity.connect((child,)) * elif child_type[0] in {'m', 'x', 't'}: # <<<<<<<<<<<<<< * logging.debug('choice: 16') * # ? */ goto __pyx_L11; } /* "graphbrain/parsers/alpha_beta.pyx":481 * # ? * entity = hedge((child, entity)) * elif child_type[0] == 'a': # <<<<<<<<<<<<<< * logging.debug('choice: 17') * # NEST PREDICATE */ __pyx_t_16 = __Pyx_GetItemInt(__pyx_v_child_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_a, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":482 * entity = hedge((child, entity)) * elif child_type[0] == 'a': * logging.debug('choice: 17') # <<<<<<<<<<<<<< * # NEST PREDICATE * entity = nest_predicate(entity, child, pos) */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_logging); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 482, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 482, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_kp_u_choice_17) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_kp_u_choice_17); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 482, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":484 * logging.debug('choice: 17') * # NEST PREDICATE * entity = nest_predicate(entity, child, pos) # <<<<<<<<<<<<<< * elif child_type == 'w': * if ent_type[0] in {'d', 's'}: */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_nest_predicate); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_v_entity, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_v_entity, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif { __pyx_t_3 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_entity); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_11, __pyx_v_pos); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 484, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":481 * # ? * entity = hedge((child, entity)) * elif child_type[0] == 'a': # <<<<<<<<<<<<<< * logging.debug('choice: 17') * # NEST PREDICATE */ goto __pyx_L11; } /* "graphbrain/parsers/alpha_beta.pyx":485 * # NEST PREDICATE * entity = nest_predicate(entity, child, pos) * elif child_type == 'w': # <<<<<<<<<<<<<< * if ent_type[0] in {'d', 's'}: * logging.debug('choice: 18') */ __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_child_type, __pyx_n_u_w, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 485, __pyx_L1_error) if (__pyx_t_5) { /* "graphbrain/parsers/alpha_beta.pyx":486 * entity = nest_predicate(entity, child, pos) * elif child_type == 'w': * if ent_type[0] in {'d', 's'}: # <<<<<<<<<<<<<< * logging.debug('choice: 18') * # NEST PREDICATE */ __pyx_t_16 = __Pyx_GetItemInt(__pyx_v_ent_type, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 486, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 486, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L50_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_n_u_s, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 486, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L50_bool_binop_done:; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_6 = (__pyx_t_5 != 0); if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":487 * elif child_type == 'w': * if ent_type[0] in {'d', 's'}: * logging.debug('choice: 18') # <<<<<<<<<<<<<< * # NEST PREDICATE * entity = nest_predicate(entity, child, pos) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_choice_18) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_choice_18); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":489 * logging.debug('choice: 18') * # NEST PREDICATE * entity = nest_predicate(entity, child, pos) # <<<<<<<<<<<<<< * else: * logging.debug('choice: 19') */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_nest_predicate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_v_entity, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_v_entity, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif { __pyx_t_9 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_entity); __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_11, __pyx_v_pos); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":486 * entity = nest_predicate(entity, child, pos) * elif child_type == 'w': * if ent_type[0] in {'d', 's'}: # <<<<<<<<<<<<<< * logging.debug('choice: 18') * # NEST PREDICATE */ goto __pyx_L49; } /* "graphbrain/parsers/alpha_beta.pyx":491 * entity = nest_predicate(entity, child, pos) * else: * logging.debug('choice: 19') # <<<<<<<<<<<<<< * # NEST * entity = entity.nest(child, pos) */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_16 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_3, __pyx_kp_u_choice_19) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_kp_u_choice_19); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":493 * logging.debug('choice: 19') * # NEST * entity = entity.nest(child, pos) # <<<<<<<<<<<<<< * else: * logging.warning('Failed to parse token (_parse_token): {}' */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_nest); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 493, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_child, __pyx_v_pos}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 493, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_child); __Pyx_GIVEREF(__pyx_v_child); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_child); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_v_pos); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_16); __pyx_t_16 = 0; } __pyx_L49:; /* "graphbrain/parsers/alpha_beta.pyx":485 * # NEST PREDICATE * entity = nest_predicate(entity, child, pos) * elif child_type == 'w': # <<<<<<<<<<<<<< * if ent_type[0] in {'d', 's'}: * logging.debug('choice: 18') */ goto __pyx_L11; } /* "graphbrain/parsers/alpha_beta.pyx":495 * entity = entity.nest(child, pos) * else: * logging.warning('Failed to parse token (_parse_token): {}' # <<<<<<<<<<<<<< * .format(token)) * logging.debug('choice: 20') */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_logging); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_warning); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "graphbrain/parsers/alpha_beta.pyx":496 * else: * logging.warning('Failed to parse token (_parse_token): {}' * .format(token)) # <<<<<<<<<<<<<< * logging.debug('choice: 20') * # IGNORE */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Failed_to_parse_token__parse_tok, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_9 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_token); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_16 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":497 * logging.warning('Failed to parse token (_parse_token): {}' * .format(token)) * logging.debug('choice: 20') # <<<<<<<<<<<<<< * # IGNORE * pass */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_logging); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 497, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 497, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, __pyx_kp_u_choice_20) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_kp_u_choice_20); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 497, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __pyx_L11:; /* "graphbrain/parsers/alpha_beta.pyx":501 * pass * * ent_type = entity.type() # <<<<<<<<<<<<<< * logging.debug('result: [%s] %s\n', ent_type, entity) * */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_entity, __pyx_n_s_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_16 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_ent_type, __pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":502 * * ent_type = entity.type() * logging.debug('result: [%s] %s\n', ent_type, entity) # <<<<<<<<<<<<<< * * if len(relative_to_concept) > 0: */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_logging); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_kp_u_result_s_s, __pyx_v_ent_type, __pyx_v_entity}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_kp_u_result_s_s, __pyx_v_ent_type, __pyx_v_entity}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_16); } else #endif { __pyx_t_3 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_kp_u_result_s_s); __Pyx_GIVEREF(__pyx_kp_u_result_s_s); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_kp_u_result_s_s); __Pyx_INCREF(__pyx_v_ent_type); __Pyx_GIVEREF(__pyx_v_ent_type); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_ent_type); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_11, __pyx_v_entity); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; /* "graphbrain/parsers/alpha_beta.pyx":372 * # process children * relative_to_concept = [] * for child in children: # <<<<<<<<<<<<<< * child_token = token_dict[child] * pos = pos_dict[child] */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":504 * logging.debug('result: [%s] %s\n', ent_type, entity) * * if len(relative_to_concept) > 0: # <<<<<<<<<<<<<< * relative_to_concept.reverse() * entity = hedge((':/b/.', entity) + tuple(relative_to_concept)) */ __pyx_t_12 = PyList_GET_SIZE(__pyx_v_relative_to_concept); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 504, __pyx_L1_error) __pyx_t_6 = ((__pyx_t_12 > 0) != 0); if (__pyx_t_6) { /* "graphbrain/parsers/alpha_beta.pyx":505 * * if len(relative_to_concept) > 0: * relative_to_concept.reverse() # <<<<<<<<<<<<<< * entity = hedge((':/b/.', entity) + tuple(relative_to_concept)) * */ __pyx_t_14 = PyList_Reverse(__pyx_v_relative_to_concept); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 505, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":506 * if len(relative_to_concept) > 0: * relative_to_concept.reverse() * entity = hedge((':/b/.', entity) + tuple(relative_to_concept)) # <<<<<<<<<<<<<< * * return self._post_parse_token(entity, token_dict), self.extra_edges */ __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_hedge); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_kp_u_b_4); __Pyx_GIVEREF(__pyx_kp_u_b_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_b_4); __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_entity); __pyx_t_3 = PyList_AsTuple(__pyx_v_relative_to_concept); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_3, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF_SET(__pyx_v_entity, __pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":504 * logging.debug('result: [%s] %s\n', ent_type, entity) * * if len(relative_to_concept) > 0: # <<<<<<<<<<<<<< * relative_to_concept.reverse() * entity = hedge((':/b/.', entity) + tuple(relative_to_concept)) */ } /* "graphbrain/parsers/alpha_beta.pyx":508 * entity = hedge((':/b/.', entity) + tuple(relative_to_concept)) * * return self._post_parse_token(entity, token_dict), self.extra_edges # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_parse_token); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_entity, __pyx_v_token_dict}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_entity, __pyx_v_token_dict}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_INCREF(__pyx_v_entity); __Pyx_GIVEREF(__pyx_v_entity); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_entity); __Pyx_INCREF(__pyx_v_token_dict); __Pyx_GIVEREF(__pyx_v_token_dict); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_token_dict); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_extra_edges); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_16); __pyx_t_1 = 0; __pyx_t_16 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "graphbrain/parsers/alpha_beta.pyx":352 * return new_entity * * def _parse_token(self, token): # <<<<<<<<<<<<<< * # check what type token maps to, return None if if maps to nothing * ent_type = self._token_type(token) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("graphbrain.parsers.alpha_beta.AlphaBeta._parse_token", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ent_type); __Pyx_XDECREF(__pyx_v_children); __Pyx_XDECREF(__pyx_v_token_dict); __Pyx_XDECREF(__pyx_v_pos_dict); __Pyx_XDECREF(__pyx_v_last_token); __Pyx_XDECREF(__pyx_v_atom); __Pyx_XDECREF(__pyx_v_entity); __Pyx_XDECREF(__pyx_v_relative_to_concept); __Pyx_XDECREF(__pyx_v_child); __Pyx_XDECREF(__pyx_v_child_token); __Pyx_XDECREF(__pyx_v_pos); __Pyx_XDECREF(__pyx_v_child_type); __Pyx_XDECREF(__pyx_v_new_child); __Pyx_XDECREF(__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; static int __pyx_import_star_set(PyObject *o, PyObject* py_name, char *name) { static const char* internal_type_names[] = { "__pyx_ctuple_int", "__pyx_ctuple_int_struct", 0 }; const char** type_name = internal_type_names; while (*type_name) { if (__Pyx_StrEq(name, *type_name)) { PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name); goto bad; } type_name++; } if (0); else { if (PyObject_SetAttr(__pyx_m, py_name, o) < 0) goto bad; } return 0; bad: return -1; } static int __Pyx_import_all_from(PyObject *locals, PyObject *v) { PyObject *all = PyObject_GetAttrString(v, "__all__"); PyObject *dict, *name, *value; int skip_leading_underscores = 0; int pos, err; if (all == NULL) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) return -1; PyErr_Clear(); dict = PyObject_GetAttrString(v, "__dict__"); if (dict == NULL) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) return -1; PyErr_SetString(PyExc_ImportError, "from-import-* object has no __dict__ and no __all__"); return -1; } #if PY_MAJOR_VERSION < 3 all = PyObject_CallMethod(dict, (char *)"keys", NULL); #else all = PyMapping_Keys(dict); #endif Py_DECREF(dict); if (all == NULL) return -1; skip_leading_underscores = 1; } for (pos = 0, err = 0; ; pos++) { name = PySequence_GetItem(all, pos); if (name == NULL) { if (!PyErr_ExceptionMatches(PyExc_IndexError)) err = -1; else PyErr_Clear(); break; } if (skip_leading_underscores && #if PY_MAJOR_VERSION < 3 PyString_Check(name) && PyString_AS_STRING(name)[0] == '_') #else PyUnicode_Check(name) && PyUnicode_AS_UNICODE(name)[0] == '_') #endif { Py_DECREF(name); continue; } value = PyObject_GetAttr(v, name); if (value == NULL) err = -1; else if (PyDict_CheckExact(locals)) err = PyDict_SetItem(locals, name, value); else err = PyObject_SetItem(locals, name, value); Py_DECREF(name); Py_XDECREF(value); if (err != 0) break; } Py_DECREF(all); return err; } static int __pyx_import_star(PyObject* m) { int i; int ret = -1; char* s; PyObject *locals = 0; PyObject *list = 0; #if PY_MAJOR_VERSION >= 3 PyObject *utf8_name = 0; #endif PyObject *name; PyObject *item; locals = PyDict_New(); if (!locals) goto bad; if (__Pyx_import_all_from(locals, m) < 0) goto bad; list = PyDict_Items(locals); if (!list) goto bad; for(i=0; i<PyList_GET_SIZE(list); i++) { name = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 0); item = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 1); #if PY_MAJOR_VERSION >= 3 utf8_name = PyUnicode_AsUTF8String(name); if (!utf8_name) goto bad; s = PyBytes_AS_STRING(utf8_name); if (__pyx_import_star_set(item, name, s) < 0) goto bad; Py_DECREF(utf8_name); utf8_name = 0; #else s = PyString_AsString(name); if (!s) goto bad; if (__pyx_import_star_set(item, name, s) < 0) goto bad; #endif } ret = 0; bad: Py_XDECREF(locals); Py_XDECREF(list); #if PY_MAJOR_VERSION >= 3 Py_XDECREF(utf8_name); #endif return ret; } #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_alpha_beta(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_alpha_beta}, {0, NULL} }; #endif static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, "alpha_beta", 0, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ #else -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_ATOM, __pyx_k_ATOM, sizeof(__pyx_k_ATOM), 0, 1, 0, 0}, {&__pyx_n_s_AlphaBeta, __pyx_k_AlphaBeta, sizeof(__pyx_k_AlphaBeta), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta___init, __pyx_k_AlphaBeta___init, sizeof(__pyx_k_AlphaBeta___init), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__add_lemmas, __pyx_k_AlphaBeta__add_lemmas, sizeof(__pyx_k_AlphaBeta__add_lemmas), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__arg_type, __pyx_k_AlphaBeta__arg_type, sizeof(__pyx_k_AlphaBeta__arg_type), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__auxiliary_type_and_su, __pyx_k_AlphaBeta__auxiliary_type_and_su, sizeof(__pyx_k_AlphaBeta__auxiliary_type_and_su), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__before_parse_sentence, __pyx_k_AlphaBeta__before_parse_sentence, sizeof(__pyx_k_AlphaBeta__before_parse_sentence), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__build_atom, __pyx_k_AlphaBeta__build_atom, sizeof(__pyx_k_AlphaBeta__build_atom), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__build_atom_auxiliary, __pyx_k_AlphaBeta__build_atom_auxiliary, sizeof(__pyx_k_AlphaBeta__build_atom_auxiliary), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__build_atom_predicate, __pyx_k_AlphaBeta__build_atom_predicate, sizeof(__pyx_k_AlphaBeta__build_atom_predicate), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__build_atom_subpredica, __pyx_k_AlphaBeta__build_atom_subpredica, sizeof(__pyx_k_AlphaBeta__build_atom_subpredica), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__builder_arg_roles, __pyx_k_AlphaBeta__builder_arg_roles, sizeof(__pyx_k_AlphaBeta__builder_arg_roles), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__builder_type_and_subt, __pyx_k_AlphaBeta__builder_type_and_subt, sizeof(__pyx_k_AlphaBeta__builder_type_and_subt), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__compose_concepts, __pyx_k_AlphaBeta__compose_concepts, sizeof(__pyx_k_AlphaBeta__compose_concepts), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__concept_role, __pyx_k_AlphaBeta__concept_role, sizeof(__pyx_k_AlphaBeta__concept_role), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__concept_type_and_subt, __pyx_k_AlphaBeta__concept_type_and_subt, sizeof(__pyx_k_AlphaBeta__concept_type_and_subt), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__is_compound, __pyx_k_AlphaBeta__is_compound, sizeof(__pyx_k_AlphaBeta__is_compound), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__is_noun, __pyx_k_AlphaBeta__is_noun, sizeof(__pyx_k_AlphaBeta__is_noun), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__is_post_parse_token_n, __pyx_k_AlphaBeta__is_post_parse_token_n, sizeof(__pyx_k_AlphaBeta__is_post_parse_token_n), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__is_relative_concept, __pyx_k_AlphaBeta__is_relative_concept, sizeof(__pyx_k_AlphaBeta__is_relative_concept), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__is_verb, __pyx_k_AlphaBeta__is_verb, sizeof(__pyx_k_AlphaBeta__is_verb), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__modifier_type_and_sub, __pyx_k_AlphaBeta__modifier_type_and_sub, sizeof(__pyx_k_AlphaBeta__modifier_type_and_sub), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__parse_token, __pyx_k_AlphaBeta__parse_token, sizeof(__pyx_k_AlphaBeta__parse_token), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__parse_token_children, __pyx_k_AlphaBeta__parse_token_children, sizeof(__pyx_k_AlphaBeta__parse_token_children), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__post_parse_token, __pyx_k_AlphaBeta__post_parse_token, sizeof(__pyx_k_AlphaBeta__post_parse_token), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__post_process, __pyx_k_AlphaBeta__post_process, sizeof(__pyx_k_AlphaBeta__post_process), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__predicate_post_type_a, __pyx_k_AlphaBeta__predicate_post_type_a, sizeof(__pyx_k_AlphaBeta__predicate_post_type_a), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__token_head_type, __pyx_k_AlphaBeta__token_head_type, sizeof(__pyx_k_AlphaBeta__token_head_type), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__token_type, __pyx_k_AlphaBeta__token_type, sizeof(__pyx_k_AlphaBeta__token_type), 0, 0, 1, 1}, {&__pyx_n_s_AlphaBeta__verb_features, __pyx_k_AlphaBeta__verb_features, sizeof(__pyx_k_AlphaBeta__verb_features), 0, 0, 1, 1}, {&__pyx_n_u_DATE, __pyx_k_DATE, sizeof(__pyx_k_DATE), 0, 1, 0, 1}, {&__pyx_kp_u_Failed_to_parse_token__parse_tok, __pyx_k_Failed_to_parse_token__parse_tok, sizeof(__pyx_k_Failed_to_parse_token__parse_tok), 0, 1, 0, 0}, {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1}, {&__pyx_n_s_Parser, __pyx_k_Parser, sizeof(__pyx_k_Parser), 0, 0, 1, 1}, {&__pyx_n_u_TIME, __pyx_k_TIME, sizeof(__pyx_k_TIME), 0, 1, 0, 1}, {&__pyx_n_s__10, __pyx_k__10, sizeof(__pyx_k__10), 0, 0, 1, 1}, {&__pyx_kp_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 0}, {&__pyx_kp_u__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 1, 0, 0}, {&__pyx_kp_u__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 1, 0, 0}, {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0}, {&__pyx_n_s__64, __pyx_k__64, sizeof(__pyx_k__64), 0, 0, 1, 1}, {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0}, {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0}, {&__pyx_n_u_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 1, 0, 1}, {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1}, {&__pyx_n_s_add_lemmas, __pyx_k_add_lemmas, sizeof(__pyx_k_add_lemmas), 0, 0, 1, 1}, {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1}, {&__pyx_n_s_apply_aux_concept_list_to_conce, __pyx_k_apply_aux_concept_list_to_conce, sizeof(__pyx_k_apply_aux_concept_list_to_conce), 0, 0, 1, 1}, {&__pyx_n_s_arg_pos, __pyx_k_arg_pos, sizeof(__pyx_k_arg_pos), 0, 0, 1, 1}, {&__pyx_n_s_arg_role, __pyx_k_arg_role, sizeof(__pyx_k_arg_role), 0, 0, 1, 1}, {&__pyx_n_s_arg_roles, __pyx_k_arg_roles, sizeof(__pyx_k_arg_roles), 0, 0, 1, 1}, {&__pyx_n_s_arg_type, __pyx_k_arg_type, sizeof(__pyx_k_arg_type), 0, 0, 1, 1}, {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_n_s_args_string, __pyx_k_args_string, sizeof(__pyx_k_args_string), 0, 0, 1, 1}, {&__pyx_n_s_atom, __pyx_k_atom, sizeof(__pyx_k_atom), 0, 0, 1, 1}, {&__pyx_n_s_atom2token, __pyx_k_atom2token, sizeof(__pyx_k_atom2token), 0, 0, 1, 1}, {&__pyx_n_s_atom_with_type, __pyx_k_atom_with_type, sizeof(__pyx_k_atom_with_type), 0, 0, 1, 1}, {&__pyx_n_s_auxiliary_type_and_subtype, __pyx_k_auxiliary_type_and_subtype, sizeof(__pyx_k_auxiliary_type_and_subtype), 0, 0, 1, 1}, {&__pyx_kp_u_av, __pyx_k_av, sizeof(__pyx_k_av), 0, 1, 0, 0}, {&__pyx_kp_u_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 1, 0, 0}, {&__pyx_n_u_b_2, __pyx_k_b_2, sizeof(__pyx_k_b_2), 0, 1, 0, 1}, {&__pyx_kp_u_b_3, __pyx_k_b_3, sizeof(__pyx_k_b_3), 0, 1, 0, 0}, {&__pyx_kp_u_b_4, __pyx_k_b_4, sizeof(__pyx_k_b_4), 0, 1, 0, 0}, {&__pyx_kp_u_b_am, __pyx_k_b_am, sizeof(__pyx_k_b_am), 0, 1, 0, 0}, {&__pyx_n_s_before, __pyx_k_before, sizeof(__pyx_k_before), 0, 0, 1, 1}, {&__pyx_n_s_before_parse_sentence, __pyx_k_before_parse_sentence, sizeof(__pyx_k_before_parse_sentence), 0, 0, 1, 1}, {&__pyx_n_s_build_atom, __pyx_k_build_atom, sizeof(__pyx_k_build_atom), 0, 0, 1, 1}, {&__pyx_n_s_build_atom_2, __pyx_k_build_atom_2, sizeof(__pyx_k_build_atom_2), 0, 0, 1, 1}, {&__pyx_n_s_build_atom_auxiliary, __pyx_k_build_atom_auxiliary, sizeof(__pyx_k_build_atom_auxiliary), 0, 0, 1, 1}, {&__pyx_n_s_build_atom_predicate, __pyx_k_build_atom_predicate, sizeof(__pyx_k_build_atom_predicate), 0, 0, 1, 1}, {&__pyx_n_s_build_atom_subpredicate, __pyx_k_build_atom_subpredicate, sizeof(__pyx_k_build_atom_subpredicate), 0, 0, 1, 1}, {&__pyx_n_s_builder, __pyx_k_builder, sizeof(__pyx_k_builder), 0, 0, 1, 1}, {&__pyx_n_s_builder_arg_roles, __pyx_k_builder_arg_roles, sizeof(__pyx_k_builder_arg_roles), 0, 0, 1, 1}, {&__pyx_n_s_builder_type_and_subtype, __pyx_k_builder_type_and_subtype, sizeof(__pyx_k_builder_type_and_subtype), 0, 0, 1, 1}, {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, {&__pyx_n_s_child, __pyx_k_child, sizeof(__pyx_k_child), 0, 0, 1, 1}, {&__pyx_kp_u_child_s_s, __pyx_k_child_s_s, sizeof(__pyx_k_child_s_s), 0, 1, 0, 0}, {&__pyx_n_s_child_token, __pyx_k_child_token, sizeof(__pyx_k_child_token), 0, 0, 1, 1}, {&__pyx_n_s_child_tokens, __pyx_k_child_tokens, sizeof(__pyx_k_child_tokens), 0, 0, 1, 1}, {&__pyx_n_s_child_type, __pyx_k_child_type, sizeof(__pyx_k_child_type), 0, 0, 1, 1}, {&__pyx_n_s_children, __pyx_k_children, sizeof(__pyx_k_children), 0, 0, 1, 1}, {&__pyx_kp_u_choice_1, __pyx_k_choice_1, sizeof(__pyx_k_choice_1), 0, 1, 0, 0}, {&__pyx_kp_u_choice_10, __pyx_k_choice_10, sizeof(__pyx_k_choice_10), 0, 1, 0, 0}, {&__pyx_kp_u_choice_11, __pyx_k_choice_11, sizeof(__pyx_k_choice_11), 0, 1, 0, 0}, {&__pyx_kp_u_choice_12, __pyx_k_choice_12, sizeof(__pyx_k_choice_12), 0, 1, 0, 0}, {&__pyx_kp_u_choice_13, __pyx_k_choice_13, sizeof(__pyx_k_choice_13), 0, 1, 0, 0}, {&__pyx_kp_u_choice_14, __pyx_k_choice_14, sizeof(__pyx_k_choice_14), 0, 1, 0, 0}, {&__pyx_kp_u_choice_15, __pyx_k_choice_15, sizeof(__pyx_k_choice_15), 0, 1, 0, 0}, {&__pyx_kp_u_choice_16, __pyx_k_choice_16, sizeof(__pyx_k_choice_16), 0, 1, 0, 0}, {&__pyx_kp_u_choice_17, __pyx_k_choice_17, sizeof(__pyx_k_choice_17), 0, 1, 0, 0}, {&__pyx_kp_u_choice_18, __pyx_k_choice_18, sizeof(__pyx_k_choice_18), 0, 1, 0, 0}, {&__pyx_kp_u_choice_19, __pyx_k_choice_19, sizeof(__pyx_k_choice_19), 0, 1, 0, 0}, {&__pyx_kp_u_choice_2, __pyx_k_choice_2, sizeof(__pyx_k_choice_2), 0, 1, 0, 0}, {&__pyx_kp_u_choice_20, __pyx_k_choice_20, sizeof(__pyx_k_choice_20), 0, 1, 0, 0}, {&__pyx_kp_u_choice_3, __pyx_k_choice_3, sizeof(__pyx_k_choice_3), 0, 1, 0, 0}, {&__pyx_kp_u_choice_4a, __pyx_k_choice_4a, sizeof(__pyx_k_choice_4a), 0, 1, 0, 0}, {&__pyx_kp_u_choice_4b, __pyx_k_choice_4b, sizeof(__pyx_k_choice_4b), 0, 1, 0, 0}, {&__pyx_kp_u_choice_5, __pyx_k_choice_5, sizeof(__pyx_k_choice_5), 0, 1, 0, 0}, {&__pyx_kp_u_choice_6, __pyx_k_choice_6, sizeof(__pyx_k_choice_6), 0, 1, 0, 0}, {&__pyx_kp_u_choice_7, __pyx_k_choice_7, sizeof(__pyx_k_choice_7), 0, 1, 0, 0}, {&__pyx_kp_u_choice_8, __pyx_k_choice_8, sizeof(__pyx_k_choice_8), 0, 1, 0, 0}, {&__pyx_kp_u_choice_9, __pyx_k_choice_9, sizeof(__pyx_k_choice_9), 0, 1, 0, 0}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_u_cm, __pyx_k_cm, sizeof(__pyx_k_cm), 0, 1, 0, 1}, {&__pyx_n_s_compose_concepts, __pyx_k_compose_concepts, sizeof(__pyx_k_compose_concepts), 0, 0, 1, 1}, {&__pyx_n_s_con_list, __pyx_k_con_list, sizeof(__pyx_k_con_list), 0, 0, 1, 1}, {&__pyx_n_s_concept, __pyx_k_concept, sizeof(__pyx_k_concept), 0, 0, 1, 1}, {&__pyx_n_s_concept_role, __pyx_k_concept_role, sizeof(__pyx_k_concept_role), 0, 0, 1, 1}, {&__pyx_n_s_concept_roles, __pyx_k_concept_roles, sizeof(__pyx_k_concept_roles), 0, 0, 1, 1}, {&__pyx_n_s_concept_type_and_subtype, __pyx_k_concept_type_and_subtype, sizeof(__pyx_k_concept_type_and_subtype), 0, 0, 1, 1}, {&__pyx_n_s_concepts, __pyx_k_concepts, sizeof(__pyx_k_concepts), 0, 0, 1, 1}, {&__pyx_n_s_connect, __pyx_k_connect, sizeof(__pyx_k_connect), 0, 0, 1, 1}, {&__pyx_n_s_connector_type, __pyx_k_connector_type, sizeof(__pyx_k_connector_type), 0, 0, 1, 1}, {&__pyx_n_s_const, __pyx_k_const, sizeof(__pyx_k_const), 0, 0, 1, 1}, {&__pyx_n_s_contains_atom_type, __pyx_k_contains_atom_type, sizeof(__pyx_k_contains_atom_type), 0, 0, 1, 1}, {&__pyx_n_s_ct, __pyx_k_ct, sizeof(__pyx_k_ct), 0, 0, 1, 1}, {&__pyx_n_s_cur_text, __pyx_k_cur_text, sizeof(__pyx_k_cur_text), 0, 0, 1, 1}, {&__pyx_n_u_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 1, 0, 1}, {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1}, {&__pyx_n_s_dep, __pyx_k_dep, sizeof(__pyx_k_dep), 0, 0, 1, 1}, {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_edge, __pyx_k_edge, sizeof(__pyx_k_edge), 0, 0, 1, 1}, {&__pyx_n_s_ent_type, __pyx_k_ent_type, sizeof(__pyx_k_ent_type), 0, 0, 1, 1}, {&__pyx_n_s_ent_type_2, __pyx_k_ent_type_2, sizeof(__pyx_k_ent_type_2), 0, 0, 1, 1}, {&__pyx_n_s_entity, __pyx_k_entity, sizeof(__pyx_k_entity), 0, 0, 1, 1}, {&__pyx_kp_u_entity_s_s, __pyx_k_entity_s_s, sizeof(__pyx_k_entity_s_s), 0, 1, 0, 0}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_et, __pyx_k_et, sizeof(__pyx_k_et), 0, 0, 1, 1}, {&__pyx_n_s_extra_edges, __pyx_k_extra_edges, sizeof(__pyx_k_extra_edges), 0, 0, 1, 1}, {&__pyx_n_s_first, __pyx_k_first, sizeof(__pyx_k_first), 0, 0, 1, 1}, {&__pyx_n_s_first_rel, __pyx_k_first_rel, sizeof(__pyx_k_first_rel), 0, 0, 1, 1}, {&__pyx_n_s_flat, __pyx_k_flat, sizeof(__pyx_k_flat), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_graphbrain, __pyx_k_graphbrain, sizeof(__pyx_k_graphbrain), 0, 0, 1, 1}, {&__pyx_n_s_graphbrain_constants, __pyx_k_graphbrain_constants, sizeof(__pyx_k_graphbrain_constants), 0, 0, 1, 1}, {&__pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_k_graphbrain_parsers_alpha_beta, sizeof(__pyx_k_graphbrain_parsers_alpha_beta), 0, 0, 1, 1}, {&__pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_k_graphbrain_parsers_alpha_beta_py, sizeof(__pyx_k_graphbrain_parsers_alpha_beta_py), 0, 0, 1, 0}, {&__pyx_n_s_head, __pyx_k_head, sizeof(__pyx_k_head), 0, 0, 1, 1}, {&__pyx_n_s_hedge, __pyx_k_hedge, sizeof(__pyx_k_hedge), 0, 0, 1, 1}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, {&__pyx_n_s_inner, __pyx_k_inner, sizeof(__pyx_k_inner), 0, 0, 1, 1}, {&__pyx_n_s_inner_rel, __pyx_k_inner_rel, sizeof(__pyx_k_inner_rel), 0, 0, 1, 1}, {&__pyx_n_s_insert_after_predicate, __pyx_k_insert_after_predicate, sizeof(__pyx_k_insert_after_predicate), 0, 0, 1, 1}, {&__pyx_kp_u_insert_after_predicate_failedwit, __pyx_k_insert_after_predicate_failedwit, sizeof(__pyx_k_insert_after_predicate_failedwit), 0, 1, 0, 0}, {&__pyx_n_s_insert_first_argument, __pyx_k_insert_first_argument, sizeof(__pyx_k_insert_first_argument), 0, 0, 1, 1}, {&__pyx_n_s_is_atom, __pyx_k_is_atom, sizeof(__pyx_k_is_atom), 0, 0, 1, 1}, {&__pyx_n_s_is_compound, __pyx_k_is_compound, sizeof(__pyx_k_is_compound), 0, 0, 1, 1}, {&__pyx_n_s_is_noun, __pyx_k_is_noun, sizeof(__pyx_k_is_noun), 0, 0, 1, 1}, {&__pyx_n_s_is_post_parse_token_necessary, __pyx_k_is_post_parse_token_necessary, sizeof(__pyx_k_is_post_parse_token_necessary), 0, 0, 1, 1}, {&__pyx_n_s_is_relative_concept, __pyx_k_is_relative_concept, sizeof(__pyx_k_is_relative_concept), 0, 0, 1, 1}, {&__pyx_n_s_is_verb, __pyx_k_is_verb, sizeof(__pyx_k_is_verb), 0, 0, 1, 1}, {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1}, {&__pyx_n_s_itertools, __pyx_k_itertools, sizeof(__pyx_k_itertools), 0, 0, 1, 1}, {&__pyx_n_s_lang, __pyx_k_lang, sizeof(__pyx_k_lang), 0, 0, 1, 1}, {&__pyx_n_s_last_token, __pyx_k_last_token, sizeof(__pyx_k_last_token), 0, 0, 1, 1}, {&__pyx_n_s_lefts, __pyx_k_lefts, sizeof(__pyx_k_lefts), 0, 0, 1, 1}, {&__pyx_n_s_lemma, __pyx_k_lemma, sizeof(__pyx_k_lemma), 0, 0, 1, 1}, {&__pyx_n_s_lemma_2, __pyx_k_lemma_2, sizeof(__pyx_k_lemma_2), 0, 0, 1, 1}, {&__pyx_n_s_lemma_edge, __pyx_k_lemma_edge, sizeof(__pyx_k_lemma_edge), 0, 0, 1, 1}, {&__pyx_n_s_lemma_pred, __pyx_k_lemma_pred, sizeof(__pyx_k_lemma_pred), 0, 0, 1, 1}, {&__pyx_n_s_lemmas, __pyx_k_lemmas, sizeof(__pyx_k_lemmas), 0, 0, 1, 1}, {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1}, {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1}, {&__pyx_n_u_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 1, 0, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_modifier_type_and_subtype, __pyx_k_modifier_type_and_subtype, sizeof(__pyx_k_modifier_type_and_subtype), 0, 0, 1, 1}, {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_nest, __pyx_k_nest, sizeof(__pyx_k_nest), 0, 0, 1, 1}, {&__pyx_n_s_nest_predicate, __pyx_k_nest_predicate, sizeof(__pyx_k_nest_predicate), 0, 0, 1, 1}, {&__pyx_n_s_new_args, __pyx_k_new_args, sizeof(__pyx_k_new_args), 0, 0, 1, 1}, {&__pyx_n_s_new_child, __pyx_k_new_child, sizeof(__pyx_k_new_child), 0, 0, 1, 1}, {&__pyx_n_s_new_entity, __pyx_k_new_entity, sizeof(__pyx_k_new_entity), 0, 0, 1, 1}, {&__pyx_n_s_new_part, __pyx_k_new_part, sizeof(__pyx_k_new_part), 0, 0, 1, 1}, {&__pyx_n_s_new_pred, __pyx_k_new_pred, sizeof(__pyx_k_new_pred), 0, 0, 1, 1}, {&__pyx_n_s_newparts, __pyx_k_newparts, sizeof(__pyx_k_newparts), 0, 0, 1, 1}, {&__pyx_n_s_orig, __pyx_k_orig, sizeof(__pyx_k_orig), 0, 0, 1, 1}, {&__pyx_n_s_outer, __pyx_k_outer, sizeof(__pyx_k_outer), 0, 0, 1, 1}, {&__pyx_n_u_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 1, 0, 1}, {&__pyx_kp_u_p_2, __pyx_k_p_2, sizeof(__pyx_k_p_2), 0, 1, 0, 0}, {&__pyx_n_s_param, __pyx_k_param, sizeof(__pyx_k_param), 0, 0, 1, 1}, {&__pyx_n_s_parse_token, __pyx_k_parse_token, sizeof(__pyx_k_parse_token), 0, 0, 1, 1}, {&__pyx_n_s_parse_token_children, __pyx_k_parse_token_children, sizeof(__pyx_k_parse_token_children), 0, 0, 1, 1}, {&__pyx_n_s_parser, __pyx_k_parser, sizeof(__pyx_k_parser), 0, 0, 1, 1}, {&__pyx_n_s_parts, __pyx_k_parts, sizeof(__pyx_k_parts), 0, 0, 1, 1}, {&__pyx_n_u_pc, __pyx_k_pc, sizeof(__pyx_k_pc), 0, 1, 0, 1}, {&__pyx_n_u_pd, __pyx_k_pd, sizeof(__pyx_k_pd), 0, 1, 0, 1}, {&__pyx_n_u_pm, __pyx_k_pm, sizeof(__pyx_k_pm), 0, 1, 0, 1}, {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1}, {&__pyx_n_s_pos_dict, __pyx_k_pos_dict, sizeof(__pyx_k_pos_dict), 0, 0, 1, 1}, {&__pyx_n_s_post_parse_token, __pyx_k_post_parse_token, sizeof(__pyx_k_post_parse_token), 0, 0, 1, 1}, {&__pyx_n_s_post_process, __pyx_k_post_process, sizeof(__pyx_k_post_process), 0, 0, 1, 1}, {&__pyx_n_u_pr, __pyx_k_pr, sizeof(__pyx_k_pr), 0, 1, 0, 1}, {&__pyx_n_s_pred, __pyx_k_pred, sizeof(__pyx_k_pred), 0, 0, 1, 1}, {&__pyx_n_s_predicate, __pyx_k_predicate, sizeof(__pyx_k_predicate), 0, 0, 1, 1}, {&__pyx_n_s_predicate_post_type_and_subtype, __pyx_k_predicate_post_type_and_subtype, sizeof(__pyx_k_predicate_post_type_and_subtype), 0, 0, 1, 1}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, {&__pyx_n_s_proc_edge, __pyx_k_proc_edge, sizeof(__pyx_k_proc_edge), 0, 0, 1, 1}, {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 0, 0, 1, 1}, {&__pyx_n_s_pt, __pyx_k_pt, sizeof(__pyx_k_pt), 0, 0, 1, 1}, {&__pyx_n_u_punct, __pyx_k_punct, sizeof(__pyx_k_punct), 0, 1, 0, 1}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_n_u_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 1, 0, 1}, {&__pyx_n_s_relative_to_concept, __pyx_k_relative_to_concept, sizeof(__pyx_k_relative_to_concept), 0, 0, 1, 1}, {&__pyx_n_s_repeat, __pyx_k_repeat, sizeof(__pyx_k_repeat), 0, 0, 1, 1}, {&__pyx_n_s_replace_atom, __pyx_k_replace_atom, sizeof(__pyx_k_replace_atom), 0, 0, 1, 1}, {&__pyx_n_s_replace_atom_part, __pyx_k_replace_atom_part, sizeof(__pyx_k_replace_atom_part), 0, 0, 1, 1}, {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1}, {&__pyx_kp_u_result_s_s, __pyx_k_result_s_s, sizeof(__pyx_k_result_s_s), 0, 1, 0, 0}, {&__pyx_n_s_rights, __pyx_k_rights, sizeof(__pyx_k_rights), 0, 0, 1, 1}, {&__pyx_n_u_rm, __pyx_k_rm, sizeof(__pyx_k_rm), 0, 1, 0, 1}, {&__pyx_n_s_role, __pyx_k_role, sizeof(__pyx_k_role), 0, 0, 1, 1}, {&__pyx_n_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 1}, {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, {&__pyx_n_s_sequence, __pyx_k_sequence, sizeof(__pyx_k_sequence), 0, 0, 1, 1}, {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1}, {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1}, {&__pyx_n_s_subentity, __pyx_k_subentity, sizeof(__pyx_k_subentity), 0, 0, 1, 1}, {&__pyx_n_s_subparts, __pyx_k_subparts, sizeof(__pyx_k_subparts), 0, 0, 1, 1}, {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1}, {&__pyx_n_u_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 1, 0, 1}, {&__pyx_kp_u_t_t, __pyx_k_t_t, sizeof(__pyx_k_t_t), 0, 1, 0, 0}, {&__pyx_kp_u_t_tt, __pyx_k_t_tt, sizeof(__pyx_k_t_tt), 0, 1, 0, 0}, {&__pyx_n_s_tag, __pyx_k_tag, sizeof(__pyx_k_tag), 0, 0, 1, 1}, {&__pyx_n_s_targ, __pyx_k_targ, sizeof(__pyx_k_targ), 0, 0, 1, 1}, {&__pyx_n_s_targ_type, __pyx_k_targ_type, sizeof(__pyx_k_targ_type), 0, 0, 1, 1}, {&__pyx_n_s_tedge, __pyx_k_tedge, sizeof(__pyx_k_tedge), 0, 0, 1, 1}, {&__pyx_n_s_temporal, __pyx_k_temporal, sizeof(__pyx_k_temporal), 0, 0, 1, 1}, {&__pyx_n_s_temps, __pyx_k_temps, sizeof(__pyx_k_temps), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_text, __pyx_k_text, sizeof(__pyx_k_text), 0, 0, 1, 1}, {&__pyx_n_s_token, __pyx_k_token, sizeof(__pyx_k_token), 0, 0, 1, 1}, {&__pyx_n_s_token_dict, __pyx_k_token_dict, sizeof(__pyx_k_token_dict), 0, 0, 1, 1}, {&__pyx_n_s_token_head_type, __pyx_k_token_head_type, sizeof(__pyx_k_token_head_type), 0, 0, 1, 1}, {&__pyx_n_s_token_type, __pyx_k_token_type, sizeof(__pyx_k_token_type), 0, 0, 1, 1}, {&__pyx_n_s_trigger, __pyx_k_trigger, sizeof(__pyx_k_trigger), 0, 0, 1, 1}, {&__pyx_n_s_trigger_atom, __pyx_k_trigger_atom, sizeof(__pyx_k_trigger_atom), 0, 0, 1, 1}, {&__pyx_n_s_triparts, __pyx_k_triparts, sizeof(__pyx_k_triparts), 0, 0, 1, 1}, {&__pyx_n_u_tt, __pyx_k_tt, sizeof(__pyx_k_tt), 0, 1, 0, 1}, {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1}, {&__pyx_n_s_verb_features, __pyx_k_verb_features, sizeof(__pyx_k_verb_features), 0, 0, 1, 1}, {&__pyx_n_s_verb_features_2, __pyx_k_verb_features_2, sizeof(__pyx_k_verb_features_2), 0, 0, 1, 1}, {&__pyx_n_u_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 1, 0, 1}, {&__pyx_n_s_warning, __pyx_k_warning, sizeof(__pyx_k_warning), 0, 0, 1, 1}, {&__pyx_n_u_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 1, 0, 1}, {&__pyx_kp_u_xv, __pyx_k_xv, sizeof(__pyx_k_xv), 0, 1, 0, 0}, {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 52, __pyx_L1_error) __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 60, __pyx_L1_error) __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 244, __pyx_L1_error) __pyx_builtin_any = __Pyx_GetBuiltinName(__pyx_n_s_any); if (!__pyx_builtin_any) __PYX_ERR(0, 320, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "graphbrain/parsers/alpha_beta.pyx":16 * inner_rel = insert_after_predicate(targ[1], orig) * if inner_rel: * return hedge((targ[0], inner_rel) + tuple(targ[2:])) # <<<<<<<<<<<<<< * else: * return None */ __pyx_slice_ = PySlice_New(__pyx_int_2, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); /* "graphbrain/parsers/alpha_beta.pyx":36 * return hedge((outer, inner)) * else: * return hedge(((outer, inner[0]),) + inner[1:]) # <<<<<<<<<<<<<< * * */ __pyx_slice__2 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2); /* "graphbrain/parsers/alpha_beta.pyx":356 * ent_type = self._token_type(token) * if ent_type == '' or ent_type is None: * return None, None # <<<<<<<<<<<<<< * * # parse token children */ __pyx_tuple__9 = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); /* "graphbrain/parsers/alpha_beta.pyx":8 * * * def insert_after_predicate(targ, orig): # <<<<<<<<<<<<<< * targ_type = targ.type() * if targ_type[0] == 'p': */ __pyx_tuple__11 = PyTuple_Pack(4, __pyx_n_s_targ, __pyx_n_s_orig, __pyx_n_s_targ_type, __pyx_n_s_inner_rel); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_insert_after_predicate, 8, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 8, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":29 * * * def nest_predicate(inner, outer, before): # <<<<<<<<<<<<<< * if inner.type() == 'rm': * first_rel = nest_predicate(inner[1], outer, before) */ __pyx_tuple__13 = PyTuple_Pack(4, __pyx_n_s_inner, __pyx_n_s_outer, __pyx_n_s_before, __pyx_n_s_first_rel); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_nest_predicate, 29, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 29, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":45 * # (+/b.am bank/c records/cn.p) * # (+/b.am (credit/cn.s card/cn.s) records/cn.p)) * def _apply_aux_concept_list_to_concept(con_list, concept): # <<<<<<<<<<<<<< * concepts = tuple([('+/b.am', item, concept) for item in con_list[1:]]) * return hedge((con_list[0],) + concepts) */ __pyx_tuple__15 = PyTuple_Pack(4, __pyx_n_s_con_list, __pyx_n_s_concept, __pyx_n_s_concepts, __pyx_n_s_item); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15); __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_apply_aux_concept_list_to_conce, 45, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 45, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":51 * * class AlphaBeta(Parser): * def __init__(self, lemmas=False): # <<<<<<<<<<<<<< * super().__init__(lemmas=lemmas) * self.extra_edges = set() */ __pyx_tuple__17 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_lemmas); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17); __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_init, 51, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 51, __pyx_L1_error) __pyx_tuple__19 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19); /* "graphbrain/parsers/alpha_beta.pyx":59 * # ======================================================================== * * def _arg_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__20 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_arg_type, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 59, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":62 * raise NotImplementedError() * * def _token_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__22 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_token_type, 62, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 62, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":65 * raise NotImplementedError() * * def _concept_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__24 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_concept_type_and_subtype, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 65, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":68 * raise NotImplementedError() * * def _modifier_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__26 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26); __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_modifier_type_and_subtype, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 68, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":71 * raise NotImplementedError() * * def _builder_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__28 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__28); __Pyx_GIVEREF(__pyx_tuple__28); __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_builder_type_and_subtype, 71, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 71, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":74 * raise NotImplementedError() * * def _auxiliary_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__30 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__30); __Pyx_GIVEREF(__pyx_tuple__30); __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_auxiliary_type_and_subtype, 74, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 74, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":77 * raise NotImplementedError() * * def _predicate_post_type_and_subtype(self, edge, subparts, args_string): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__32 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_edge, __pyx_n_s_subparts, __pyx_n_s_args_string); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32); __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_predicate_post_type_and_subtype, 77, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 77, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":80 * raise NotImplementedError() * * def _concept_role(self, concept): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__34 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_concept); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_concept_role, 80, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 80, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":83 * raise NotImplementedError() * * def _builder_arg_roles(self, edge): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__36 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_edge); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_builder_arg_roles, 83, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 83, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":86 * raise NotImplementedError() * * def _is_noun(token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__38 = PyTuple_Pack(1, __pyx_n_s_token); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__38); __Pyx_GIVEREF(__pyx_tuple__38); __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_is_noun, 86, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 86, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":89 * raise NotImplementedError() * * def _is_compound(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__40 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__40); __Pyx_GIVEREF(__pyx_tuple__40); __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_is_compound, 89, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 89, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":92 * raise NotImplementedError() * * def _is_relative_concept(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__42 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42); __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_is_relative_concept, 92, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 92, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":95 * raise NotImplementedError() * * def _is_verb(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__44 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__44); __Pyx_GIVEREF(__pyx_tuple__44); __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_is_verb, 95, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 95, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":98 * raise NotImplementedError() * * def _verb_features(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_tuple__46 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_token); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__46); __Pyx_GIVEREF(__pyx_tuple__46); __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_verb_features, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 98, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":105 * # ========================= * * def _token_head_type(self, token): # <<<<<<<<<<<<<< * head = token.head * if head and head != token: */ __pyx_tuple__48 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_head); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__48); __Pyx_GIVEREF(__pyx_tuple__48); __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_token_head_type, 105, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(0, 105, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":112 * return '' * * def _build_atom(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ __pyx_tuple__50 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_ent_type, __pyx_n_s_last_token, __pyx_n_s_text, __pyx_n_s_et, __pyx_n_s_atom); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__50); __Pyx_GIVEREF(__pyx_tuple__50); __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_build_atom_2, 112, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 112, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":128 * return atom * * def _build_atom_predicate(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ __pyx_tuple__52 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_ent_type, __pyx_n_s_last_token, __pyx_n_s_text, __pyx_n_s_et, __pyx_n_s_verb_features_2); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__52); __Pyx_GIVEREF(__pyx_tuple__52); __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_build_atom_predicate, 128, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 128, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":152 * return build_atom(text, et, self.lang) * * def _build_atom_subpredicate(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ __pyx_tuple__54 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_ent_type, __pyx_n_s_text, __pyx_n_s_et, __pyx_n_s_verb_features_2); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__54); __Pyx_GIVEREF(__pyx_tuple__54); __pyx_codeobj__55 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_build_atom_subpredicate, 152, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__55)) __PYX_ERR(0, 152, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":163 * return build_atom(text, et, self.lang) * * def _build_atom_auxiliary(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * */ __pyx_tuple__56 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_ent_type, __pyx_n_s_text, __pyx_n_s_verb_features_2, __pyx_n_s_et); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__56); __Pyx_GIVEREF(__pyx_tuple__56); __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_build_atom_auxiliary, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) __PYX_ERR(0, 163, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":178 * return build_atom(text, et, self.lang) * * def _compose_concepts(self, concepts): # <<<<<<<<<<<<<< * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': */ __pyx_tuple__58 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_concepts, __pyx_n_s_first, __pyx_n_s_concept_roles, __pyx_n_s_builder, __pyx_n_s_concept); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__58); __Pyx_GIVEREF(__pyx_tuple__58); __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_compose_concepts, 178, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 178, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":189 * self._compose_concepts(first[1:] + concepts[1:]))) * * def _post_process(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * token = self.atom2token.get(entity) */ __pyx_tuple__60 = PyTuple_Pack(21, __pyx_n_s_self, __pyx_n_s_entity, __pyx_n_s_token, __pyx_n_s_ent_type, __pyx_n_s_temporal, __pyx_n_s_temps, __pyx_n_s_ct, __pyx_n_s_ps, __pyx_n_s_pred, __pyx_n_s_role, __pyx_n_s_arg_roles, __pyx_n_s_proc_edge, __pyx_n_s_trigger, __pyx_n_s_i, __pyx_n_s_arg_role, __pyx_n_s_arg_pos, __pyx_n_s_tedge, __pyx_n_s_trigger_atom, __pyx_n_s_triparts, __pyx_n_s_newparts, __pyx_n_s_item); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__60); __Pyx_GIVEREF(__pyx_tuple__60); __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(2, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_post_process, 189, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 189, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":270 * return entity, temporal * * def _before_parse_sentence(self): # <<<<<<<<<<<<<< * self.extra_edges = set() * */ __pyx_tuple__62 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__62); __Pyx_GIVEREF(__pyx_tuple__62); __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_before_parse_sentence, 270, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 270, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":273 * self.extra_edges = set() * * def _parse_token_children(self, token): # <<<<<<<<<<<<<< * children = [] * token_dict = {} */ __pyx_tuple__65 = PyTuple_Pack(12, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_children, __pyx_n_s_token_dict, __pyx_n_s_pos_dict, __pyx_n_s_child_tokens, __pyx_n_s_child_token, __pyx_n_s_pos, __pyx_n_s_child, __pyx_n_s__64, __pyx_n_s_child_type, __pyx_n_s_last_token); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__65); __Pyx_GIVEREF(__pyx_tuple__65); __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(2, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_parse_token_children, 273, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 273, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":299 * return children, token_dict, pos_dict, last_token * * def _add_lemmas(self, token, entity, ent_type): # <<<<<<<<<<<<<< * text = token.lemma_.lower() * if text != token.text.lower(): */ __pyx_tuple__67 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_entity, __pyx_n_s_ent_type, __pyx_n_s_text, __pyx_n_s_lemma_2, __pyx_n_s_lemma_edge); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__67); __Pyx_GIVEREF(__pyx_tuple__67); __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_add_lemmas, 299, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 299, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":306 * self.extra_edges.add(lemma_edge) * * def _is_post_parse_token_necessary(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * return False */ __pyx_tuple__69 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_entity, __pyx_n_s_ct, __pyx_n_s_pred, __pyx_n_s_subparts, __pyx_n_s_subentity); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__69); __Pyx_GIVEREF(__pyx_tuple__69); __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_is_post_parse_token_necessary, 306, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 306, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":323 * for subentity in entity]) * * def _post_parse_token(self, entity, token_dict): # <<<<<<<<<<<<<< * new_entity = entity * */ __pyx_tuple__71 = PyTuple_Pack(15, __pyx_n_s_self, __pyx_n_s_entity, __pyx_n_s_token_dict, __pyx_n_s_new_entity, __pyx_n_s_ct, __pyx_n_s_pred, __pyx_n_s_subparts, __pyx_n_s_args, __pyx_n_s_args_string, __pyx_n_s_pt, __pyx_n_s_new_part, __pyx_n_s_new_pred, __pyx_n_s_new_args, __pyx_n_s_param, __pyx_n_s_subentity); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__71); __Pyx_GIVEREF(__pyx_tuple__71); __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_post_parse_token, 323, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 323, __pyx_L1_error) /* "graphbrain/parsers/alpha_beta.pyx":352 * return new_entity * * def _parse_token(self, token): # <<<<<<<<<<<<<< * # check what type token maps to, return None if if maps to nothing * ent_type = self._token_type(token) */ __pyx_tuple__73 = PyTuple_Pack(16, __pyx_n_s_self, __pyx_n_s_token, __pyx_n_s_ent_type, __pyx_n_s_children, __pyx_n_s_token_dict, __pyx_n_s_pos_dict, __pyx_n_s_last_token, __pyx_n_s_atom, __pyx_n_s_entity, __pyx_n_s_relative_to_concept, __pyx_n_s_child, __pyx_n_s_child_token, __pyx_n_s_pos, __pyx_n_s_child_type, __pyx_n_s_new_child, __pyx_n_s_result); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__73); __Pyx_GIVEREF(__pyx_tuple__73); __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(2, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_graphbrain_parsers_alpha_beta_py, __pyx_n_s_parse_token, 352, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ static int __Pyx_modinit_global_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #if PY_MAJOR_VERSION < 3 #ifdef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC void #else #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #endif #else #ifdef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyObject * #else #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #endif #endif #if PY_MAJOR_VERSION < 3 __Pyx_PyMODINIT_FUNC initalpha_beta(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC initalpha_beta(void) #else __Pyx_PyMODINIT_FUNC PyInit_alpha_beta(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_alpha_beta(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { #if PY_VERSION_HEX >= 0x030700A1 static PY_INT64_T main_interpreter_id = -1; PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); if (main_interpreter_id == -1) { main_interpreter_id = current_id; return (unlikely(current_id == -1)) ? -1 : 0; } else if (unlikely(main_interpreter_id != current_id)) #else static PyInterpreterState *main_interpreter = NULL; PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; if (!main_interpreter) { main_interpreter = current_interpreter; } else if (unlikely(main_interpreter != current_interpreter)) #endif { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { result = PyDict_SetItemString(moddict, to_name, value); } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; if (__Pyx_check_single_interpreter()) return NULL; if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_alpha_beta(PyObject *__pyx_pyinit_module) #endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'alpha_beta' has already been imported. Re-initialisation is not supported."); return -1; } #elif PY_MAJOR_VERSION >= 3 if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_alpha_beta(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); #endif __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("alpha_beta", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_b); __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_cython_runtime); if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_graphbrain__parsers__alpha_beta) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "graphbrain.parsers.alpha_beta")) { if (unlikely(PyDict_SetItemString(modules, "graphbrain.parsers.alpha_beta", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error; /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error; /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); (void)__Pyx_modinit_variable_export_code(); (void)__Pyx_modinit_function_export_code(); (void)__Pyx_modinit_type_init_code(); (void)__Pyx_modinit_type_import_code(); (void)__Pyx_modinit_variable_import_code(); (void)__Pyx_modinit_function_import_code(); /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "graphbrain/parsers/alpha_beta.pyx":1 * from itertools import repeat # <<<<<<<<<<<<<< * import logging * from graphbrain import * */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_repeat); __Pyx_GIVEREF(__pyx_n_s_repeat); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_repeat); __pyx_t_2 = __Pyx_Import(__pyx_n_s_itertools, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_repeat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_repeat, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":2 * from itertools import repeat * import logging # <<<<<<<<<<<<<< * from graphbrain import * * import graphbrain.constants as const */ __pyx_t_2 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_2) < 0) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":3 * from itertools import repeat * import logging * from graphbrain import * # <<<<<<<<<<<<<< * import graphbrain.constants as const * from .parser import Parser */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s__10); __Pyx_GIVEREF(__pyx_n_s__10); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s__10); __pyx_t_1 = __Pyx_Import(__pyx_n_s_graphbrain, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_import_star(__pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":4 * import logging * from graphbrain import * * import graphbrain.constants as const # <<<<<<<<<<<<<< * from .parser import Parser * */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s__10); __Pyx_GIVEREF(__pyx_n_s__10); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s__10); __pyx_t_2 = __Pyx_Import(__pyx_n_s_graphbrain_constants, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_const, __pyx_t_2) < 0) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":5 * from graphbrain import * * import graphbrain.constants as const * from .parser import Parser # <<<<<<<<<<<<<< * * */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Parser); __Pyx_GIVEREF(__pyx_n_s_Parser); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Parser); __pyx_t_1 = __Pyx_Import(__pyx_n_s_parser, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Parser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Parser, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":8 * * * def insert_after_predicate(targ, orig): # <<<<<<<<<<<<<< * targ_type = targ.type() * if targ_type[0] == 'p': */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_1insert_after_predicate, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_insert_after_predicate, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":29 * * * def nest_predicate(inner, outer, before): # <<<<<<<<<<<<<< * if inner.type() == 'rm': * first_rel = nest_predicate(inner[1], outer, before) */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_3nest_predicate, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_nest_predicate, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":45 * # (+/b.am bank/c records/cn.p) * # (+/b.am (credit/cn.s card/cn.s) records/cn.p)) * def _apply_aux_concept_list_to_concept(con_list, concept): # <<<<<<<<<<<<<< * concepts = tuple([('+/b.am', item, concept) for item in con_list[1:]]) * return hedge((con_list[0],) + concepts) */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_5_apply_aux_concept_list_to_concept, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_apply_aux_concept_list_to_conce, __pyx_t_1) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "graphbrain/parsers/alpha_beta.pyx":50 * * * class AlphaBeta(Parser): # <<<<<<<<<<<<<< * def __init__(self, lemmas=False): * super().__init__(lemmas=lemmas) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Parser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_AlphaBeta, __pyx_n_s_AlphaBeta, (PyObject *) NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* "graphbrain/parsers/alpha_beta.pyx":51 * * class AlphaBeta(Parser): * def __init__(self, lemmas=False): # <<<<<<<<<<<<<< * super().__init__(lemmas=lemmas) * self.extra_edges = set() */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_1__init__, 0, __pyx_n_s_AlphaBeta___init, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_5); PyList_Append(__pyx_t_4, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__19); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_5) < 0) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":59 * # ======================================================================== * * def _arg_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_3_arg_type, 0, __pyx_n_s_AlphaBeta__arg_type, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_arg_type, __pyx_t_5) < 0) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":62 * raise NotImplementedError() * * def _token_type(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_5_token_type, 0, __pyx_n_s_AlphaBeta__token_type, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_token_type, __pyx_t_5) < 0) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":65 * raise NotImplementedError() * * def _concept_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_7_concept_type_and_subtype, 0, __pyx_n_s_AlphaBeta__concept_type_and_subt, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_concept_type_and_subtype, __pyx_t_5) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":68 * raise NotImplementedError() * * def _modifier_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_9_modifier_type_and_subtype, 0, __pyx_n_s_AlphaBeta__modifier_type_and_sub, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_modifier_type_and_subtype, __pyx_t_5) < 0) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":71 * raise NotImplementedError() * * def _builder_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_11_builder_type_and_subtype, 0, __pyx_n_s_AlphaBeta__builder_type_and_subt, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__29)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_builder_type_and_subtype, __pyx_t_5) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":74 * raise NotImplementedError() * * def _auxiliary_type_and_subtype(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_13_auxiliary_type_and_subtype, 0, __pyx_n_s_AlphaBeta__auxiliary_type_and_su, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_auxiliary_type_and_subtype, __pyx_t_5) < 0) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":77 * raise NotImplementedError() * * def _predicate_post_type_and_subtype(self, edge, subparts, args_string): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_15_predicate_post_type_and_subtype, 0, __pyx_n_s_AlphaBeta__predicate_post_type_a, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_predicate_post_type_and_subtype, __pyx_t_5) < 0) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":80 * raise NotImplementedError() * * def _concept_role(self, concept): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_17_concept_role, 0, __pyx_n_s_AlphaBeta__concept_role, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_concept_role, __pyx_t_5) < 0) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":83 * raise NotImplementedError() * * def _builder_arg_roles(self, edge): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_19_builder_arg_roles, 0, __pyx_n_s_AlphaBeta__builder_arg_roles, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_builder_arg_roles, __pyx_t_5) < 0) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":86 * raise NotImplementedError() * * def _is_noun(token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_21_is_noun, 0, __pyx_n_s_AlphaBeta__is_noun, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_is_noun, __pyx_t_5) < 0) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":89 * raise NotImplementedError() * * def _is_compound(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_23_is_compound, 0, __pyx_n_s_AlphaBeta__is_compound, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_is_compound, __pyx_t_5) < 0) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":92 * raise NotImplementedError() * * def _is_relative_concept(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_25_is_relative_concept, 0, __pyx_n_s_AlphaBeta__is_relative_concept, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_is_relative_concept, __pyx_t_5) < 0) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":95 * raise NotImplementedError() * * def _is_verb(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_27_is_verb, 0, __pyx_n_s_AlphaBeta__is_verb, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_is_verb, __pyx_t_5) < 0) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":98 * raise NotImplementedError() * * def _verb_features(self, token): # <<<<<<<<<<<<<< * raise NotImplementedError() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_29_verb_features, 0, __pyx_n_s_AlphaBeta__verb_features, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_verb_features, __pyx_t_5) < 0) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":105 * # ========================= * * def _token_head_type(self, token): # <<<<<<<<<<<<<< * head = token.head * if head and head != token: */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_31_token_head_type, 0, __pyx_n_s_AlphaBeta__token_head_type, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_token_head_type, __pyx_t_5) < 0) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":112 * return '' * * def _build_atom(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_33_build_atom, 0, __pyx_n_s_AlphaBeta__build_atom, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__51)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_build_atom_2, __pyx_t_5) < 0) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":128 * return atom * * def _build_atom_predicate(self, token, ent_type, last_token): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_35_build_atom_predicate, 0, __pyx_n_s_AlphaBeta__build_atom_predicate, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__53)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_build_atom_predicate, __pyx_t_5) < 0) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":152 * return build_atom(text, et, self.lang) * * def _build_atom_subpredicate(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * et = ent_type */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_37_build_atom_subpredicate, 0, __pyx_n_s_AlphaBeta__build_atom_subpredica, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__55)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_build_atom_subpredicate, __pyx_t_5) < 0) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":163 * return build_atom(text, et, self.lang) * * def _build_atom_auxiliary(self, token, ent_type): # <<<<<<<<<<<<<< * text = token.text.lower() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_39_build_atom_auxiliary, 0, __pyx_n_s_AlphaBeta__build_atom_auxiliary, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_build_atom_auxiliary, __pyx_t_5) < 0) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":178 * return build_atom(text, et, self.lang) * * def _compose_concepts(self, concepts): # <<<<<<<<<<<<<< * first = concepts[0] * if first.is_atom() or first[0].type()[0] != 'm': */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_41_compose_concepts, 0, __pyx_n_s_AlphaBeta__compose_concepts, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_compose_concepts, __pyx_t_5) < 0) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":189 * self._compose_concepts(first[1:] + concepts[1:]))) * * def _post_process(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * token = self.atom2token.get(entity) */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_43_post_process, 0, __pyx_n_s_AlphaBeta__post_process, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_post_process, __pyx_t_5) < 0) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":270 * return entity, temporal * * def _before_parse_sentence(self): # <<<<<<<<<<<<<< * self.extra_edges = set() * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_45_before_parse_sentence, 0, __pyx_n_s_AlphaBeta__before_parse_sentence, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_before_parse_sentence, __pyx_t_5) < 0) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":273 * self.extra_edges = set() * * def _parse_token_children(self, token): # <<<<<<<<<<<<<< * children = [] * token_dict = {} */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_47_parse_token_children, 0, __pyx_n_s_AlphaBeta__parse_token_children, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__66)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_parse_token_children, __pyx_t_5) < 0) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":299 * return children, token_dict, pos_dict, last_token * * def _add_lemmas(self, token, entity, ent_type): # <<<<<<<<<<<<<< * text = token.lemma_.lower() * if text != token.text.lower(): */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_49_add_lemmas, 0, __pyx_n_s_AlphaBeta__add_lemmas, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__68)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_add_lemmas, __pyx_t_5) < 0) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":306 * self.extra_edges.add(lemma_edge) * * def _is_post_parse_token_necessary(self, entity): # <<<<<<<<<<<<<< * if entity.is_atom(): * return False */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_51_is_post_parse_token_necessary, 0, __pyx_n_s_AlphaBeta__is_post_parse_token_n, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__70)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_is_post_parse_token_necessary, __pyx_t_5) < 0) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":323 * for subentity in entity]) * * def _post_parse_token(self, entity, token_dict): # <<<<<<<<<<<<<< * new_entity = entity * */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_53_post_parse_token, 0, __pyx_n_s_AlphaBeta__post_parse_token, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__72)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_post_parse_token, __pyx_t_5) < 0) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":352 * return new_entity * * def _parse_token(self, token): # <<<<<<<<<<<<<< * # check what type token maps to, return None if if maps to nothing * ent_type = self._token_type(token) */ __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_10graphbrain_7parsers_10alpha_beta_9AlphaBeta_55_parse_token, 0, __pyx_n_s_AlphaBeta__parse_token, NULL, __pyx_n_s_graphbrain_parsers_alpha_beta, __pyx_d, ((PyObject *)__pyx_codeobj__74)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_parse_token, __pyx_t_5) < 0) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "graphbrain/parsers/alpha_beta.pyx":50 * * * class AlphaBeta(Parser): # <<<<<<<<<<<<<< * def __init__(self, lemmas=False): * super().__init__(lemmas=lemmas) */ __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_AlphaBeta, __pyx_t_2, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_CyFunction_InitClassCell(__pyx_t_4, __pyx_t_5) < 0) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_AlphaBeta, __pyx_t_5) < 0) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "graphbrain/parsers/alpha_beta.pyx":1 * from itertools import repeat # <<<<<<<<<<<<<< * import logging * from graphbrain import * */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init graphbrain.parsers.alpha_beta", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_CLEAR(__pyx_m); } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init graphbrain.parsers.alpha_beta"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #elif PY_MAJOR_VERSION >= 3 return __pyx_m; #else return; #endif } /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #endif /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } /* ParseKeywords */ static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; assert(globals != NULL); /* XXX Perhaps we should create a specialized PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) { return NULL; } fastlocals = __Pyx_PyFrame_GetLocalsplus(f); for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; } result = PyEval_EvalFrameEx(f,0); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; return result; } #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); PyObject *closure; #if PY_MAJOR_VERSION >= 3 PyObject *kwdefs; #endif PyObject *kwtuple, **k; PyObject **d; Py_ssize_t nd; Py_ssize_t nk; PyObject *result; assert(kwargs == NULL || PyDict_Check(kwargs)); nk = kwargs ? PyDict_Size(kwargs) : 0; if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { return NULL; } if ( #if PY_MAJOR_VERSION >= 3 co->co_kwonlyargcount == 0 && #endif likely(kwargs == NULL || nk == 0) && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { if (argdefs == NULL && co->co_argcount == nargs) { result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); goto done; } else if (nargs == 0 && argdefs != NULL && co->co_argcount == Py_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); goto done; } } if (kwargs != NULL) { Py_ssize_t pos, i; kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { result = NULL; goto done; } k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { Py_INCREF(k[i]); Py_INCREF(k[i+1]); i += 2; } nk = i / 2; } else { kwtuple = NULL; k = NULL; } closure = PyFunction_GET_CLOSURE(func); #if PY_MAJOR_VERSION >= 3 kwdefs = PyFunction_GET_KW_DEFAULTS(func); #endif if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); nd = Py_SIZE(argdefs); } else { d = NULL; nd = 0; } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, closure); #endif Py_XDECREF(kwtuple); done: Py_LeaveRecursiveCall(); return result; } #endif #endif /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallNoArg */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, NULL, 0); } #endif #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) #else if (likely(PyCFunction_Check(func))) #endif { if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif /* PyCFunctionFastCall */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { PyCFunctionObject *func = (PyCFunctionObject*)func_obj; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); int flags = PyCFunction_GET_FLAGS(func); assert(PyCFunction_Check(func)); assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); assert(nargs >= 0); assert(nargs == 0 || args != NULL); /* _PyCFunction_FastCallDict() must not be called with an exception set, because it may clear it (directly or indirectly) and so the caller loses its exception */ assert(!PyErr_Occurred()); if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); } else { return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); } } #endif /* PyObjectCallOneArg */ #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, &arg, 1); } #endif if (likely(PyCFunction_Check(func))) { if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); #if CYTHON_FAST_PYCCALL } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { return __Pyx_PyCFunction_FastCall(func, &arg, 1); #endif } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return m->sq_item(o, i); } } #else if (is_list || PySequence_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else #if PY_MAJOR_VERSION < 3 PyObject* owned_ref = NULL; #endif int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); #if PY_MAJOR_VERSION < 3 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { owned_ref = PyUnicode_FromObject(s2); if (unlikely(!owned_ref)) return -1; s2 = owned_ref; s2_is_unicode = 1; } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { owned_ref = PyUnicode_FromObject(s1); if (unlikely(!owned_ref)) return -1; s1 = owned_ref; s1_is_unicode = 1; } else if (((!s2_is_unicode) & (!s1_is_unicode))) { return __Pyx_PyBytes_Equals(s1, s2, equals); } #endif if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length; int kind; void *data1, *data2; if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; length = __Pyx_PyUnicode_GET_LENGTH(s1); if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; #if CYTHON_PEP393_ENABLED hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; #else hash1 = ((PyUnicodeObject*)s1)->hash; hash2 = ((PyUnicodeObject*)s2)->hash; #endif if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ); return_ne: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_NE); #endif } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } else if (unlikely(PyErr_Occurred())) { return NULL; } #else result = PyDict_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } #endif #else result = PyObject_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* PyObjectCall2Args */ static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { PyObject *args, *result = NULL; #if CYTHON_FAST_PYCALL if (PyFunction_Check(function)) { PyObject *args[2] = {arg1, arg2}; return __Pyx_PyFunction_FastCall(function, args, 2); } #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(function)) { PyObject *args[2] = {arg1, arg2}; return __Pyx_PyCFunction_FastCall(function, args, 2); } #endif args = PyTuple_New(2); if (unlikely(!args)) goto done; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); Py_INCREF(function); result = __Pyx_PyObject_Call(function, args, NULL); Py_DECREF(args); Py_DECREF(function); done: return result; } /* SliceObject */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { #if CYTHON_USE_TYPE_SLOTS PyMappingMethods* mp; #if PY_MAJOR_VERSION < 3 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; if (likely(ms && ms->sq_slice)) { if (!has_cstart) { if (_py_start && (*_py_start != Py_None)) { cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstart = 0; } if (!has_cstop) { if (_py_stop && (*_py_stop != Py_None)) { cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstop = PY_SSIZE_T_MAX; } if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { Py_ssize_t l = ms->sq_length(obj); if (likely(l >= 0)) { if (cstop < 0) { cstop += l; if (cstop < 0) cstop = 0; } if (cstart < 0) { cstart += l; if (cstart < 0) cstart = 0; } } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) goto bad; PyErr_Clear(); } } return ms->sq_slice(obj, cstart, cstop); } #endif mp = Py_TYPE(obj)->tp_as_mapping; if (likely(mp && mp->mp_subscript)) #endif { PyObject* result; PyObject *py_slice, *py_start, *py_stop; if (_py_slice) { py_slice = *_py_slice; } else { PyObject* owned_start = NULL; PyObject* owned_stop = NULL; if (_py_start) { py_start = *_py_start; } else { if (has_cstart) { owned_start = py_start = PyInt_FromSsize_t(cstart); if (unlikely(!py_start)) goto bad; } else py_start = Py_None; } if (_py_stop) { py_stop = *_py_stop; } else { if (has_cstop) { owned_stop = py_stop = PyInt_FromSsize_t(cstop); if (unlikely(!py_stop)) { Py_XDECREF(owned_start); goto bad; } } else py_stop = Py_None; } py_slice = PySlice_New(py_start, py_stop, Py_None); Py_XDECREF(owned_start); Py_XDECREF(owned_stop); if (unlikely(!py_slice)) goto bad; } #if CYTHON_USE_TYPE_SLOTS result = mp->mp_subscript(obj, py_slice); #else result = PyObject_GetItem(obj, py_slice); #endif if (!_py_slice) { Py_DECREF(py_slice); } return result; } PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); bad: return NULL; } /* PyObjectSetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_setattro)) return tp->tp_setattro(obj, attr_name, value); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_setattr)) return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); #endif return PyObject_SetAttr(obj, attr_name, value); } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; } #endif /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* ObjectGetItem */ #if CYTHON_USE_TYPE_SLOTS static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { PyObject *runerr; Py_ssize_t key_value; PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; if (unlikely(!(m && m->sq_item))) { PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); return NULL; } key_value = __Pyx_PyIndex_AsSsize_t(index); if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); } if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { PyErr_Clear(); PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); } return NULL; } static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; if (likely(m && m->mp_subscript)) { return m->mp_subscript(obj, key); } return __Pyx_PyObject_GetIndex(obj, key); } #endif /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { PyObject *exc_value, *exc_tb; exc_value = tstate->curexc_value; exc_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; Py_DECREF(exc_type); Py_XDECREF(exc_value); Py_XDECREF(exc_tb); return 0; } else { return -1; } } return 0; #else if (unlikely(PyErr_Occurred())) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { PyErr_Clear(); return 0; } else { return -1; } } return 0; #endif } /* UnpackItemEndCheck */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else { return __Pyx_IterFinish(); } return 0; } /* SetItemInt */ static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { int r; if (!j) return -1; r = PyObject_SetItem(o, j, v); Py_DECREF(j); return r; } static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { PyObject* old = PyList_GET_ITEM(o, n); Py_INCREF(v); PyList_SET_ITEM(o, n, v); Py_DECREF(old); return 1; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_ass_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return -1; PyErr_Clear(); } } return m->sq_ass_item(o, i, v); } } #else #if CYTHON_COMPILING_IN_PYPY if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) #else if (is_list || PySequence_Check(o)) #endif { return PySequence_SetItem(o, i, v); } #endif return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); } /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { (void)inplace; (void)zerodivision_check; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a + b); if (likely((x^a) >= 0 || (x^b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; #ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; #endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { a = likely(size) ? digits[0] : 0; if (size == -1) a = -a; } else { switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); #ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); #endif } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; double a = PyFloat_AS_DOUBLE(op1); double result; PyFPE_START_PROTECT("add", return NULL) result = ((double)a) + (double)b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); } #endif /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* CalculateMetaclass */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); for (i=0; i < nbases; i++) { PyTypeObject *tmptype; PyObject *tmp = PyTuple_GET_ITEM(bases, i); tmptype = Py_TYPE(tmp); #if PY_MAJOR_VERSION < 3 if (tmptype == &PyClass_Type) continue; #endif if (!metaclass) { metaclass = tmptype; continue; } if (PyType_IsSubtype(metaclass, tmptype)) continue; if (PyType_IsSubtype(tmptype, metaclass)) { metaclass = tmptype; continue; } PyErr_SetString(PyExc_TypeError, "metaclass conflict: " "the metaclass of a derived class " "must be a (non-strict) subclass " "of the metaclasses of all its bases"); return NULL; } if (!metaclass) { #if PY_MAJOR_VERSION < 3 metaclass = &PyClass_Type; #else metaclass = &PyType_Type; #endif } Py_INCREF((PyObject*) metaclass); return (PyObject*) metaclass; } /* FetchCommonType */ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* fake_module; PyTypeObject* cached_type = NULL; fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); if (!fake_module) return NULL; Py_INCREF(fake_module); cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); if (cached_type) { if (!PyType_Check((PyObject*)cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", type->tp_name); goto bad; } if (cached_type->tp_basicsize != type->tp_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", type->tp_name); goto bad; } } else { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); if (PyType_Ready(type) < 0) goto bad; if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) goto bad; Py_INCREF(type); cached_type = type; } done: Py_DECREF(fake_module); return cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } /* CythonFunction */ #include <structmember.h> static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) { if (unlikely(op->func_doc == NULL)) { if (op->func.m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); #else op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); #endif if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } } Py_INCREF(op->func_doc); return op->func_doc; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp = op->func_doc; if (value == NULL) { value = Py_None; } Py_INCREF(value); op->func_doc = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { if (unlikely(op->func_name == NULL)) { #if PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); #else op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = op->func_name; Py_INCREF(value); op->func_name = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { Py_INCREF(op->func_qualname); return op->func_qualname; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } tmp = op->func_qualname; Py_INCREF(value); op->func_qualname = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) { PyObject *self; self = m->func_closure; if (self == NULL) self = Py_None; Py_INCREF(self); return self; } static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } static int __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; if (unlikely(value == NULL)) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } tmp = op->func_dict; Py_INCREF(value); op->func_dict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } Py_INCREF(value); tmp = op->defaults_tuple; op->defaults_tuple = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } Py_INCREF(value); tmp = op->defaults_kwdict; op->defaults_kwdict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { PyObject* tmp; if (!value || value == Py_None) { value = NULL; } else if (!PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); tmp = op->func_annotations; op->func_annotations = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(m->func.m_ml->ml_name); #else return PyString_FromString(m->func.m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if PY_VERSION_HEX < 0x030500A0 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) #endif static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); if (op == NULL) return NULL; op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; op->func.m_ml = ml; op->func.m_self = (PyObject *) op; Py_XINCREF(closure); op->func_closure = closure; Py_XINCREF(module); op->func.m_module = module; op->func_dict = NULL; op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; op->func_classobj = NULL; op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; PyObject_GC_Track(op); return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); Py_CLEAR(m->func.m_module); Py_CLEAR(m->func_dict); Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); Py_CLEAR(m->func_classobj); Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_XDECREF(pydefaults[i]); PyObject_Free(m->defaults); m->defaults = NULL; } return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); PyObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); Py_VISIT(m->func.m_module); Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); Py_VISIT(m->func_code); Py_VISIT(m->func_classobj); Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_VISIT(pydefaults[i]); } return 0; } static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { Py_INCREF(func); return func; } if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { if (type == NULL) type = (PyObject *)(Py_TYPE(obj)); return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); } if (obj == Py_None) obj = NULL; return __Pyx_PyMethod_New(func, obj, type); } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("<cyfunction %U at %p>", op->func_qualname, (void *)op); #else return PyString_FromFormat("<cyfunction %s at %p>", PyString_AsString(op->func_qualname), (void *)op); #endif } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; Py_ssize_t size; switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 0)) return (*meth)(self, NULL); PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags in " "__Pyx_CyFunction_Call. METH_OLDARGS is no " "longer supported!"); return NULL; } PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; argc = PyTuple_GET_SIZE(args); new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, (destructor) __Pyx_CyFunction_dealloc, 0, 0, 0, #if PY_MAJOR_VERSION < 3 0, #else 0, #endif (reprfunc) __Pyx_CyFunction_repr, 0, 0, 0, 0, __Pyx_CyFunction_CallAsMethod, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, 0, (traverseproc) __Pyx_CyFunction_traverse, (inquiry) __Pyx_CyFunction_clear, 0, #if PY_VERSION_HEX < 0x030500A0 offsetof(__pyx_CyFunctionObject, func_weakreflist), #else offsetof(PyCFunctionObject, m_weakreflist), #endif 0, 0, __pyx_CyFunction_methods, __pyx_CyFunction_members, __pyx_CyFunction_getsets, 0, 0, __Pyx_CyFunction_descr_get, 0, offsetof(__pyx_CyFunctionObject, func_dict), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if PY_VERSION_HEX >= 0x030400a1 0, #endif #if PY_VERSION_HEX >= 0x030800b1 0, #endif }; static int __pyx_CyFunction_init(void) { __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); if (unlikely(__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_Malloc(size); if (unlikely(!m->defaults)) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* Py3ClassCreate */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); if (prep) { PyObject *pargs = PyTuple_Pack(2, name, bases); if (unlikely(!pargs)) { Py_DECREF(prep); return NULL; } ns = PyObject_Call(prep, pargs, mkw); Py_DECREF(prep); Py_DECREF(pargs); } else { if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; PyErr_Clear(); ns = PyDict_New(); } } else { ns = PyDict_New(); } if (unlikely(!ns)) return NULL; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; return ns; bad: Py_DECREF(ns); return NULL; } static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass) { PyObject *result, *margs; PyObject *owned_metaclass = NULL; if (allow_py2_metaclass) { owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); if (owned_metaclass) { metaclass = owned_metaclass; } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { PyErr_Clear(); } else { return NULL; } } if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); Py_XDECREF(owned_metaclass); if (unlikely(!metaclass)) return NULL; owned_metaclass = metaclass; } margs = PyTuple_Pack(3, name, bases, dict); if (unlikely(!margs)) { result = NULL; } else { result = PyObject_Call(metaclass, margs, mkw); Py_DECREF(margs); } Py_XDECREF(owned_metaclass); return result; } /* CyFunctionClassCell */ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) { Py_ssize_t i, count = PyList_GET_SIZE(cyfunctions); for (i = 0; i < count; i++) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS PyList_GET_ITEM(cyfunctions, i); #else PySequence_ITEM(cyfunctions, i); if (unlikely(!m)) return -1; #endif Py_INCREF(classobj); m->func_classobj = classobj; #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF((PyObject*)m); #endif } return 0; } /* CLineInTraceback */ #ifndef CYTHON_CLINE_IN_TRACEBACK static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif if (unlikely(!__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, *cython_runtime_dict, __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { PyErr_Clear(); use_cline = NULL; } } if (!use_cline) { c_line = 0; PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = a->tp_base; if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } #if PY_MAJOR_VERSION == 2 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { PyObject *exception, *value, *tb; int res; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&exception, &value, &tb); res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } if (!res) { res = PyObject_IsSubclass(err, exc_type2); if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } } __Pyx_ErrRestore(exception, value, tb); return res; } #else static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; if (!res) { res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } return res; } #endif static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i<n; i++) { if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; } #endif for (i=0; i<n; i++) { PyObject *t = PyTuple_GET_ITEM(tuple, i); #if PY_MAJOR_VERSION < 3 if (likely(exc_type == t)) return 1; #endif if (likely(PyExceptionClass_Check(t))) { if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; } else { } } return 0; } static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { if (likely(err == exc_type)) return 1; if (likely(PyExceptionClass_Check(err))) { if (likely(PyExceptionClass_Check(exc_type))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); } else if (likely(PyTuple_Check(exc_type))) { return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); } else { } } return PyErr_GivenExceptionMatches(err, exc_type); } static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { assert(PyExceptionClass_Check(exc_type1)); assert(PyExceptionClass_Check(exc_type2)); if (likely(err == exc_type1 || err == exc_type2)) return 1; if (likely(PyExceptionClass_Check(err))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); } return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); } #endif /* CStringEquals */ static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) { while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } return *s1 == *s2; } /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } /* InitStrings */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #if !CYTHON_PEP393_ENABLED static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; } #else static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif } #endif #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { #if PY_MAJOR_VERSION >= 3 if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type %.200s). " "The ability to return an instance of a strict subclass of int " "is deprecated, and may be removed in a future version of Python.", Py_TYPE(result)->tp_name)) { Py_DECREF(result); return NULL; } return result; } #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", type_name, type_name, Py_TYPE(result)->tp_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x) || PyLong_Check(x))) #else if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; res = m->nb_long(x); } #else if (likely(m && m->nb_int)) { name = "int"; res = m->nb_int(x); } #endif #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Int(x); } #endif if (likely(res)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else if (unlikely(!PyLong_CheckExact(res))) { #endif return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */
45.215636
481
0.653244
[ "object" ]
207522e45646694b05c178bfeb0b64c9e8af50a2
117,187
h
C
Config/include/mtf/Config/parameters.h
abhineet123/MTF
6cb45c88d924fb2659696c3375bd25c683802621
[ "BSD-3-Clause" ]
100
2016-12-11T00:34:06.000Z
2022-01-27T23:03:40.000Z
Config/include/mtf/Config/parameters.h
siqiyan/MTF
9a76388c907755448bb7223420fe74349130f636
[ "BSD-3-Clause" ]
21
2017-09-04T06:27:13.000Z
2021-07-14T19:07:23.000Z
Config/include/mtf/Config/parameters.h
siqiyan/MTF
9a76388c907755448bb7223420fe74349130f636
[ "BSD-3-Clause" ]
21
2017-02-19T02:12:11.000Z
2020-09-23T03:47:55.000Z
#ifndef MTF_PARAMETERS_H #define MTF_PARAMETERS_H //#include <cstddef> #include <stdio.h> #include <stdlib.h> #include <vector> #include <iostream> #include "boost/filesystem/operations.hpp" #include "opencv2/core/core.hpp" #include "mtf/Macros/common.h" #include "datasets.h" namespace fs = boost::filesystem; #define VID_FNAME "nl_bookI_s3" #define VID_FMT "mpg" #define IMG_FOLDER "nl_bookI_s3" #define IMG_FMT "jpg" #define ROOT_FOLDER "../../Datasets/TMT" #define FW_DEV_NAME "firewire_cam" #define FW_DEV_PATH "/dev/fw1" #define FW_DEV_FMT "i1V1f7o3r150" #define USB_DEV_NAME "usb_cam" #define USB_DEV_PATH "/dev/video0" #define USB_DEV_FMT "I1B4r0N0" #define CV_CAM_ID 0 #define CASCADE_MAX_TRACKERS 10 #define MAX_ABS_PATH 500 #define parse_param(param_name, param_func)\ do{if(!strcmp(arg_name, #param_name)){\ param_name = param_func(arg_val);\ return;\ }} while(0) #define parse_param_vec(param_name, param_func)\ do{if(!strcmp(arg_name, #param_name)){\ param_name.push_back(param_func(arg_val));\ return;\ }} while(0) #define parse_cfg(fname) \ fargc = readParams(fargv, (config_dir + "/" + fname).c_str());\ if(fargc){\ if(!parseArgumentPairs(fargv.data(), fargc)){\ printf("Error in parsing %s\n", fname);\ return false;\ }\ fargv.clear();\ } #define atof32(x) static_cast<float>(atof(x)) namespace mtf{ namespace params{ // folder where the config files mtf.cfg, modules.cfg and multi.cfg are located std::string config_dir = "Config"; /* default parameters */ int seq_id = 0; int actor_id = 0; std::string db_root_path = "../../../Datasets"; std::string actor; std::string seq_path; std::string seq_name; std::string seq_fmt; bool invert_seq = false; unsigned int n_trackers = 1; bool track_single_obj = false; char pipeline = 'c'; char img_source = 'u'; double img_resize_factor = 1.0; int input_buffer_size = 10; int buffer_id = 0; //! flags int mtf_visualize = 1; int pause_after_frame = 0; bool print_corners = false; bool print_fps = false; int show_corner_ids = 0; int show_ground_truth = 0; int reinit_gt_from_bin = 1; int read_obj_from_file = 0; int read_obj_from_gt = 1; bool sel_quad_obj = false; int line_thickness = 2; int record_frames = 0; bool gt_write_ssm_params = false; int write_tracking_data = 0; bool overwrite_gt = 0; int show_proc_img = 0; int write_objs = 0; char rec_source = 'u'; std::string rec_seq_suffix; int rec_fps = 24; std::vector<std::string> tracker_labels; int reinit_at_each_frame = 0; int reset_at_each_frame = 0; bool reset_to_init = false; int reinit_on_failure = false; double reinit_err_thresh = 5.0; int reinit_frame_skip = 5; bool reinit_with_new_obj = false; bool use_reinit_gt = false; bool use_opt_gt = false; std::string opt_gt_ssm = "2"; int debug_mode = 0; int reset_template = 0; int patch_size = 0; std::string read_obj_fname = "sel_objs/selected_objects.txt"; std::string write_obj_fname = "sel_objs/selected_objects.txt"; std::string tracking_data_fname; std::string record_frames_fname, record_frames_dir; //! for Xvision trackers int xv_visualize = 0; int xv_steps_per_frame = 1; /* only for pyramidal trackers */ int xv_no_of_levels = 2; double xv_scale = 0.5; /* for xvision grid tracker */ int xv_patch_size = 32; int xv_tracker_type = 't'; int xvg_grid_size_x = 4; int xvg_grid_size_y = -1; int xvg_reset_pos = 0; int xvg_reset_wts = 0; double xvg_sel_reset_thresh = 1.0; int xvg_pause_after_line = 0; int xvg_show_tracked_pts = 0; int xvg_use_constant_slope = 0; int xvg_use_ls = 0; int xvg_update_wts = 0; double xvg_inter_alpha_thresh = 0.10; double xvg_intra_alpha_thresh = 0.05; int xvg_adjust_grid = 0; int xvg_adjust_lines = 1; //! for MTF unsigned int mtf_res = 50; unsigned int resx = 50; unsigned int resy = 50; int init_frame_id = 0; int start_frame_id = 0; int end_frame_id = 0; int frame_gap = 1; int max_iters = 10; double epsilon = 0.01; char* mtf_sm = "esm"; char* mtf_am = "ssd"; char* mtf_ssm = "8"; char* mtf_ilm = "0"; bool enable_nt = false; bool invalid_state_check = true; double invalid_state_err_thresh = 0; bool uchar_input = false; bool ic_update_ssm = true; bool ic_chained_warp = true; int ic_hess_type = 0; bool fc_chained_warp = false; int fc_hess_type = 1; bool fc_write_ssm_updates = false; bool fc_show_grid = false; bool fc_show_patch = false; double fc_patch_resize_factor = 1.0; bool fc_debug_mode = false; int fa_hess_type = 1; bool fa_show_grid = false; bool fa_show_patch = false; double fa_patch_resize_factor = 1.0; bool fa_write_frames = false; int ia_hess_type = 1; int esm_jac_type = 1; int esm_hess_type = 2; bool esm_chained_warp = false; bool sec_ord_hess = false; bool leven_marq = false; double lm_delta_init = 0.01; double lm_delta_update = 10; bool enable_learning = false; double learning_rate = 0.5; bool ssd_show_template = false; double nssd_norm_pix_min = 0.0; double nssd_norm_pix_max = 1.0; double zncc_likelihood_alpha = 50; double res_from_size = 0; int show_tracking_error = 0; int write_tracking_error = 0; int write_tracking_sr = 0; vectord sr_err_thresh; vector_s obj_cols; std::string fps_col = "green"; std::string gt_col = "green"; std::string err_col = "green"; int tracking_err_type = 0; bool show_jaccard_error = false; double grad_eps = 1e-8; double hess_eps = 1.0; double likelihood_alpha = 1.0; double likelihood_beta = 0.0; bool dist_from_likelihood = false; std::string pre_proc_type = "gauss"; //! perform histogram equalization during pre processing; bool pre_proc_hist_eq = false; //! Gaussian filtering int gauss_kernel_size = 5; double gauss_sigma_x = 3; double gauss_sigma_y = 3; //! median filtering int med_kernel_size = 5; //! normalized box filtering int box_kernel_size = 5; //! bilateral filtering int bil_diameter = 5; double bil_sigma_col = 15; double bil_sigma_space = 15; //! Sobel filtering int sobel_kernel_size = 5; bool sobel_normalize = false; //! Anisotropic diffusion double aniso_lambda = 0.14285714285; double aniso_kappa = 30; unsigned int aniso_n_iters = 15; //! Affine int aff_normalized_init = 0; int aff_pt_based_sampling = 0; //! Lie Affine int laff_normalized_init = 0; double laff_grad_eps = 1e-8; //! Homograhy int hom_normalized_init = 0; bool hom_corner_based_sampling = true; //! Lie Homograhy int lhom_normalized_init = 0; double lhom_grad_eps = 1e-8; //! Corner based Homograhy int cbh_normalized_init = 0; double cbh_grad_eps = 1e-8; //! ASRT bool asrt_normalized_init = false; int asrt_pt_based_sampling = 0; //! Similitude bool sim_normalized_init = false; bool sim_geom_sampling = true; int sim_pt_based_sampling = 0; int sim_n_model_pts = 2; //! Isometry int iso_pt_based_sampling = 0; //! SL3 int sl3_normalized_init = 0; bool sl3_iterative_sample_mean = true; int sl3_sample_mean_max_iters = 10; double sl3_sample_mean_eps = 1e-4; bool sl3_debug_mode = 0; //! Spline SSM int spl_control_size = 10; double spl_control_overlap = 1; int spl_interp_type = 0; bool spl_static_wts = true; bool spl_debug_mode = 0; //! SCV and RSCV int scv_hist_type = 0; bool scv_use_bspl = 0; int scv_n_bins = 256; double scv_preseed = 0; bool scv_pou = 1; bool scv_weighted_mapping = 1; bool scv_mapped_gradient = 1; bool scv_affine_mapping = 0; bool scv_once_per_frame = 0; bool scv_approx_dist_feat = true; double scv_likelihood_alpha = 0; //! LSCV and LRSCV int lscv_sub_regions = 3; int lscv_spacing = 10; bool lscv_show_subregions = false; //! LKLD int lkld_n_bins = 8; double lkld_pre_seed = 0.1; bool lkld_pou = 1; int lkld_sub_regions = 0; int lkld_spacing = 1; //! NCC bool ncc_fast_hess = false; double ncc_likelihood_alpha = 50; //! SPSS double spss_k = 0.01; double spss_likelihood_alpha = 50; //! SSIM int ssim_pix_proc_type = 0; double ssim_k1 = 0.01; double ssim_k2 = 0.03; double ssim_likelihood_alpha = 50; //! Sum of AMs std::string sum_am1, sum_am2; char *pix_mapper = nullptr; //! MI & CCRE int mi_n_bins = 8; double mi_pre_seed = 10; bool mi_pou = false; double mi_likelihood_alpha = 50; //! CCRE int ccre_n_bins = 8; double ccre_pre_seed = 10; bool ccre_pou = false; bool ccre_symmetrical_grad = false; int ccre_n_blocks = 0; double ccre_likelihood_alpha = 50; //!NGF double ngf_eta = 5.0; bool ngf_use_ssd = false; //! NN int nn_max_iters = 10; int nn_n_samples = 1000; vectori nn_ssm_sigma_ids; vectori nn_ssm_mean_ids; double nn_corner_sigma_d = 0.04; double nn_corner_sigma_t = 0.06; vectord nn_pix_sigma; int nn_n_trees = 6; double nn_ssm_sigma_prec = 1.1; int nn_index_type = 1; int nn_search_type = 0; bool nn_additive_update = false; int nn_show_samples = 0; int nn_add_samples_gap = 0; int nn_n_samples_to_add = 0; int nn_remove_samples = 0; bool nn_save_index = false; bool nn_load_index = false; int nn_saved_index_fid = 0; //! GNN int nn_gnn_degree = 250; int nn_gnn_max_steps = 10; int nn_gnn_cmpt_dist_thresh = 10000; bool nn_gnn_random_start = false; bool nn_gnn_verbose = false; int nn_fgnn_index_type = 0; //! FLANN specific params int nn_srch_checks = 32; float nn_srch_eps = 0.0; bool nn_srch_sorted = true; int nn_srch_max_neighbors = -1; int nn_srch_cores = 1; bool nn_srch_matrices_in_gpu_ram = false; int nn_srch_use_heap = 2; int nn_kdt_trees = 6; int nn_km_branching = 32; int nn_km_iterations = 11; int nn_km_centers_init = 0; float nn_km_cb_index = 0.2f; int nn_kdts_leaf_max_size = 10; int nn_kdtc_leaf_max_size = 64; int nn_hc_branching = 32; int nn_hc_trees = 4; int nn_hc_leaf_max_size = 100; int nn_hc_centers_init = 0; float nn_auto_target_precision = 0.9f; float nn_auto_build_weight = 0.01f; float nn_auto_memory_weight = 0.0f; float nn_auto_sample_fraction = 0.1f; // Multi Layer Nearest Filter int nnk_n_layers; vectorvi nnk_ssm_sigma_ids; //! Regression Network int rg_max_iters = 10; int rg_n_samples = 1000; vectori rg_ssm_sigma_ids; vectori rg_ssm_mean_ids; vectord rg_pix_sigma; bool rg_additive_update = false; int rg_show_samples = 0; int rg_add_points = 0; int rg_remove_points = 0; bool rg_save_index = false; bool rg_load_index = false; int rg_saved_index_fid = 0; int rg_nepochs = 10; int rg_bs = 128; bool rg_preproc = true; char *rg_solver = nullptr; char *rg_train = nullptr; char *rg_mean = nullptr; bool rg_dbg = false; bool rg_pretrained = false; //! RIU AM double riu_likelihood_alpha = 50.0; //! Gradient Descent double sd_learning_rate = 0.1; //! Gain and Bias Illumination Model bool gb_additive_update = false; //! Piecewise Gain and Bias Illumination Model bool pgb_additive_update = false; int pgb_sub_regions_x = 3; int pgb_sub_regions_y = 3; //! Radial Basis Function illumination model bool rbf_additive_update = false; int rbf_n_ctrl_pts_x = 3; int rbf_n_ctrl_pts_y = 3; //! Particle Filter int pf_max_iters = 1; int pf_n_particles = 100; int pf_dynamic_model = 1; int pf_update_type = 0; int pf_likelihood_func = 0; int pf_resampling_type = 0; int pf_mean_type = 1; bool pf_reset_to_mean = false; vectori pf_ssm_sigma_ids; vectori pf_ssm_mean_ids; bool pf_update_distr_wts = false; double pf_min_distr_wt = 0.1; double pf_adaptive_resampling_thresh = 0; double pf_measurement_sigma = 0.1; vectord pf_pix_sigma; int pf_show_particles = 0; bool pf_jacobian_as_sigma = false; bool pf_debug_mode = false; //! Multi Layer Particle Filter int pfk_n_layers; vectorvi pfk_ssm_sigma_ids; //! Gaussian parameters for sampling SSM parameters - used by NN, PF and RG vectorvd ssm_sigma; vectorvd ssm_mean; vectorvd am_sigma; vectorvd am_mean; //! Hierarchical SSM tracker char* hrch_sm = "iclk"; char* hrch_am = "ssd"; //! Cascade tracker int casc_n_trackers = 2; bool casc_enable_feedback = 1; bool casc_auto_reinit = false; double casc_reinit_err_thresh = 1.0; int casc_reinit_frame_gap = 1; //! Grid tracker char* grid_sm = "iclk"; char* grid_am = "ssd"; char* grid_ssm = "2"; char* grid_ilm = "0"; int grid_res = 10; int grid_patch_size = 10; int grid_patch_res = 0; int grid_reset_at_each_frame = 1; bool grid_dyn_patch_size = false; bool grid_patch_centroid_inside = true; double grid_fb_err_thresh = 0; bool grid_fb_reinit = 0; bool grid_show_trackers = false; bool grid_show_tracker_edges = false; bool grid_use_tbb = true; //! OpenCV grid tracker int grid_pyramid_levels = 2; bool grid_use_min_eig_vals = 0; bool grid_rgb_input = false; double grid_min_eig_thresh = 1e-4; std::string feat_detector_type = "orb"; std::string feat_descriptor_type = "orb"; double feat_max_dist_ratio = 0.75; int feat_min_matches = 10; bool feat_rebuild_index = false; bool feat_use_cv_flann = true; bool feat_show_keypoints = 0; bool feat_show_matches = 0; bool feat_debug_mode = 0; bool grid_use_const_grad = true; int sift_n_features = 0; int sift_n_octave_layers = 3; double sift_contrast_thresh = 0.04; double sift_edge_thresh = 10; double sift_sigma = 1.6; double surf_hessian_threshold = 100; int surf_n_octaves = 4; int surf_n_octave_layers = 3; bool surf_extended = false; bool surf_upright = false; int brisk_thresh = 30; int brisk_octaves = 3; float brisk_pattern_scale = 1.0f; int orb_n_features = 500; float orb_scale_factor = 1.2f; int orb_n_levels = 8; int orb_edge_threshold = 31; int orb_first_level = 0; int orb_WTA_K = 2; int orb_score_type = 0; int orb_patch_size = 31; int orb_fast_threshold = 20; int mser_delta = 5; int mser_min_area = 60; int mser_max_area = 14400; double mser_max_variation = 0.25; double mser_min_diversity = .2; int mser_max_evolution = 200; double mser_area_threshold = 1.01; double mser_min_margin = 0.003; int mser_edge_blur_size = 5; int fast_threshold = 10; bool fast_non_max_suppression = true; int fast_type = 2; int agast_threshold = 10; bool agast_non_max_suppression = true; int agast_type = 3; int gftt_max_corners = 1000; double gftt_quality_level = 0.01; double gftt_min_distance = 1; int gftt_block_size = 3; bool gftt_use_harris_detector = false; double gftt_k = 0.04; int brief_bytes = 32; bool brief_use_orientation = false; bool freak_orientation_normalized = true; bool freak_scale_normalized = true; float freak_pattern_scale = 22.0f; int freak_n_octaves = 4; int lucid_kernel = 1; int lucid_blur_kernel = 2; int latch_bytes = 32; bool latch_rotation_invariance = true; int latch_half_ssd_size = 3; float daisy_radius = 15; int daisy_q_radius = 3; int daisy_q_theta = 8; int daisy_q_hist = 8; int daisy_norm = 100; vectorf daisy_H; bool daisy_interpolation = true; bool daisy_use_orientation = false; int vgg_desc = 100; float vgg_isigma = 1.4f; bool vgg_img_normalize = true; bool vgg_use_scale_orientation = true; float vgg_scale_factor = 6.25f; bool vgg_dsc_normalize = false; int boost_desc_desc = 302; bool boost_desc_use_scale_orientation = true; float boost_desc_scale_factor = 6.25f; int star_max_size = 45; int star_response_threshold = 30; int star_line_threshold_projected = 10; int star_line_threshold_binarized = 8; int star_suppress_nonmax_size = 5; int msd_patch_radius = 3; int msd_search_area_radius = 5; int msd_nms_radius = 5; int msd_nms_scale_radius = 0; float msd_th_saliency = 250.0f; int msd_kNN = 4; float msd_scale_factor = 1.25f; int msd_n_scales = -1; bool msd_compute_orientation = false; //! SSM Estimator int est_method = 0; double est_ransac_reproj_thresh = 10; int est_n_model_pts = 4; int est_max_iters = 2000; int est_max_subset_attempts = 300; bool est_use_boost_rng = false; double est_confidence = 0.995; bool est_refine = true; int est_lm_max_iters = 10; char* line_sm = "iclk"; char* line_am = "ssd"; char* line_ssm = "2"; int line_grid_size = 5; int line_patch_size = 25; bool line_use_constant_slope = false; bool line_use_ls = false; double line_inter_alpha_thresh = 0.1; double line_intra_alpha_thresh = 0.05; bool line_reset_pos = false; bool line_reset_template = false; bool line_debug_mode = false; //! RKL Tracker char* rkl_sm = "iclk"; bool rkl_enable_spi = true; bool rkl_enable_feedback = true; bool rkl_failure_detection = true; double rkl_failure_thresh = 15.0; //! Parallel Tracker int prl_n_trackers = 1; int prl_estimation_method = 0; bool prl_reset_to_mean = false; bool prl_auto_reinit = false; double prl_reinit_err_thresh = 1.0; int prl_reinit_frame_gap = 1; //! Pyramidal Tracker std::string pyr_sm = "fc"; int pyr_no_of_levels = 3; double pyr_scale_factor = 0.50; bool pyr_scale_res = true; bool pyr_show_levels = false; //! MTF Diagnostics char* diag_am = "ssd"; char* diag_ssm = "2"; char* diag_ilm = "0"; bool diag_3d = false; std::vector<int> diag_3d_ids = { 0, 1 }; int diag_frame_gap = 0; double diag_range = 0; std::vector<double> diag_ssm_range; std::vector<double> diag_am_range; int diag_ssm_range_id = 0; int diag_am_range_id = 0; std::string diag_gen_norm = "000";// Norm,FeatNorm std::string diag_gen_jac = "000";// Std,ESM,Diff std::string diag_gen_hess = "0000";// Std,ESM,InitSelf,CurrSelf std::string diag_gen_hess2 = "0000";// Std2,ESM2,InitSelf2,CurrSelf2 std::string diag_gen_hess_sum = "0000";// Std, Std2, Self, Self2 std::string diag_gen_num = "000"; // Jac, Hess, NHess std::string diag_gen_ssm = "0";// ssm params bool diag_bin = true; bool diag_inv = true; bool diag_show_data = false; bool diag_show_corners = false; bool diag_show_patches = false; bool diag_verbose = false; double diag_grad_diff = 0.1; int diag_res = 50; int diag_update_type = 0; int diag_start_id = 0; int diag_end_id = 0; std::string diag_out_prefix; bool diag_enable_validation = false; double diag_validation_prec = 1e-20; bool esm_spi_enable = false; double esm_spi_thresh = 10; //! DSST double dsst_padding = 1; double dsst_sigma = 1.0 / 16; double dsst_scale_sigma = 1.0 / 4; double dsst_lambda = 1e-2; double dsst_learning_rate = 0.025; int dsst_number_scales = 33; int dsst_number_rots = 21; double dsst_scale_step = 1.02; double dsst_rot_step = 2; int dsst_resize_factor = 4; int dsst_is_scaling = 1; int dsst_is_rotating = 1; int dsst_bin_size = 1; //! KCF double kcf_padding; //extra area surrounding the target double kcf_lambda; //regularization double kcf_output_sigma_factor; //spatial bandwidth (proportional to target) double kcf_interp_factor; //linear interpolation factor for adaptation double kcf_kernel_sigma; //gaussian kernel bandwidth //! for scaling int kcf_number_scales; double kcf_scale_step; double kcf_scale_model_max_area; double kcf_scale_sigma_factor; double kcf_scale_learning_rate; bool kcf_is_scaling; int kcf_resize_factor; int mil_algorithm = 100; int mil_num_classifiers = 100; float mil_overlap = 0.99f; float mil_search_factor = 2.0f; float mil_pos_radius_train = 4.0f; int mil_neg_num_train = 65; int mil_num_features = 250; //! CMT bool cmt_estimate_scale = true; bool cmt_estimate_rotation = false; char* cmt_feat_detector = "FAST"; char* cmt_desc_extractor = "BRISK"; double cmt_resize_factor = 0.5; //! TLD bool tld_tracker_enabled = true; bool tld_detector_enabled = true; bool tld_learning_enabled = true; bool tld_alternating = false; //! RCT int rct_min_n_rect = 2; int rct_max_n_rect = 4; int rct_n_feat = 50; int rct_rad_outer_pos = 4; int rct_rad_search_win = 25; double rct_learning_rate = 0.85; std::string strk_config_path = "Config/struck.cfg"; //! ViSP Template Tracker char* vptt_sm = "fclk"; char* vptt_am = "ssd"; char* vptt_ssm = "8"; int vptt_max_iters = 30; int vptt_res = 50; double vptt_lambda = 0.001; double vptt_thresh_grad = 60; int vptt_pyr_n_levels = 0; int vptt_pyr_level_to_stop = 1; //! ViSP Pipeline int vp_usb_n_buffers = 3; std::string vp_usb_res = "0"; std::string vp_usb_fps = "0"; std::string vp_fw_res = "0"; std::string vp_fw_fps = "0"; std::string vp_fw_depth = "0"; std::string vp_fw_iso = "0"; bool vp_fw_print_info; float vp_pg_fw_shutter_ms; float vp_pg_fw_gain; float vp_pg_fw_exposure; float vp_pg_fw_brightness; //! OpenCV 3 Tracking std::string cv3_tracker_type = "mil"; //! PFSL3 int pfsl3_p_x = 40; int pfsl3_p_y = 40; double pfsl3_rot = 0; double pfsl3_ncc_std = 0.1; double pfsl3_pca_std = 10; std::vector<double> pfsl3_state_std; double pfsl3_ar_p = 0.5; int pfsl3_n = 40; int pfsl3_n_c = 10; int pfsl3_n_iter = 5; int pfsl3_sampling = 0; int pfsl3_capture = 0; int pfsl3_mean_check = 0; int pfsl3_outlier_flag = 0; int pfsl3_len = 100; int pfsl3_init_size = 15; int pfsl3_update_period = 5; float pfsl3_ff = 0.99f; double pfsl3_basis_thr = 0.95; int pfsl3_max_num_basis = 30; int pfsl3_max_num_used_basis = 10; bool pfsl3_show_weights = false; bool pfsl3_show_templates = false; bool pfsl3_debug_mode = false; //! GOTURN bool gtrn_do_train = true; int gtrn_gpu_id = 0; bool gtrn_show_intermediate_output = false; std::string gtrn_model_file = "Data/GOTURN/tracker.prototxt"; std::string gtrn_trained_file = "Data/GOTURN/solver.prototxt"; //! DFT float dft_res_to_l = 1e-10f; float dft_p_to_l = 5e-5f; int dft_max_iter = 50; int dft_max_iter_single_level = 10; std::vector<float> dft_pyramid_smoothing_variance = { 7 }; float dft_presmoothing_variance = 1; int dft_n_control_points_on_edge = 25; bool dft_b_adaptative_choice_of_points = 0; bool dft_b_normalize_descriptors = 0; int dft_optimization_type = 2; int frg_n_bins = 16; int frg_search_margin = 7; int frg_hist_cmp_metric = 3; double frg_resize_factor = 0.5; bool frg_show_window = false; //! PCA Patch Extraction std::vector<int> extracted_frame_ids = { 0, 1, 2, 3, 4 }; int extraction_id = 0; // PCA int pca_n_eigenvec = 16; int pca_batchsize = 5; float pca_f_factor = 0.95f; bool pca_show_basis = false; //! DFM int dfm_nfmaps = 1; char* dfm_layer_name = "conv1"; int dfm_vis = 0; int dfm_zncc = 0; char *dfm_model_f_name = "../../../VGG_Models/VGG_deploy.prototxt"; char *dfm_params_f_name = "../../../VGG_Models/VGG_CNN_F.caffemodel"; char *dfm_mean_f_name = "../../../VGG_Models/VGG_mean.binaryproto"; //! SPI int spi_type = 0; double spi_pix_diff_thresh = 10; double spi_grad_thresh = 0.005; bool spi_grad_use_union = false; // GFTT int spi_gftt_max_corners = 1000; double spi_gftt_quality_level = 0.01; double spi_gftt_min_distance = 0; int spi_gftt_block_size = 3; bool spi_gftt_use_harris_detector = false; double spi_gftt_k = 0.04; // SPI with GFTT bool spi_gftt_use_union = false; int spi_gftt_neigh_offset = 0; //! Registered sequence generator std::string reg_ssm = "8"; std::string reg_ilm = "0"; int reg_track_border = 0; bool reg_grayscale_img = false; bool reg_show_output = true; bool reg_save_as_video = false; int reg_video_fps = 24; //! Synthetic sequence generator std::string syn_ssm = "c8"; std::string syn_ilm = "0"; int syn_frame_id = 0; bool syn_grayscale_img = false; bool syn_continuous_warping = true; vectori syn_ssm_sigma_ids, syn_ssm_mean_ids; vectori syn_am_sigma_ids, syn_am_mean_ids; double syn_pix_sigma = 0; bool syn_am_on_obj = false; bool syn_warp_entire_image = false; int syn_background_type = 0; bool syn_use_inv_warp = false; std::string syn_out_suffix; int syn_n_frames = 1; bool syn_add_noise = true; double syn_noise_mean = 0.0; double syn_noise_sigma = 1.0; bool syn_save_as_video = false; int syn_video_fps = 24; int syn_jpg_quality = 100; bool syn_show_output = true; //! Online mosaic creator bool mos_inv_tracking = true; int mos_use_norm_corners = true; int mos_track_border = 100; int mos_border_width = 200; int mos_border_height = 200; int mos_init_offset_x = 0; int mos_init_offset_y = 0; int mos_disp_width = 200; int mos_disp_height = 200; bool mos_show_grid = false; bool mos_show_tracked_img = false; bool mos_show_patch = false; bool mos_show_mask = false; bool mos_use_write_mask = false; bool mos_save_img = true; std::string mos_out_fname; std::string mos_out_fmt = "jpg"; //! QR tracker std::vector<std::string> qr_input; std::string qr_root_dir = "Data/QRTracker"; std::string qr_detector_ssm = "4"; double qr_duplicate_min_dist = 50; double qr_min_size = 10; bool qr_init_with_rect = 1; int qr_n_markers = -1; //! pyMTF int py_visualize = 1; int py_live_init = 1; //! mexMTF int mex_visualize = 1; int mex_live_init = 1; inline void split(const std::string &s, char delim, std::vector<std::string> &elems) { stringstream ss(s); std::string item; while(getline(ss, item, delim)) { if(!item.empty()){ elems.push_back(item); } } } inline int readParams(std::vector<char*> &fargv, const char* fname = "mtf.cfg"){ #ifdef _WIN32 FILE *fid; errno_t err; if((err = fopen_s(&fid, fname, "r")) != 0) { printf("Parameter file: %s not found: %s\n", fname, strerror(err)); return 0; } #else FILE *fid = fopen(fname, "r"); if(!fid){ printf("\n Parameter file: %s not found\n", fname); return 0; } #endif // one extra entry at the beginning to maintain compatibilty with the C/C++ // command line argument convention fargv.push_back(nullptr); int arg_id = 0; while(!feof(fid)){ char *temp = new char[500]; fgets(temp, 500, fid); strtok(temp, "\n"); strtok(temp, "\r"); if(strlen(temp) <= 1 || temp[0] == '#'){ delete(temp); continue; } fargv.push_back(temp); ++arg_id; //printf("arg %d: %s\n", arg_id, fargv[arg_id]); } fclose(fid); return arg_id + 1; } inline void processStringParam(std::string &str_out, const char* param){ if(!strcmp(param, "#")){ // use default value return; } str_out = std::string(param); } inline void processStringParam(char* &str_out, const char* param){ //printf("-----------------------\n"); //printf("param: %s\n", param); //printf("use_default: %c\n", use_default); if(!strcmp(param, "#")){ // use default value return; } //if((strlen(param) == 2) && (param[0] == '0') && (param[1] == '0')){ // return; //} //if(str_out){ delete(str_out); } str_out = new char[strlen(param) + 1]; strcpy(str_out, param); //printf("str_out: %s\n", str_out); } // convert a string of comma (or other specified character) separated values // into a vector of doubles inline vectord atof_arr(char *str, const char *sep = ","){ char *param_str = strtok(str, sep); std::vector<double> param_arr; //printf("atof_arr::str: %s\n", str); //printf("atof_arr::param_arr:\n"); while(param_str){ double param_num = atof(param_str); param_arr.push_back(param_num); //printf("%f\t", param_num); param_str = strtok(nullptr, sep); } //printf("\n"); //std::string str_temp(str); //for(int i = 0; i < str_temp.length(); ++i){ // if(str_temp[i] == sep) // str_temp[i] = ' '; //} //printf("atof_arr::str_temp: %s\n", str_temp.c_str()); //std::stringstream ss(str); //double temp; //while(ss >> temp) // param_arr.push_back(temp); return param_arr; } inline vectorf atof32_arr(char *str, const char *sep = ","){ char *param_str = strtok(str, sep); std::vector<float> param_arr; while(param_str){ float param_num = atof32(param_str); param_arr.push_back(param_num); param_str = strtok(nullptr, sep); } return param_arr; } inline vectori atoi_arr(char *str, const char *sep = ","){ char *param_str = strtok(str, sep); std::vector<int> param_arr; //printf("atof_arr::str: %s\n", str); //printf("atof_arr::param_arr:\n"); while(param_str){ int param_num = atoi(param_str); param_arr.push_back(param_num); //printf("%f\t", param_num); param_str = strtok(nullptr, sep); } //printf("\n"); //std::string str_temp(str); //for(int i = 0; i < str_temp.length(); ++i){ // if(str_temp[i] == sep) // str_temp[i] = ' '; //} //printf("atof_arr::str_temp: %s\n", str_temp.c_str()); //std::stringstream ss(str); //double temp; //while(ss >> temp) // param_arr.push_back(temp); return param_arr; } inline vector_s string_arr(char *str, const char *sep = ","){ char *param_str = strtok(str, sep); vector_s param_arr; while(param_str){ param_arr.push_back(std::string(param_str)); param_str = strtok(nullptr, sep); } return param_arr; } inline char atoc(char *arg_val){ return arg_val[0]; } inline int atoc_i(char *arg_val){ return arg_val[0] - '0'; } inline void processAgrumentUnchained(char *arg_name, char *arg_val, char *arg_prefix = nullptr){ if(arg_val[0] == '#'){ return; } parse_param(n_trackers, atoi); parse_param(track_single_obj, atoi); parse_param(seq_id, atoi); parse_param(actor_id, atoi); parse_param(pipeline, atoc); parse_param(img_source, atoc); parse_param(rec_source, atoc); parse_param(rec_fps, atoi); parse_param(rec_seq_suffix, std::string); parse_param(img_resize_factor, atof); parse_param(gt_write_ssm_params, atoi); parse_param(write_tracking_data, atoc_i); parse_param(overwrite_gt, atoc_i); parse_param(tracking_data_fname, std::string); parse_param(record_frames_fname, std::string); parse_param(record_frames_dir, std::string); parse_param(read_obj_fname, std::string); parse_param(write_obj_fname, std::string); parse_param(mtf_visualize, atoc_i); parse_param(show_ground_truth, atoc_i); parse_param(xv_visualize, atoc_i); parse_param(read_obj_from_gt, atoi); parse_param(sel_quad_obj, atoi); } inline void processAgrument(char *arg_name, char *arg_val, char *arg_prefix = nullptr){ if(arg_val[0] == '#'){ return; } if(!strcmp(arg_name, "n_trackers")){ n_trackers = static_cast<unsigned int>(atoi(arg_val)); return; } if(!strcmp(arg_name, "track_single_obj")){ track_single_obj = atoi(arg_val); return; } if(!strcmp(arg_name, "source_id") || !strcmp(arg_name, "seq_id")){ seq_id = atoi(arg_val); return; } if(!strcmp(arg_name, "actor_id")){ actor_id = atoi(arg_val); return; } if(!strcmp(arg_name, "pipeline")){ pipeline = arg_val[0]; return; } if(!strcmp(arg_name, "img_source")){ img_source = arg_val[0]; return; } if(!strcmp(arg_name, "rec_source")){ rec_source = arg_val[0]; return; } if(!strcmp(arg_name, "rec_fps")){ rec_fps = atoi(arg_val); return; } if(!strcmp(arg_name, "rec_seq_suffix")){ rec_seq_suffix = std::string(arg_val); return; } if(!strcmp(arg_name, "img_resize_factor")){ img_resize_factor = atof(arg_val); return; } if(!strcmp(arg_name, "gt_write_ssm_params")){ gt_write_ssm_params = atoi(arg_val); return; } if(!strcmp(arg_name, "write_tracking_data")){ write_tracking_data = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "overwrite_gt")){ overwrite_gt = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "tracking_data_fname")){ tracking_data_fname = std::string(arg_val); return; } if(!strcmp(arg_name, "record_frames_fname")){ record_frames_fname = std::string(arg_val); return; } if(!strcmp(arg_name, "record_frames_dir")){ record_frames_dir = std::string(arg_val); return; } if(!strcmp(arg_name, "read_obj_fname")){ read_obj_fname = std::string(arg_val); return; } if(!strcmp(arg_name, "write_obj_fname")){ write_obj_fname = std::string(arg_val); return; } if(!strcmp(arg_name, "show_corner_ids")){ show_corner_ids = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "tracker_labels")){ tracker_labels.push_back(std::string(arg_val)); return; } if(!strcmp(arg_name, "mtf_visualize")){ mtf_visualize = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "show_ground_truth")){ show_ground_truth = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "xv_visualize")){ xv_visualize = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "read_obj_from_gt")){ read_obj_from_gt = atoi(arg_val); return; } if(!strcmp(arg_name, "sel_quad_obj")){ sel_quad_obj = atoi(arg_val); return; } if(!strcmp(arg_name, "line_thickness")){ line_thickness = atoi(arg_val); return; } if(!strcmp(arg_name, "reinit_gt_from_bin")){ reinit_gt_from_bin = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "read_obj_from_file")){ read_obj_from_file = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "write_objs")){ write_objs = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "record_frames")){ record_frames = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "source_name") || !strcmp(arg_name, "seq_name")){ seq_name = std::string(arg_val); return; } if(!strcmp(arg_name, "source_path") || !strcmp(arg_name, "seq_path")){ seq_path = std::string(arg_val); return; } if(!strcmp(arg_name, "source_fmt") || !strcmp(arg_name, "seq_fmt")){ seq_fmt = std::string(arg_val); return; } if(!strcmp(arg_name, "invert_seq")){ invert_seq = atoi(arg_val); return; } if(!strcmp(arg_name, "patch_size")){ patch_size = atoi(arg_val); return; } if(!strcmp(arg_name, "db_root_path") || !strcmp(arg_name, "root_path")){ db_root_path = std::string(arg_val); return; } //! Xvision trackers if(!strcmp(arg_name, "xv_scale")){ xv_scale = atof(arg_val); return; } if(!strcmp(arg_name, "xv_no_of_levels")){ xv_no_of_levels = atoi(arg_val); return; } if(!strcmp(arg_name, "xv_steps_per_frame")){ xv_steps_per_frame = atoi(arg_val); return; } if(!strcmp(arg_name, "xv_patch_size")){ xv_patch_size = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_grid_size_x")){ xvg_grid_size_x = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_grid_size_y")){ xvg_grid_size_y = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_adjust_grid")){ xvg_adjust_grid = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "xvg_adjust_lines")){ xvg_adjust_lines = arg_val[0] - '0'; return; } if(!strcmp(arg_name, "xvg_reset_pos")){ xvg_reset_pos = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_reset_wts")){ xvg_reset_wts = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_pause_after_line")){ xvg_pause_after_line = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_use_constant_slope")){ xvg_use_constant_slope = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_use_ls")){ xvg_use_ls = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_inter_alpha_thresh")){ xvg_inter_alpha_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "xvg_intra_alpha_thresh")){ xvg_intra_alpha_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "xvg_show_tracked_pts")){ xvg_show_tracked_pts = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_update_wts")){ xvg_update_wts = atoi(arg_val); return; } if(!strcmp(arg_name, "xvg_sel_reset_thresh")){ xvg_sel_reset_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "reset_template")){ reset_template = atoi(arg_val); return; } if(!strcmp(arg_name, "debug_mode")){ debug_mode = atoi(arg_val); return; } if(!strcmp(arg_name, "pause_after_frame")){ pause_after_frame = atoi(arg_val); return; } if(!strcmp(arg_name, "print_corners")){ print_corners = atoi(arg_val); return; } if(!strcmp(arg_name, "print_fps")){ print_fps = atoi(arg_val); return; } if(!strcmp(arg_name, "show_proc_img")){ show_proc_img = atoi(arg_val); return; } if(!strcmp(arg_name, "res_from_size")){ res_from_size = atof(arg_val); return; } if(!strcmp(arg_name, "mtf_res")){ mtf_res = atoi(arg_val); return; } if(!strcmp(arg_name, "resx")){ resx = atoi(arg_val); return; } if(!strcmp(arg_name, "resy")){ resy = atoi(arg_val); return; } if(!strcmp(arg_name, "epsilon")){ epsilon = atof(arg_val); return; } if(!strcmp(arg_name, "max_iters")){ max_iters = atoi(arg_val); return; } if(!strcmp(arg_name, "mtf_sm")){ processStringParam(mtf_sm, arg_val); return; } if(!strcmp(arg_name, "mtf_am")){ processStringParam(mtf_am, arg_val); return; } if(!strcmp(arg_name, "mtf_ssm")){ processStringParam(mtf_ssm, arg_val); return; } if(!strcmp(arg_name, "mtf_ilm")){ processStringParam(mtf_ilm, arg_val); return; } if(!strcmp(arg_name, "enable_nt")){ enable_nt = atoi(arg_val); return; } if(!strcmp(arg_name, "invalid_state_err_thresh")){ invalid_state_err_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "invalid_state_check")){ invalid_state_check = atoi(arg_val); return; } if(!strcmp(arg_name, "uchar_input")){ uchar_input = atoi(arg_val); return; } //! ICLK if(!strcmp(arg_name, "ic_update_ssm")){ ic_update_ssm = atoi(arg_val); return; } if(!strcmp(arg_name, "ic_chained_warp")){ ic_chained_warp = atoi(arg_val); return; } if(!strcmp(arg_name, "ic_hess_type")){ ic_hess_type = atoi(arg_val); return; } //! FCLK if(!strcmp(arg_name, "fc_chained_warp")){ fc_chained_warp = atoi(arg_val); return; } if(!strcmp(arg_name, "fc_hess_type")){ fc_hess_type = atoi(arg_val); return; } if(!strcmp(arg_name, "fc_write_ssm_updates")){ fc_write_ssm_updates = atoi(arg_val); return; } if(!strcmp(arg_name, "fc_show_grid")){ fc_show_grid = atoi(arg_val); return; } if(!strcmp(arg_name, "fc_show_patch")){ fc_show_patch = atoi(arg_val); return; } if(!strcmp(arg_name, "fc_patch_resize_factor")){ fc_patch_resize_factor = atoi(arg_val); return; } if(!strcmp(arg_name, "fc_debug_mode")){ fc_debug_mode = atoi(arg_val); return; } // IA/FA if(!strcmp(arg_name, "ia_hess_type")){ ia_hess_type = atoi(arg_val); return; } if(!strcmp(arg_name, "fa_hess_type")){ fa_hess_type = atoi(arg_val); return; } if(!strcmp(arg_name, "fa_show_grid")){ fa_show_grid = atoi(arg_val); return; } if(!strcmp(arg_name, "fa_patch_resize_factor")){ fa_patch_resize_factor = atof(arg_val); return; } if(!strcmp(arg_name, "fa_show_patch")){ fa_show_patch = atoi(arg_val); return; } if(!strcmp(arg_name, "fa_write_frames")){ fa_write_frames = atoi(arg_val); return; } //! SSD if(!strcmp(arg_name, "ssd_show_template")){ ssd_show_template = atoi(arg_val); return; } if(!strcmp(arg_name, "input_buffer_size")){ input_buffer_size = atoi(arg_val); return; } if(!strcmp(arg_name, "nssd_norm_pix_max")){ nssd_norm_pix_max = atof(arg_val); return; } if(!strcmp(arg_name, "nssd_norm_pix_min")){ nssd_norm_pix_min = atof(arg_val); return; } if(!strcmp(arg_name, "zncc_likelihood_alpha")){ zncc_likelihood_alpha = atof(arg_val); return; } if(!strcmp(arg_name, "init_frame_id")){ init_frame_id = atoi(arg_val); return; } if(!strcmp(arg_name, "start_frame_id")){ start_frame_id = atoi(arg_val); return; } if(!strcmp(arg_name, "frame_gap")){ frame_gap = atoi(arg_val); return; } if(!strcmp(arg_name, "end_frame_id")){ end_frame_id = atoi(arg_val); return; } if(!strcmp(arg_name, "show_tracking_error")){ show_tracking_error = atoi(arg_val); return; } if(!strcmp(arg_name, "write_tracking_error")){ write_tracking_error = atoi(arg_val); return; } if(!strcmp(arg_name, "write_tracking_sr")){ write_tracking_sr = atoi(arg_val); return; } if(!strcmp(arg_name, "sr_err_thresh")){ sr_err_thresh = atof_arr(arg_val); return; } if(!strcmp(arg_name, "fps_col")){ fps_col = std::string(arg_val); return; } if(!strcmp(arg_name, "obj_cols")){ obj_cols = string_arr(arg_val); return; } if(!strcmp(arg_name, "gt_col")){ gt_col = std::string(arg_val); return; } if(!strcmp(arg_name, "err_col")){ err_col = std::string(arg_val); return; } if(!strcmp(arg_name, "tracking_err_type")){ tracking_err_type = atoi(arg_val); return; } if(!strcmp(arg_name, "show_jaccard_error")){ show_jaccard_error = atoi(arg_val); return; } if(!strcmp(arg_name, "grad_eps")){ grad_eps = strtod(arg_val, nullptr); return; } if(!strcmp(arg_name, "hess_eps")){ hess_eps = strtod(arg_val, nullptr); return; } if(!strcmp(arg_name, "likelihood_alpha")){ likelihood_alpha = strtod(arg_val, nullptr); return; } if(!strcmp(arg_name, "likelihood_beta")){ likelihood_beta = strtod(arg_val, nullptr); return; } if(!strcmp(arg_name, "dist_from_likelihood")){ dist_from_likelihood = atoi(arg_val); return; } //! Reinitialization if(!strcmp(arg_name, "reinit_at_each_frame")){ reinit_at_each_frame = atoi(arg_val); return; } if(!strcmp(arg_name, "reset_at_each_frame")){ reset_at_each_frame = atoi(arg_val); return; } if(!strcmp(arg_name, "reset_to_init")){ reset_to_init = atoi(arg_val); return; } if(!strcmp(arg_name, "reinit_on_failure")){ reinit_on_failure = atoi(arg_val); return; } if(!strcmp(arg_name, "reinit_err_thresh")){ reinit_err_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "reinit_frame_skip")){ reinit_frame_skip = atoi(arg_val); return; } if(!strcmp(arg_name, "reinit_with_new_obj")){ reinit_with_new_obj = atoi(arg_val); return; } //! Reinitialization GT if(!strcmp(arg_name, "use_reinit_gt")){ use_reinit_gt = atoi(arg_val); return; } //! Optimized low DOF ground truth if(!strcmp(arg_name, "use_opt_gt")){ use_opt_gt = atoi(arg_val); return; } if(!strcmp(arg_name, "opt_gt_ssm")){ opt_gt_ssm = std::string(arg_val); return; } //! Pre processing type if(!strcmp(arg_name, "pre_proc_type")){ pre_proc_type = std::string(arg_val); return; } if(!strcmp(arg_name, "pre_proc_hist_eq")){ pre_proc_hist_eq = atoi(arg_val); return; } //! Gaussian smoothing if(!strcmp(arg_name, "gauss_kernel_size")){ gauss_kernel_size = atoi(arg_val); return; } if(!strcmp(arg_name, "gauss_sigma_x")){ gauss_sigma_x = atof(arg_val); return; } if(!strcmp(arg_name, "gauss_sigma_y")){ gauss_sigma_y = atof(arg_val); return; } //! Median Blurring if(!strcmp(arg_name, "med_kernel_size")){ med_kernel_size = atoi(arg_val); return; } //! Normalized box filtering if(!strcmp(arg_name, "box_kernel_size")){ box_kernel_size = atoi(arg_val); return; } //! Bilateral Filtering if(!strcmp(arg_name, "bil_diameter")){ bil_diameter = atoi(arg_val); return; } if(!strcmp(arg_name, "bil_sigma_col")){ bil_sigma_col = atof(arg_val); return; } if(!strcmp(arg_name, "bil_sigma_space")){ bil_sigma_space = atof(arg_val); return; } //! Sobel filtering if(!strcmp(arg_name, "sobel_kernel_size")){ sobel_kernel_size = atoi(arg_val); return; } if(!strcmp(arg_name, "sobel_normalize")){ sobel_normalize = atoi(arg_val); return; } //! Anisotropic Diffusion if(!strcmp(arg_name, "aniso_lambda")){ aniso_lambda = atof(arg_val); return; } if(!strcmp(arg_name, "aniso_kappa")){ aniso_kappa = atof(arg_val); return; } if(!strcmp(arg_name, "aniso_n_iters")){ aniso_n_iters = atoi(arg_val); return; } //! Affine if(!strcmp(arg_name, "aff_normalized_init")){ aff_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "aff_pt_based_sampling")){ aff_pt_based_sampling = atoi(arg_val); return; } //! Lie Affine if(!strcmp(arg_name, "laff_normalized_init")){ laff_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "laff_grad_eps")){ laff_grad_eps = atof(arg_val); return; } //! Homography if(!strcmp(arg_name, "hom_normalized_init")){ hom_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "hom_corner_based_sampling")){ hom_corner_based_sampling = atoi(arg_val); return; } //! Lie Homography if(!strcmp(arg_name, "lhom_normalized_init")){ lhom_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "lhom_grad_eps")){ lhom_grad_eps = atof(arg_val); return; } //! ASRT if(!strcmp(arg_name, "asrt_normalized_init")){ asrt_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "asrt_pt_based_sampling")){ asrt_pt_based_sampling = atoi(arg_val); return; } //! Similitude if(!strcmp(arg_name, "sim_normalized_init")){ sim_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "sim_n_model_pts")){ sim_n_model_pts = atoi(arg_val); return; } if(!strcmp(arg_name, "sim_geom_sampling")){ sim_geom_sampling = atoi(arg_val); return; } if(!strcmp(arg_name, "sim_pt_based_sampling")){ sim_pt_based_sampling = atoi(arg_val); return; } //! Isometry if(!strcmp(arg_name, "iso_pt_based_sampling")){ iso_pt_based_sampling = atoi(arg_val); return; } //! SL3 if(!strcmp(arg_name, "sl3_normalized_init")){ sl3_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "sl3_iterative_sample_mean")){ sl3_iterative_sample_mean = atoi(arg_val); return; } if(!strcmp(arg_name, "sl3_sample_mean_max_iters")){ sl3_sample_mean_max_iters = atoi(arg_val); return; } if(!strcmp(arg_name, "sl3_sample_mean_eps")){ sl3_sample_mean_eps = atof(arg_val); return; } if(!strcmp(arg_name, "sl3_debug_mode")){ sl3_debug_mode = atoi(arg_val); return; } //! Corner based Homography if(!strcmp(arg_name, "cbh_normalized_init")){ cbh_normalized_init = atoi(arg_val); return; } if(!strcmp(arg_name, "cbh_grad_eps")){ cbh_grad_eps = atof(arg_val); return; } //! Spline SSM if(!strcmp(arg_name, "spl_control_size")){ spl_control_size = atoi(arg_val); return; } if(!strcmp(arg_name, "spl_control_overlap")){ spl_control_overlap = atof(arg_val); return; } if(!strcmp(arg_name, "spl_interp_type")){ spl_interp_type = atoi(arg_val); return; } if(!strcmp(arg_name, "spl_static_wts")){ spl_static_wts = atoi(arg_val); return; } if(!strcmp(arg_name, "spl_debug_mode")){ spl_debug_mode = atoi(arg_val); return; } //! SCV if(!strcmp(arg_name, "scv_hist_type")){ scv_hist_type = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_use_bspl")){ scv_use_bspl = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_n_bins")){ scv_n_bins = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_preseed")){ scv_preseed = atof(arg_val); return; } if(!strcmp(arg_name, "scv_pou")){ scv_pou = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_weighted_mapping")){ scv_weighted_mapping = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_mapped_gradient")){ scv_mapped_gradient = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_affine_mapping")){ scv_affine_mapping = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_once_per_frame")){ scv_once_per_frame = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_approx_dist_feat")){ scv_approx_dist_feat = atoi(arg_val); return; } if(!strcmp(arg_name, "scv_likelihood_alpha")){ scv_likelihood_alpha = atof(arg_val); return; } //! LSCV if(!strcmp(arg_name, "lscv_sub_regions")){ lscv_sub_regions = atoi(arg_val); return; } if(!strcmp(arg_name, "lscv_spacing")){ lscv_spacing = atoi(arg_val); return; } if(!strcmp(arg_name, "lscv_show_subregions")){ lscv_show_subregions = atoi(arg_val); return; } //! LKLD if(!strcmp(arg_name, "lkld_pre_seed")){ lkld_pre_seed = atof(arg_val); return; } if(!strcmp(arg_name, "lkld_pou")){ lkld_pou = atoi(arg_val); return; } if(!strcmp(arg_name, "lkld_n_bins")){ lkld_n_bins = atoi(arg_val); return; } if(!strcmp(arg_name, "lkld_sub_regions")){ lkld_sub_regions = atoi(arg_val); return; } if(!strcmp(arg_name, "lkld_spacing")){ lkld_spacing = atoi(arg_val); return; } //! NCC if(!strcmp(arg_name, "ncc_fast_hess")){ ncc_fast_hess = atoi(arg_val); return; } if(!strcmp(arg_name, "ncc_likelihood_alpha")){ ncc_likelihood_alpha = atof(arg_val); return; } //! SPSS if(!strcmp(arg_name, "spss_k")){ spss_k = atof(arg_val); return; } if(!strcmp(arg_name, "spss_likelihood_alpha")){ spss_likelihood_alpha = atof(arg_val); return; } //! SSIM if(!strcmp(arg_name, "ssim_pix_proc_type")){ ssim_pix_proc_type = atoi(arg_val); return; } if(!strcmp(arg_name, "ssim_k1")){ ssim_k1 = atof(arg_val); return; } if(!strcmp(arg_name, "ssim_k2")){ ssim_k2 = atof(arg_val); return; } if(!strcmp(arg_name, "ssim_likelihood_alpha")){ ssim_likelihood_alpha = atof(arg_val); return; } //! Sum of AMs if(!strcmp(arg_name, "sum_am1")){ sum_am1 = std::string(arg_val); return; } if(!strcmp(arg_name, "sum_am2")){ sum_am2 = std::string(arg_val); return; } //! Hessian if(!strcmp(arg_name, "sec_ord_hess")){ sec_ord_hess = atoi(arg_val); return; } if(!strcmp(arg_name, "leven_marq")){ leven_marq = atoi(arg_val); return; } if(!strcmp(arg_name, "lm_delta_init")){ lm_delta_init = atof(arg_val); return; } if(!strcmp(arg_name, "lm_delta_update")){ lm_delta_update = atof(arg_val); return; } //! Online learning in AM if(!strcmp(arg_name, "enable_learning")){ enable_learning = atof(arg_val); return; } if(!strcmp(arg_name, "learning_rate")){ learning_rate = atof(arg_val); return; } //! ESM if(!strcmp(arg_name, "esm_hess_type")){ esm_hess_type = atoi(arg_val); return; } if(!strcmp(arg_name, "esm_jac_type")){ esm_jac_type = atoi(arg_val); return; } if(!strcmp(arg_name, "esm_chained_warp")){ esm_chained_warp = atoi(arg_val); return; } //! MI and CCRE if(!strcmp(arg_name, "mi_pre_seed")){ mi_pre_seed = atof(arg_val); return; } if(!strcmp(arg_name, "mi_pou")){ mi_pou = atoi(arg_val); return; } if(!strcmp(arg_name, "mi_n_bins")){ mi_n_bins = atoi(arg_val); return; } if(!strcmp(arg_name, "mi_likelihood_alpha")){ mi_likelihood_alpha = atof(arg_val); return; } //! CCRE if(!strcmp(arg_name, "ccre_pre_seed")){ ccre_pre_seed = atof(arg_val); return; } if(!strcmp(arg_name, "ccre_pou")){ ccre_pou = atoi(arg_val); return; } if(!strcmp(arg_name, "ccre_n_bins")){ ccre_n_bins = atoi(arg_val); return; } if(!strcmp(arg_name, "ccre_symmetrical_grad")){ ccre_symmetrical_grad = atoi(arg_val); return; } if(!strcmp(arg_name, "ccre_n_blocks")){ ccre_n_blocks = atoi(arg_val); return; } if(!strcmp(arg_name, "ccre_likelihood_alpha")){ ccre_likelihood_alpha = atof(arg_val); return; } //! NGF if(!strcmp(arg_name, "ngf_eta")){ ngf_eta = atof(arg_val); return; } if(!strcmp(arg_name, "ngf_use_ssd")){ ngf_use_ssd = atoi(arg_val); return; } //! diagnostics if(!strcmp(arg_name, "diag_am")){ processStringParam(diag_am, arg_val); return; } if(!strcmp(arg_name, "diag_ssm")){ processStringParam(diag_ssm, arg_val); return; } if(!strcmp(arg_name, "diag_ilm")){ processStringParam(diag_ilm, arg_val); return; } if(!strcmp(arg_name, "diag_range")){ diag_range = atof(arg_val); return; } if(!strcmp(arg_name, "diag_ssm_range")){ diag_ssm_range = atof_arr(arg_val); return; } if(!strcmp(arg_name, "diag_ssm_range_id")){ diag_ssm_range_id = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_am_range_id")){ diag_am_range_id = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_res")){ diag_res = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_3d")){ diag_3d = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_3d_ids")){ diag_3d_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "diag_update_type")){ diag_update_type = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_start_id")){ diag_start_id = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_end_id")){ diag_end_id = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_grad_diff")){ diag_grad_diff = atof(arg_val); return; } if(!strcmp(arg_name, "diag_gen_norm")){ diag_gen_norm = std::string(arg_val); return; } if(!strcmp(arg_name, "diag_gen_jac")){ diag_gen_jac = std::string(arg_val); return; } if(!strcmp(arg_name, "diag_gen_hess")){ diag_gen_hess = std::string(arg_val); return; } if(!strcmp(arg_name, "diag_gen_hess2")){ diag_gen_hess2 = std::string(arg_val); return; } if(!strcmp(arg_name, "diag_gen_hess_sum")){ diag_gen_hess_sum = std::string(arg_val); return; } if(!strcmp(arg_name, "diag_gen_num")){ diag_gen_num = std::string(arg_val); return; } if(!strcmp(arg_name, "diag_gen_ssm")){ diag_gen_ssm = std::string(arg_val); return; } if(!strcmp(arg_name, "diag_bin")){ diag_bin = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_inv")){ diag_inv = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_frame_gap")){ diag_frame_gap = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_show_data")){ diag_show_data = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_show_corners")){ diag_show_corners = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_show_patches")){ diag_show_patches = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_verbose")){ diag_verbose = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_enable_validation")){ diag_enable_validation = atoi(arg_val); return; } if(!strcmp(arg_name, "diag_validation_prec")){ diag_validation_prec = atof(arg_val); return; } if(!strcmp(arg_name, "diag_out_prefix")){ diag_out_prefix = std::string(arg_val); return; } //! Selective Pixel Integration if(!strcmp(arg_name, "esm_spi_enable")){ esm_spi_enable = atoi(arg_val); return; } if(!strcmp(arg_name, "esm_spi_thresh")){ esm_spi_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "pix_mapper")){ processStringParam(pix_mapper, arg_val);; return; } //! NN and GNN if(!strcmp(arg_name, "nn_max_iters")){ nn_max_iters = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_n_samples")){ nn_n_samples = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_ssm_sigma_prec")){ nn_ssm_sigma_prec = atof(arg_val); return; } if(!strcmp(arg_name, "nn_additive_update")){ nn_additive_update = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_show_samples")){ nn_show_samples = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_add_samples_gap")){ nn_add_samples_gap = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_n_samples_to_add")){ nn_n_samples_to_add = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_remove_samples")){ nn_remove_samples = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_ssm_sigma_ids")){ nn_ssm_sigma_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "nn_ssm_mean_ids")){ nn_ssm_mean_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "nn_corner_sigma_d")){ nn_corner_sigma_d = atof(arg_val); return; } if(!strcmp(arg_name, "nn_corner_sigma_t")){ nn_corner_sigma_t = atof(arg_val); return; } if(!strcmp(arg_name, "nn_pix_sigma")){ nn_pix_sigma = atof_arr(arg_val); return; } if(!strcmp(arg_name, "nn_n_trees")){ nn_n_trees = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_index_type")){ nn_index_type = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_search_type")){ nn_search_type = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_save_index")){ nn_save_index = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_load_index")){ nn_load_index = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_saved_index_fid")){ nn_saved_index_fid = atoi(arg_val); return; } //! NN Index specific parameters if(!strcmp(arg_name, "nn_srch_checks")){ nn_srch_checks = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_srch_eps")){ nn_srch_eps = atof32(arg_val); return; } if(!strcmp(arg_name, "nn_srch_sorted")){ nn_srch_sorted = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_srch_max_neighbors")){ nn_srch_max_neighbors = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_srch_cores")){ nn_srch_cores = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_srch_matrices_in_gpu_ram")){ nn_srch_matrices_in_gpu_ram = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_srch_use_heap")){ nn_srch_use_heap = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_gnn_degree")){ nn_gnn_degree = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_gnn_max_steps")){ nn_gnn_max_steps = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_gnn_cmpt_dist_thresh")){ nn_gnn_cmpt_dist_thresh = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_gnn_random_start")){ nn_gnn_random_start = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_fgnn_index_type")){ nn_fgnn_index_type = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_gnn_verbose")){ nn_gnn_verbose = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_kdt_trees")){ nn_kdt_trees = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_km_branching")){ nn_km_branching = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_km_iterations")){ nn_km_iterations = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_km_centers_init")){ nn_km_centers_init = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_km_cb_index")){ nn_km_cb_index = atof32(arg_val); return; } if(!strcmp(arg_name, "nn_kdts_leaf_max_size")){ nn_kdts_leaf_max_size = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_kdtc_leaf_max_size")){ nn_kdtc_leaf_max_size = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_hc_branching")){ nn_hc_branching = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_hc_centers_init")){ nn_hc_centers_init = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_hc_trees")){ nn_hc_trees = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_hc_leaf_max_size")){ nn_hc_leaf_max_size = atoi(arg_val); return; } if(!strcmp(arg_name, "nn_auto_target_precision")){ nn_auto_target_precision = atof32(arg_val); return; } if(!strcmp(arg_name, "ann_uto_build_weight")){ nn_auto_build_weight = atof32(arg_val); return; } if(!strcmp(arg_name, "nn_auto_memory_weight")){ nn_auto_memory_weight = atof32(arg_val); return; } if(!strcmp(arg_name, "nn_auto_sample_fraction")){ nn_auto_sample_fraction = atof32(arg_val); return; } if(!strcmp(arg_name, "nnk_n_layers")){ nnk_n_layers = atoi(arg_val); return; } if(!strcmp(arg_name, "nnk_ssm_sigma_ids")){ nnk_ssm_sigma_ids.push_back(atoi_arr(arg_val)); return; } //! Regression Network if(!strcmp(arg_name, "rg_max_iters")){ rg_max_iters = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_n_samples")){ rg_n_samples = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_additive_update")){ rg_additive_update = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_show_samples")){ rg_show_samples = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_add_points")){ rg_add_points = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_remove_points")){ rg_remove_points = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_ssm_sigma_ids")){ rg_ssm_sigma_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "rg_ssm_mean_ids")){ rg_ssm_mean_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "rg_pix_sigma")){ rg_pix_sigma = atof_arr(arg_val); return; } if(!strcmp(arg_name, "rg_save_index")){ rg_save_index = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_load_index")){ rg_load_index = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_saved_index_fid")){ rg_saved_index_fid = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_nepochs")){ rg_nepochs = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_bs")){ rg_bs = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_preproc")){ rg_preproc = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_solver")){ processStringParam(rg_solver, arg_val);; return; } if(!strcmp(arg_name, "rg_train")){ processStringParam(rg_train, arg_val);; return; } if(!strcmp(arg_name, "rg_mean")){ processStringParam(rg_mean, arg_val);; return; } if(!strcmp(arg_name, "rg_dbg")){ rg_dbg = atoi(arg_val); return; } if(!strcmp(arg_name, "rg_pretrained")){ rg_pretrained = atoi(arg_val); return; } //! RIU AM if(!strcmp(arg_name, "riu_likelihood_alpha")){ riu_likelihood_alpha = atof(arg_val); return; } //! Hierarchical SSM tracker if(!strcmp(arg_name, "hrch_sm")){ processStringParam(hrch_sm, arg_val); return; } if(!strcmp(arg_name, "hrch_am")){ processStringParam(hrch_am, arg_val); return; } //! Cascade Tracker if(!strcmp(arg_name, "casc_n_trackers")){ casc_n_trackers = atoi(arg_val); return; } if(!strcmp(arg_name, "casc_enable_feedback")){ casc_enable_feedback = atoi(arg_val); return; } if(!strcmp(arg_name, "casc_auto_reinit")) { casc_auto_reinit = atoi(arg_val); return; } if(!strcmp(arg_name, "casc_reinit_err_thresh")) { casc_reinit_err_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "casc_reinit_frame_gap")) { casc_reinit_frame_gap = atoi(arg_val); return; } //! Grid tracker if(!strcmp(arg_name, "grid_sm")){ processStringParam(grid_sm, arg_val); return; } if(!strcmp(arg_name, "grid_am")){ processStringParam(grid_am, arg_val); return; } if(!strcmp(arg_name, "grid_ssm")){ processStringParam(grid_ssm, arg_val); return; } if(!strcmp(arg_name, "grid_ilm")){ processStringParam(grid_ilm, arg_val); return; } if(!strcmp(arg_name, "grid_res")){ grid_res = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_patch_size")){ grid_patch_size = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_patch_res")){ grid_patch_res = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_reset_at_each_frame")){ grid_reset_at_each_frame = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_dyn_patch_size")){ grid_dyn_patch_size = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_patch_centroid_inside")){ grid_patch_centroid_inside = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_show_trackers")){ grid_show_trackers = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_show_tracker_edges")){ grid_show_tracker_edges = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_use_tbb")){ grid_use_tbb = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_pyramid_levels")){ grid_pyramid_levels = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_use_min_eig_vals")){ grid_use_min_eig_vals = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_rgb_input")){ grid_rgb_input = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_min_eig_thresh")){ grid_min_eig_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "grid_fb_err_thresh")){ grid_fb_err_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "grid_fb_reinit")){ grid_fb_reinit = atoi(arg_val); return; } if(!strcmp(arg_name, "grid_use_const_grad")){ grid_use_const_grad = atoi(arg_val); return; } //! Feature Tracker if(!strcmp(arg_name, "feat_detector_type")){ feat_detector_type = std::string(arg_val); return; } if(!strcmp(arg_name, "feat_descriptor_type")){ feat_descriptor_type = std::string(arg_val); return; } if(!strcmp(arg_name, "feat_max_dist_ratio")){ feat_max_dist_ratio = atof(arg_val); return; } if(!strcmp(arg_name, "feat_min_matches")){ feat_min_matches = atoi(arg_val); return; } if(!strcmp(arg_name, "feat_rebuild_index")){ feat_rebuild_index = atoi(arg_val); return; } if(!strcmp(arg_name, "feat_use_cv_flann")){ feat_use_cv_flann = atoi(arg_val); return; } if(!strcmp(arg_name, "feat_show_keypoints")){ feat_show_keypoints = atoi(arg_val); return; } if(!strcmp(arg_name, "feat_show_matches")){ feat_show_matches = atoi(arg_val); return; } if(!strcmp(arg_name, "feat_debug_mode")){ feat_debug_mode = atoi(arg_val); return; } //! SIFT detector and descriptor if(!strcmp(arg_name, "sift_n_features")){ sift_n_features = atoi(arg_val); return; } if(!strcmp(arg_name, "sift_n_octave_layers")){ sift_n_octave_layers = atoi(arg_val); return; } if(!strcmp(arg_name, "sift_edge_thresh")){ sift_edge_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "sift_contrast_thresh")){ sift_contrast_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "sift_sigma")){ sift_sigma = atof(arg_val); return; } //! SURF detector and descriptor if(!strcmp(arg_name, "surf_hessian_threshold")){ surf_hessian_threshold = atof(arg_val); return; } if(!strcmp(arg_name, "surf_n_octaves")){ surf_n_octaves = atoi(arg_val); return; } if(!strcmp(arg_name, "surf_n_octave_layers")){ surf_n_octave_layers = atoi(arg_val); return; } if(!strcmp(arg_name, "surf_extended")){ surf_extended = atoi(arg_val); return; } if(!strcmp(arg_name, "surf_upright")){ surf_upright = atoi(arg_val); return; } //! FAST detector if(!strcmp(arg_name, "fast_non_max_suppression")){ fast_non_max_suppression = atoi(arg_val); return; } if(!strcmp(arg_name, "fast_threshold")){ fast_threshold = atoi(arg_val); return; } if(!strcmp(arg_name, "fast_type")){ fast_type = atoi(arg_val); return; } //! BRISK detector and descriptor if(!strcmp(arg_name, "brisk_thresh")){ brisk_thresh = atoi(arg_val); return; } if(!strcmp(arg_name, "brisk_octaves")){ brisk_octaves = atoi(arg_val); return; } if(!strcmp(arg_name, "brisk_pattern_scale")){ brisk_pattern_scale = atof32(arg_val); return; } //! MSER detector if(!strcmp(arg_name, "mser_delta")){ mser_delta = atoi(arg_val); return; } if(!strcmp(arg_name, "mser_min_area")){ mser_min_area = atoi(arg_val); return; } if(!strcmp(arg_name, "mser_max_area")){ mser_max_area = atoi(arg_val); return; } if(!strcmp(arg_name, "mser_max_evolution")){ mser_max_evolution = atoi(arg_val); return; } if(!strcmp(arg_name, "mser_edge_blur_size")){ mser_edge_blur_size = atoi(arg_val); return; } if(!strcmp(arg_name, "mser_max_variation")){ mser_max_variation = atof(arg_val); return; } if(!strcmp(arg_name, "mser_min_diversity")){ mser_min_diversity = atof(arg_val); return; } if(!strcmp(arg_name, "mser_area_threshold")){ mser_area_threshold = atof(arg_val); return; } if(!strcmp(arg_name, "mser_min_margin")){ mser_min_margin = atof(arg_val); return; } //! ORB detector and descriptor if(!strcmp(arg_name, "orb_n_features")){ orb_n_features = atoi(arg_val); return; } if(!strcmp(arg_name, "orb_scale_factor")){ orb_scale_factor = atof32(arg_val); return; } if(!strcmp(arg_name, "orb_n_levels")){ orb_n_levels = atoi(arg_val); return; } if(!strcmp(arg_name, "orb_edge_threshold")){ orb_edge_threshold = atoi(arg_val); return; } if(!strcmp(arg_name, "orb_first_level")){ orb_first_level = atoi(arg_val); return; } if(!strcmp(arg_name, "orb_WTA_K")){ orb_WTA_K = atoi(arg_val); return; } if(!strcmp(arg_name, "orb_score_type")){ orb_score_type = atoi(arg_val); return; } if(!strcmp(arg_name, "orb_patch_size")){ orb_patch_size = atoi(arg_val); return; } if(!strcmp(arg_name, "orb_fast_threshold")){ orb_fast_threshold = atoi(arg_val); return; } //! AGAST detector if(!strcmp(arg_name, "agast_non_max_suppression")){ agast_non_max_suppression = atoi(arg_val); return; } if(!strcmp(arg_name, "agast_threshold")){ agast_threshold = atoi(arg_val); return; } if(!strcmp(arg_name, "agast_type")){ agast_type = atoi(arg_val); return; } //! GFTT detector if(!strcmp(arg_name, "gftt_max_corners")){ gftt_max_corners = atoi(arg_val); return; } if(!strcmp(arg_name, "gftt_quality_level")){ gftt_quality_level = atof(arg_val); return; } if(!strcmp(arg_name, "gftt_min_distance")){ gftt_min_distance = atof(arg_val); return; } if(!strcmp(arg_name, "gftt_block_size")){ gftt_block_size = atoi(arg_val); return; } if(!strcmp(arg_name, "gftt_use_harris_detector")){ gftt_use_harris_detector = atoi(arg_val); return; } if(!strcmp(arg_name, "gftt_k")){ gftt_k = atof(arg_val); return; } //! BRIEF descriptor if(!strcmp(arg_name, "brief_bytes")){ brief_bytes = atoi(arg_val); return; } if(!strcmp(arg_name, "brief_use_orientation")){ brief_use_orientation = atoi(arg_val); return; } //! FREAK descriptor if(!strcmp(arg_name, "freak_orientation_normalized")){ freak_orientation_normalized = atoi(arg_val); return; } if(!strcmp(arg_name, "freak_scale_normalized")){ freak_scale_normalized = atoi(arg_val); return; } if(!strcmp(arg_name, "freak_pattern_scale")){ freak_pattern_scale = atof32(arg_val); return; } if(!strcmp(arg_name, "freak_n_octaves")){ freak_n_octaves = atoi(arg_val); return; } //! LUCID descriptor if(!strcmp(arg_name, "lucid_kernel")){ lucid_kernel = atoi(arg_val); return; } if(!strcmp(arg_name, "lucid_blur_kernel")){ lucid_blur_kernel = atoi(arg_val); return; } //! LATCH descriptor if(!strcmp(arg_name, "latch_bytes")){ latch_bytes = atoi(arg_val); return; } if(!strcmp(arg_name, "latch_rotation_invariance")){ latch_rotation_invariance = atoi(arg_val); return; } if(!strcmp(arg_name, "latch_half_ssd_size")){ latch_half_ssd_size = atoi(arg_val); return; } //! DAISY descriptor if(!strcmp(arg_name, "daisy_radius")){ daisy_radius = atof32(arg_val); return; } if(!strcmp(arg_name, "daisy_q_radius")){ daisy_q_radius = atoi(arg_val); return; } if(!strcmp(arg_name, "daisy_q_theta")){ daisy_q_theta = atoi(arg_val); return; } if(!strcmp(arg_name, "daisy_q_hist")){ daisy_q_hist = atoi(arg_val); return; } if(!strcmp(arg_name, "daisy_H")){ daisy_H = atof32_arr(arg_val); return; } if(!strcmp(arg_name, "daisy_interpolation")){ daisy_interpolation = atoi(arg_val); return; } if(!strcmp(arg_name, "daisy_use_orientation")){ daisy_use_orientation = atoi(arg_val); return; } //! VGG descriptor if(!strcmp(arg_name, "vgg_desc")){ vgg_desc = atoi(arg_val); return; } if(!strcmp(arg_name, "vgg_isigma")){ vgg_isigma = atof32(arg_val); return; } if(!strcmp(arg_name, "vgg_img_normalize")){ vgg_img_normalize = atoi(arg_val); return; } if(!strcmp(arg_name, "vgg_use_scale_orientation")){ vgg_use_scale_orientation = atoi(arg_val); return; } if(!strcmp(arg_name, "vgg_scale_factor")){ vgg_scale_factor = atof32(arg_val); return; } if(!strcmp(arg_name, "vgg_dsc_normalize")){ vgg_dsc_normalize = atoi(arg_val); return; } //! BoostDesc descriptor if(!strcmp(arg_name, "boost_desc_desc")){ boost_desc_desc = atoi(arg_val); return; } if(!strcmp(arg_name, "boost_desc_use_scale_orientation")){ boost_desc_use_scale_orientation = atoi(arg_val); return; } if(!strcmp(arg_name, "boost_desc_scale_factor")){ boost_desc_scale_factor = atof32(arg_val); return; } //! Star detector if(!strcmp(arg_name, "star_max_size")){ star_max_size = atoi(arg_val); return; } if(!strcmp(arg_name, "star_response_threshold")){ star_response_threshold = atoi(arg_val); return; } if(!strcmp(arg_name, "star_line_threshold_projected")){ star_line_threshold_projected = atoi(arg_val); return; } if(!strcmp(arg_name, "star_line_threshold_binarized")){ star_line_threshold_binarized = atoi(arg_val); return; } if(!strcmp(arg_name, "star_suppress_nonmax_size")){ star_suppress_nonmax_size = atoi(arg_val); return; } //! MSD detector if(!strcmp(arg_name, "msd_patch_radius")){ msd_patch_radius = atoi(arg_val); return; } if(!strcmp(arg_name, "msd_search_area_radius")){ msd_search_area_radius = atoi(arg_val); return; } if(!strcmp(arg_name, "msd_nms_radius")){ msd_nms_radius = atoi(arg_val); return; } if(!strcmp(arg_name, "msd_nms_scale_radius")){ msd_nms_scale_radius = atoi(arg_val); return; } if(!strcmp(arg_name, "msd_th_saliency")){ msd_th_saliency = atof32(arg_val); return; } if(!strcmp(arg_name, "msd_kNN")){ msd_kNN = atoi(arg_val); return; } if(!strcmp(arg_name, "msd_scale_factor")){ msd_scale_factor = atof32(arg_val); return; } if(!strcmp(arg_name, "msd_n_scales")){ msd_n_scales = atoi(arg_val); return; } if(!strcmp(arg_name, "msd_compute_orientation")){ msd_compute_orientation = atoi(arg_val); return; } //! SSM Estimator if(!strcmp(arg_name, "est_method")){ est_method = atoi(arg_val); return; } if(!strcmp(arg_name, "est_ransac_reproj_thresh")){ est_ransac_reproj_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "est_n_model_pts")){ est_n_model_pts = atoi(arg_val); return; } if(!strcmp(arg_name, "est_max_iters")){ est_max_iters = atoi(arg_val); return; } if(!strcmp(arg_name, "est_max_subset_attempts")){ est_max_subset_attempts = atoi(arg_val); return; } if(!strcmp(arg_name, "est_use_boost_rng")){ est_use_boost_rng = atoi(arg_val); return; } if(!strcmp(arg_name, "est_confidence")){ est_confidence = atof(arg_val); return; } if(!strcmp(arg_name, "est_refine")){ est_refine = atoi(arg_val); return; } if(!strcmp(arg_name, "est_lm_max_iters")){ est_lm_max_iters = atoi(arg_val); return; } //! RKLT if(!strcmp(arg_name, "rkl_sm")){ processStringParam(rkl_sm, arg_val); return; } if(!strcmp(arg_name, "rkl_enable_spi")){ rkl_enable_spi = atoi(arg_val); return; } if(!strcmp(arg_name, "rkl_enable_feedback")){ rkl_enable_feedback = atoi(arg_val); return; } if(!strcmp(arg_name, "rkl_failure_detection")){ rkl_failure_detection = atoi(arg_val); return; } if(!strcmp(arg_name, "rkl_failure_thresh")){ rkl_failure_thresh = atof(arg_val); return; } //! Parallel Tracker if(!strcmp(arg_name, "prl_n_trackers")) { prl_n_trackers = atoi(arg_val); return; } if(!strcmp(arg_name, "prl_estimation_method")) { prl_estimation_method = atoi(arg_val); return; } if(!strcmp(arg_name, "prl_reset_to_mean")) { prl_reset_to_mean = atoi(arg_val); return; } if(!strcmp(arg_name, "prl_auto_reinit")) { prl_auto_reinit = atoi(arg_val); return; } if(!strcmp(arg_name, "prl_reinit_err_thresh")) { prl_reinit_err_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "prl_reinit_frame_gap")) { prl_reinit_frame_gap = atoi(arg_val); return; } //! Pyramidal Tracker if(!strcmp(arg_name, "pyr_sm")) { pyr_sm = std::string(arg_val); return; } if(!strcmp(arg_name, "pyr_no_of_levels")) { pyr_no_of_levels = atoi(arg_val); return; } if(!strcmp(arg_name, "pyr_scale_factor")) { pyr_scale_factor = atof(arg_val); return; } if(!strcmp(arg_name, "pyr_scale_res")) { pyr_scale_res = atoi(arg_val); return; } if(!strcmp(arg_name, "pyr_show_levels")) { pyr_show_levels = atoi(arg_val); return; } //! Gradient Descent if(!strcmp(arg_name, "sd_learning_rate")){ sd_learning_rate = atof(arg_val); return; } //! Gain and Bias Illumination Model if(!strcmp(arg_name, "gb_additive_update")){ gb_additive_update = atoi(arg_val); return; } //! Piecewise Gain and Bias Illumination Model if(!strcmp(arg_name, "pgb_additive_update")){ pgb_additive_update = atoi(arg_val); return; } if(!strcmp(arg_name, "pgb_sub_regions_x")){ pgb_sub_regions_x = atoi(arg_val); return; } if(!strcmp(arg_name, "pgb_sub_regions_y")){ pgb_sub_regions_y = atoi(arg_val); return; } //! Radial Basis Function illumination model if(!strcmp(arg_name, "rbf_additive_update")){ rbf_additive_update = atoi(arg_val); return; } if(!strcmp(arg_name, "rbf_n_ctrl_pts_x")){ rbf_n_ctrl_pts_x = atoi(arg_val); return; } if(!strcmp(arg_name, "rbf_n_ctrl_pts_y")){ rbf_n_ctrl_pts_y = atoi(arg_val); return; } //! Particle Filter if(!strcmp(arg_name, "pf_max_iters")){ pf_max_iters = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_n_particles")){ pf_n_particles = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_dynamic_model")){ pf_dynamic_model = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_update_type")){ pf_update_type = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_likelihood_func")){ pf_likelihood_func = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_resampling_type")){ pf_resampling_type = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_reset_to_mean")){ pf_reset_to_mean = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_mean_type")){ pf_mean_type = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_ssm_sigma_ids")){ pf_ssm_sigma_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "pf_ssm_mean_ids")){ pf_ssm_mean_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "pf_update_distr_wts")){ pf_update_distr_wts = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_min_distr_wt")){ pf_min_distr_wt = atof(arg_val); return; } if(!strcmp(arg_name, "pf_adaptive_resampling_thresh")){ pf_adaptive_resampling_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "pf_measurement_sigma")){ pf_measurement_sigma = atof(arg_val); return; } if(!strcmp(arg_name, "pf_pix_sigma")){ pf_pix_sigma = atof_arr(arg_val); return; } if(!strcmp(arg_name, "pf_show_particles")){ pf_show_particles = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_jacobian_as_sigma")){ pf_jacobian_as_sigma = atoi(arg_val); return; } if(!strcmp(arg_name, "pf_debug_mode")){ pf_debug_mode = atoi(arg_val); return; } //! Multi layer PF if(!strcmp(arg_name, "pfk_n_layers")){ pfk_n_layers = atoi(arg_val); return; } if(!strcmp(arg_name, "pfk_ssm_sigma_ids")){ pfk_ssm_sigma_ids.push_back(atoi_arr(arg_val)); return; } //! Gaussian parameters for sampling SSM parameters if(!strcmp(arg_name, "ssm_sigma")){ ssm_sigma.push_back(atof_arr(arg_val)); return; } if(!strcmp(arg_name, "ssm_mean")){ ssm_mean.push_back(atof_arr(arg_val)); return; } if(!strcmp(arg_name, "am_sigma")){ am_sigma.push_back(atof_arr(arg_val)); return; } if(!strcmp(arg_name, "am_mean")){ am_mean.push_back(atof_arr(arg_val)); return; } //! CMT if(!strcmp(arg_name, "cmt_estimate_scale")){ cmt_estimate_scale = atoi(arg_val); return; } if(!strcmp(arg_name, "cmt_estimate_rotation")){ cmt_estimate_rotation = atoi(arg_val); return; } if(!strcmp(arg_name, "cmt_feat_detector")){ processStringParam(cmt_feat_detector, arg_val); return; } if(!strcmp(arg_name, "cmt_desc_extractor")){ processStringParam(cmt_desc_extractor, arg_val); return; } if(!strcmp(arg_name, "cmt_resize_factor")){ cmt_resize_factor = atof(arg_val); return; } //! DSST if(!strcmp(arg_name, "dsst_sigma")){ dsst_sigma = atof(arg_val); return; } if(!strcmp(arg_name, "dsst_scale_sigma")){ dsst_scale_sigma = atof(arg_val); return; } if(!strcmp(arg_name, "dsst_lambda")){ dsst_lambda = atof(arg_val); return; } if(!strcmp(arg_name, "dsst_learning_rate")){ dsst_learning_rate = atof(arg_val); return; } if(!strcmp(arg_name, "dsst_number_scales")){ dsst_number_scales = atoi(arg_val); return; } if(!strcmp(arg_name, "dsst_number_rots")){ dsst_number_rots = atoi(arg_val); return; } if(!strcmp(arg_name, "dsst_scale_step")){ dsst_scale_step = atof(arg_val); return; } if(!strcmp(arg_name, "dsst_rot_step")){ dsst_rot_step = atof(arg_val); return; } if(!strcmp(arg_name, "dsst_padding")){ dsst_padding = atoi(arg_val); return; } if(!strcmp(arg_name, "dsst_resize_factor")){ dsst_resize_factor = atoi(arg_val); return; } if(!strcmp(arg_name, "dsst_is_scaling")){ dsst_is_scaling = atoi(arg_val); return; } if(!strcmp(arg_name, "dsst_is_rotating")){ dsst_is_rotating = atoi(arg_val); return; } if(!strcmp(arg_name, "dsst_bin_size")){ dsst_bin_size = atoi(arg_val); return; } //! KCF if(!strcmp(arg_name, "kcf_output_sigma_factor")){ kcf_output_sigma_factor = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_interp_factor")){ kcf_interp_factor = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_lambda")){ kcf_lambda = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_kernel_sigma")){ kcf_kernel_sigma = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_number_scales")){ kcf_number_scales = atoi(arg_val); return; } if(!strcmp(arg_name, "kcf_scale_step")){ kcf_scale_step = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_padding")){ kcf_padding = atoi(arg_val); return; } if(!strcmp(arg_name, "kcf_resize_factor")){ kcf_resize_factor = atoi(arg_val); return; } if(!strcmp(arg_name, "kcf_scale_model_max_area")){ kcf_scale_model_max_area = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_scale_sigma_factor")){ kcf_scale_sigma_factor = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_scale_learning_rate")){ kcf_scale_learning_rate = atof(arg_val); return; } if(!strcmp(arg_name, "kcf_is_scaling")){ kcf_is_scaling = atoi(arg_val); return; } //! MIL if(!strcmp(arg_name, "mil_algorithm")){ mil_algorithm = atoi(arg_val); return; } if(!strcmp(arg_name, "mil_num_classifiers")){ mil_num_classifiers = atoi(arg_val); return; } if(!strcmp(arg_name, "mil_overlap")){ mil_overlap = atof32(arg_val); return; } if(!strcmp(arg_name, "mil_search_factor")){ mil_search_factor = atof32(arg_val); return; } if(!strcmp(arg_name, "mil_pos_radius_train")){ mil_pos_radius_train = atof32(arg_val); return; } if(!strcmp(arg_name, "mil_neg_num_train")){ mil_neg_num_train = atoi(arg_val); return; } if(!strcmp(arg_name, "mil_num_features")){ mil_num_features = atoi(arg_val); return; } //! TLD if(!strcmp(arg_name, "tld_detector_enabled")){ tld_detector_enabled = atoi(arg_val); return; } if(!strcmp(arg_name, "tld_learning_enabled")){ tld_learning_enabled = atoi(arg_val); return; } if(!strcmp(arg_name, "tld_tracker_enabled")){ tld_tracker_enabled = atoi(arg_val); return; } if(!strcmp(arg_name, "tld_alternating")){ tld_alternating = atoi(arg_val); return; } //! RCT if(!strcmp(arg_name, "rct_min_n_rect")){ rct_min_n_rect = atoi(arg_val); return; } if(!strcmp(arg_name, "rct_max_n_rect")){ rct_max_n_rect = atoi(arg_val); return; } if(!strcmp(arg_name, "rct_n_feat")){ rct_n_feat = atoi(arg_val); return; } if(!strcmp(arg_name, "rct_rad_outer_pos")){ rct_rad_outer_pos = atoi(arg_val); return; } if(!strcmp(arg_name, "rct_rad_search_win")){ rct_rad_search_win = atoi(arg_val); return; } if(!strcmp(arg_name, "rct_learning_rate")){ rct_learning_rate = atof(arg_val); return; } //! Struck if(!strcmp(arg_name, "strk_config_path")){ strk_config_path = std::string(arg_val); return; } //! ViSP Template Tracker if(!strcmp(arg_name, "vptt_sm")){ processStringParam(vptt_sm, arg_val); return; } if(!strcmp(arg_name, "vptt_am")){ processStringParam(vptt_am, arg_val); return; } if(!strcmp(arg_name, "vptt_ssm")){ processStringParam(vptt_ssm, arg_val); return; } if(!strcmp(arg_name, "vptt_max_iters")){ vptt_max_iters = atoi(arg_val); return; } if(!strcmp(arg_name, "vptt_res")){ vptt_res = atoi(arg_val); return; } if(!strcmp(arg_name, "vptt_pyr_n_levels")){ vptt_pyr_n_levels = atoi(arg_val); return; } if(!strcmp(arg_name, "vptt_pyr_level_to_stop")){ vptt_pyr_level_to_stop = atoi(arg_val); return; } if(!strcmp(arg_name, "vptt_lambda")){ vptt_lambda = atof(arg_val); return; } if(!strcmp(arg_name, "vptt_thresh_grad")){ vptt_thresh_grad = atof(arg_val); return; } //! ViSP pipeline if(!strcmp(arg_name, "vp_usb_res")){ vp_usb_res = std::string(arg_val); return; } if(!strcmp(arg_name, "vp_usb_fps")){ vp_usb_fps = std::string(arg_val); return; } if(!strcmp(arg_name, "vp_usb_n_buffers")){ vp_usb_n_buffers = atoi(arg_val); return; } if(!strcmp(arg_name, "vp_fw_res")){ vp_fw_res = std::string(arg_val); return; } if(!strcmp(arg_name, "vp_fw_fps")){ vp_fw_fps = std::string(arg_val); return; } if(!strcmp(arg_name, "vp_fw_depth")){ vp_fw_depth = std::string(arg_val); return; } if(!strcmp(arg_name, "vp_fw_iso")){ vp_fw_iso = std::string(arg_val); return; } if(!strcmp(arg_name, " vp_fw_print_info")){ vp_fw_print_info = atoi(arg_val); return; } if(!strcmp(arg_name, " vp_pg_fw_shutter_ms")){ vp_pg_fw_shutter_ms = atof32(arg_val); return; } if(!strcmp(arg_name, " vp_pg_fw_gain")){ vp_pg_fw_gain = atof32(arg_val); return; } if(!strcmp(arg_name, " vp_pg_fw_exposure")){ vp_pg_fw_exposure = atof32(arg_val); return; } if(!strcmp(arg_name, " vp_pg_fw_brightness")){ vp_pg_fw_brightness = atof32(arg_val); return; } //! CV3 if(!strcmp(arg_name, "cv3_tracker_type")){ cv3_tracker_type = std::string(arg_val); return; } //! PFSL3 if(!strcmp(arg_name, "pfsl3_p_x")){ pfsl3_p_x = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_p_y")){ pfsl3_p_y = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_rot")){ pfsl3_rot = atof(arg_val); return; } if(!strcmp(arg_name, "pfsl3_ncc_std")){ pfsl3_ncc_std = atof(arg_val); return; } if(!strcmp(arg_name, "pfsl3_pca_std")){ pfsl3_pca_std = atof(arg_val); return; } if(!strcmp(arg_name, "pfsl3_state_std")){ pfsl3_state_std = atof_arr(arg_val); return; } if(!strcmp(arg_name, "pfsl3_ar_p")){ pfsl3_ar_p = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_n")){ pfsl3_n = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_n_c")){ pfsl3_n_c = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_n_iter")){ pfsl3_n_iter = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_sampling")){ pfsl3_sampling = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_capture")){ pfsl3_capture = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_mean_check")){ pfsl3_mean_check = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_outlier_flag")){ pfsl3_outlier_flag = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_len")){ pfsl3_len = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_init_size")){ pfsl3_init_size = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_update_period")){ pfsl3_update_period = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_ff")){ pfsl3_ff = atof32(arg_val); return; } if(!strcmp(arg_name, "pfsl3_basis_thr")){ pfsl3_basis_thr = atof(arg_val); return; } if(!strcmp(arg_name, "pfsl3_max_num_basis")){ pfsl3_max_num_basis = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_max_num_used_basis")){ pfsl3_max_num_used_basis = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_show_weights")){ pfsl3_show_weights = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_show_templates")){ pfsl3_show_templates = atoi(arg_val); return; } if(!strcmp(arg_name, "pfsl3_debug_mode")){ pfsl3_debug_mode = atoi(arg_val); return; } //! GOTURN if(!strcmp(arg_name, "gtrn_do_train")){ gtrn_do_train = atoi(arg_val); return; } if(!strcmp(arg_name, "gtrn_gpu_id")){ gtrn_gpu_id = atoi(arg_val); return; } if(!strcmp(arg_name, "gtrn_show_intermediate_output")){ gtrn_show_intermediate_output = atoi(arg_val); return; } if(!strcmp(arg_name, "gtrn_model_file")){ gtrn_model_file = std::string(arg_val); return; } if(!strcmp(arg_name, "gtrn_trained_file")){ gtrn_trained_file = std::string(arg_val); return; } //! DFT if(!strcmp(arg_name, "dft_res_to_l")){ dft_res_to_l = atof32(arg_val); return; } if(!strcmp(arg_name, "dft_p_to_l")){ dft_p_to_l = atof32(arg_val); return; } if(!strcmp(arg_name, "dft_max_iter")){ dft_max_iter = atoi(arg_val); return; } if(!strcmp(arg_name, "dft_max_iter_single_level")){ dft_max_iter_single_level = atoi(arg_val); return; } if(!strcmp(arg_name, "dft_pyramid_smoothing_variance")){ dft_pyramid_smoothing_variance = atof32_arr(arg_val); return; } if(!strcmp(arg_name, "dft_presmoothing_variance")){ dft_presmoothing_variance = atof32(arg_val); return; } if(!strcmp(arg_name, "dft_n_control_points_on_edge")){ dft_n_control_points_on_edge = atoi(arg_val); return; } if(!strcmp(arg_name, "dft_b_adaptative_choice_of_points")){ dft_b_adaptative_choice_of_points = atoi(arg_val); return; } if(!strcmp(arg_name, "dft_b_normalize_descriptors")){ dft_b_normalize_descriptors = atoi(arg_val); return; } if(!strcmp(arg_name, "dft_optimization_type")){ dft_optimization_type = atoi(arg_val); return; } // FRG if(!strcmp(arg_name, "frg_n_bins")){ frg_n_bins = atoi(arg_val); return; } if(!strcmp(arg_name, "frg_search_margin")){ frg_search_margin = atoi(arg_val); return; } if(!strcmp(arg_name, "frg_hist_cmp_metric")){ frg_hist_cmp_metric = atoi(arg_val); return; } if(!strcmp(arg_name, "frg_resize_factor")){ frg_resize_factor = atof(arg_val); return; } if(!strcmp(arg_name, "frg_show_window")){ frg_show_window = atoi(arg_val); return; } //! FMaps if(!strcmp(arg_name, "dfm_nfmaps")){ dfm_nfmaps = atoi(arg_val); return; } if(!strcmp(arg_name, "dfm_layer_name")){ processStringParam(dfm_layer_name, arg_val); return; } if(!strcmp(arg_name, "dfm_vis")){ dfm_vis = atoi(arg_val); return; } if(!strcmp(arg_name, "dfm_zncc")){ dfm_zncc = atoi(arg_val); return; } if(!strcmp(arg_name, "dfm_model_f_name")){ processStringParam(dfm_model_f_name, arg_val); return; } if(!strcmp(arg_name, "dfm_params_f_name")){ processStringParam(dfm_params_f_name, arg_val); return; } if(!strcmp(arg_name, "dfm_mean_f_name")){ processStringParam(dfm_mean_f_name, arg_val); return; } //! SPI if(!strcmp(arg_name, "spi_type")){ spi_type = atoi(arg_val); return; } if(!strcmp(arg_name, "spi_pix_diff_thresh")){ spi_pix_diff_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "spi_grad_thresh")){ spi_grad_thresh = atof(arg_val); return; } if(!strcmp(arg_name, "spi_grad_use_union")){ spi_grad_use_union = atoi(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_max_corners")){ spi_gftt_max_corners = atoi(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_quality_level")){ spi_gftt_quality_level = atof(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_min_distance")){ spi_gftt_min_distance = atof(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_block_size")){ spi_gftt_block_size = atoi(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_use_harris_detector")){ spi_gftt_use_harris_detector = atoi(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_use_union")){ spi_gftt_use_union = atoi(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_k")){ spi_gftt_k = atof(arg_val); return; } if(!strcmp(arg_name, "spi_gftt_neigh_offset")){ spi_gftt_neigh_offset = atoi(arg_val); return; } //! Patch extractor if(!strcmp(arg_name, "extracted_frame_ids")){ extracted_frame_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "extraction_id")){ extraction_id = atoi(arg_val); return; } //! PCA if(!strcmp(arg_name, "pca_n_eigenvec")){ pca_n_eigenvec = atoi(arg_val); return; } if(!strcmp(arg_name, "pca_batchsize")){ pca_batchsize = atoi(arg_val); return; } if(!strcmp(arg_name, "pca_f_factor")){ pca_f_factor = atof32(arg_val); return; } if(!strcmp(arg_name, "pca_show_basis")){ pca_show_basis = atoi(arg_val); return; } //! registered sequence generator if(!strcmp(arg_name, "reg_ssm")){ reg_ssm = std::string(arg_val); return; } if(!strcmp(arg_name, "reg_ilm")){ reg_ilm = std::string(arg_val); return; } if(!strcmp(arg_name, "reg_track_border")){ reg_track_border = atoi(arg_val); return; } if(!strcmp(arg_name, "reg_grayscale_img")){ reg_grayscale_img = atoi(arg_val); return; } if(!strcmp(arg_name, "reg_show_output")){ reg_show_output = atoi(arg_val); return; } if(!strcmp(arg_name, "reg_save_as_video")){ reg_save_as_video = atoi(arg_val); return; } if(!strcmp(arg_name, "reg_video_fps")){ reg_video_fps = atoi(arg_val); return; } //! Synthetic warped sequence generator if(!strcmp(arg_name, "syn_ssm")){ syn_ssm = std::string(arg_val); return; } if(!strcmp(arg_name, "syn_ilm")){ syn_ilm = std::string(arg_val); return; } if(!strcmp(arg_name, "syn_frame_id")){ syn_frame_id = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_grayscale_img")){ syn_grayscale_img = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_continuous_warping")){ syn_continuous_warping = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_ssm_sigma_ids")){ syn_ssm_sigma_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "syn_ssm_mean_ids")){ syn_ssm_mean_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "syn_am_sigma_ids")){ syn_am_sigma_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "syn_am_mean_ids")){ syn_am_mean_ids = atoi_arr(arg_val); return; } if(!strcmp(arg_name, "syn_pix_sigma")){ syn_pix_sigma = atof(arg_val); return; } if(!strcmp(arg_name, "syn_am_on_obj")){ syn_am_on_obj = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_warp_entire_image")){ syn_warp_entire_image = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_background_type")){ syn_background_type = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_use_inv_warp")){ syn_use_inv_warp = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_out_suffix")){ syn_out_suffix = std::string(arg_val); return; } if(!strcmp(arg_name, "syn_n_frames")){ syn_n_frames = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_add_noise")){ syn_add_noise = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_noise_mean")){ syn_noise_mean = atof(arg_val); return; } if(!strcmp(arg_name, "syn_noise_sigma")){ syn_noise_sigma = atof(arg_val); return; } if(!strcmp(arg_name, "syn_save_as_video")){ syn_save_as_video = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_video_fps")){ syn_video_fps = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_jpg_quality")){ syn_jpg_quality = atoi(arg_val); return; } if(!strcmp(arg_name, "syn_show_output")){ syn_show_output = atoi(arg_val); return; } //! online image mosaicing if(!strcmp(arg_name, "mos_inv_tracking")){ mos_inv_tracking = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_use_norm_corners")){ mos_use_norm_corners = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_track_border")){ mos_track_border = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_border_width")){ mos_border_width = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_border_height")){ mos_border_height = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_init_offset_x")){ mos_init_offset_x = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_init_offset_y")){ mos_init_offset_y = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_disp_width")){ mos_disp_width = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_disp_height")){ mos_disp_height = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_show_grid")){ mos_show_grid = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_show_tracked_img")){ mos_show_tracked_img = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_show_patch")){ mos_show_patch = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_show_mask")){ mos_show_mask = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_use_write_mask")){ mos_use_write_mask = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_save_img")){ mos_save_img = atoi(arg_val); return; } if(!strcmp(arg_name, "mos_out_fname")){ mos_out_fname = std::string(arg_val); return; } if(!strcmp(arg_name, "mos_out_fmt")){ mos_out_fmt = std::string(arg_val); return; } if(!strcmp(arg_name, "qr_input")){ qr_input.push_back(std::string(arg_val)); return; } if(!strcmp(arg_name, "qr_root_dir")){ qr_root_dir = std::string(arg_val); return; } if(!strcmp(arg_name, "qr_detector_ssm")){ qr_detector_ssm = std::string(arg_val); return; } if(!strcmp(arg_name, "qr_duplicate_min_dist")){ qr_duplicate_min_dist = atof(arg_val); return; } if(!strcmp(arg_name, "qr_min_size")){ qr_min_size = atof(arg_val); return; } if(!strcmp(arg_name, "qr_init_with_rect")){ qr_init_with_rect = atoi(arg_val); return; } if(!strcmp(arg_name, "qr_n_markers")){ qr_n_markers = atoi(arg_val); return; } if(!strcmp(arg_name, "py_visualize")){ py_visualize = atoi(arg_val); return; } if(!strcmp(arg_name, "py_live_init")){ py_live_init = atoi(arg_val); return; } if(!strcmp(arg_name, "mex_visualize")){ mex_visualize = atoi(arg_val); return; } if(!strcmp(arg_name, "mex_live_init")){ mex_live_init = atoi(arg_val); return; } } inline FILE* readTrackerParams(FILE * fid = nullptr, int print_args = 0){ // reads parameters for a single tracker in a multi tracker setup // a blank line signals the end of the current tracker's parameters // a line starting with # is treated as comment and ignored if(!fid){ if(!fs::is_directory(config_dir)) { return nullptr; } std::string fname = config_dir + "/multi.cfg"; printf("Opening file: %s...\n", fname.c_str()); if(!(fid = fopen(fname.c_str(), "r"))){ printf("readTrackerParams :: Error: File could not be opened\n"); return nullptr; } } char curr_line[500]; char arg_name[500], arg_val[500]; while(!feof(fid)){ fgets(curr_line, 500, fid); strtok(curr_line, "\n"); strtok(curr_line, "\r"); // ignore comments if(curr_line[0] == '#') continue; // empty line signals the end of current tracker's parameters if(strlen(curr_line) <= 1) return fid; sscanf(curr_line, "%s%s", arg_name, arg_val); strtok(arg_name, "\n"); strtok(arg_name, "\r"); strtok(arg_val, "\n"); strtok(arg_val, "\r"); char *alpha_arg_name = arg_name; while(!isalpha(*alpha_arg_name)){ ++alpha_arg_name; } if(strlen(alpha_arg_name) == 0){ continue; } if(print_args) printf("arg_name: %s arg_val: %s\n", alpha_arg_name, arg_val); processAgrument(alpha_arg_name, arg_val); } fclose(fid); return nullptr; } inline bool parseArgumentPairs(char * argv[], int argc, int parse_type = 0, int print_args = 0){ // parse_type = 0 means that each element of argv contains // an argument's name and its value separated by a space // parse_type = 1 means that consecutive elements of argv contain // the name and value of each argument if(argc <= 0){ return true; } if(parse_type && argc % 2 == 0){ printf("Command line arguments must be specified in pairs\n"); return false; } //printf("Parsing %d argument pairs with argv=%d...\n", argc, argv); int max_arg = parse_type ? argc / 2 + 1 : argc; if(print_args){ printf("argc: %d max_arg: %d\n", argc, max_arg); } for(int arg_id = 1; arg_id < max_arg; arg_id++){ char arg_name[500], arg_val[500]; //printf("i=%d\n", i); if(parse_type){ sscanf(argv[2 * arg_id - 1], "%s", arg_name); sscanf(argv[2 * arg_id], "%s", arg_val); } else{ sscanf(argv[arg_id], "%s%s", arg_name, arg_val); } strtok(arg_name, "\n"); strtok(arg_name, "\r"); strtok(arg_val, "\n"); strtok(arg_val, "\r"); // discard all numbers and special characters from the start of the argument name char *alpha_arg_name = arg_name; //printf("arg_name: %s\n", arg_name); vector<char> arg_prefix; while(!isalpha(*alpha_arg_name)){ arg_prefix.push_back(*alpha_arg_name); ++alpha_arg_name; } if(strlen(alpha_arg_name) == 0){ continue; } if(print_args){ printf("arg_name: %s arg_val: %s\n", alpha_arg_name, arg_val); } processAgrument(alpha_arg_name, arg_val, arg_prefix.data()); } return true; } inline std::string getSyntheticSeqName(){ if(syn_out_suffix.empty()){ syn_out_suffix = cv::format("warped_%s_s%d", syn_ssm.c_str(), syn_ssm_sigma_ids[0]); if(syn_ilm != "0"){ syn_out_suffix = cv::format("%s_%s_s%d", syn_out_suffix.c_str(), syn_ilm.c_str(), syn_am_sigma_ids[0]); } if(syn_add_noise){ syn_out_suffix = cv::format("%s_gauss_%4.2f_%4.2f", syn_out_suffix.c_str(), syn_noise_mean, syn_noise_sigma); } } return cv::format("%s_%d_%s", seq_name.c_str(), syn_frame_id, syn_out_suffix.c_str()); } inline bool postProcessParams(){ if(mtf_res > 0){ resx = resy = mtf_res; } if(img_resize_factor <= 0){ img_resize_factor = 1; } if((img_source == SRC_IMG) || (img_source == SRC_DISK) || (img_source == SRC_VID)){ if(actor_id >= 0){ int n_actors = sizeof(actors) / sizeof(actors[0]); //printf("n_actors: %d\n", n_actors); if(actor_id >= n_actors){ printf("Invalid actor id specified: %d\n", actor_id); return false; } actor = actors[actor_id]; if(seq_id >= 0){ int n_sources = combined_n_sequences[actor_id]; if(seq_id >= n_sources){ printf("Invalid source id %d specified for actor %s with %d sources\n", seq_id, actor.c_str(), n_sources); return false; } seq_name = combined_sequences[actor_id][seq_id]; } if(actor == "Synthetic"){ //! synthetic sequence seq_name = getSyntheticSeqName(); } if(seq_name.empty()){ printf("Source name must be specified if source ID is invalid\n"); return false; } seq_path = db_root_path + "/" + actor; } else{ actor = "None"; if(seq_path.empty()){ seq_path = "."; } seq_path = db_root_path + "/" + seq_path; } if(seq_fmt.empty()){ seq_fmt = (img_source == SRC_IMG || img_source == SRC_DISK) ? IMG_FMT : VID_FMT; } } else { actor = "Live"; seq_name = (img_source == SRC_USB_CAM) ? USB_DEV_NAME : FW_DEV_NAME; if(seq_path.empty()){ seq_path = (img_source == SRC_USB_CAM) ? USB_DEV_PATH : FW_DEV_PATH; } if(seq_fmt.empty()){ seq_fmt = (img_source == SRC_USB_CAM) ? USB_DEV_FMT : FW_DEV_FMT; } show_tracking_error = reinit_on_failure = read_obj_from_gt = read_obj_from_file = pause_after_frame = invert_seq = 0; } if(atoi(pre_proc_type.c_str()) < 0){ //! input images must be read into the same location for pre processing to be disabled input_buffer_size = 1; } return true; } // inline std::string getAbsolutePath(const std::string &file) { //#ifdef _WIN32 // TCHAR abs_path[MAX_PATH]; // GetFullPathName(file.c_str(), MAX_PATH, abs_path, NULL); // return std::string(abs_path); //#else // char abs_path[MAX_ABS_PATH]; // realpath(file.c_str(), abs_path); // return std::string(abs_path); //#endif // //return fs::absolute(config_dir.c_str()); // } inline bool readParams(int cmd_argc, char* cmd_argv[]){ //! check if a custom configuration directory has been specified bool custom_cfg = false; if(cmd_argc > 2 && !strcmp(cmd_argv[1], "config_dir")){ config_dir = std::string(cmd_argv[2]); cmd_argv += 2; cmd_argc -= 2; custom_cfg = true; } if(!fs::is_directory(config_dir)){ if(custom_cfg) { std::cout << "Configuration folder: " << config_dir << " does not exist\n"; } } else { if(custom_cfg) { std::cout << "Reading configuration files from: " << config_dir << "\n"; } std::vector<char*> fargv; //! read general parameters int fargc = readParams(fargv, (config_dir + "/mtf.cfg").c_str()); if(fargc){ if(!parseArgumentPairs(fargv.data(), fargc)){ printf("Error in parsing mtf.cfg\n"); return false; } fargv.clear(); } //! read parameters specific to different modules fargc = readParams(fargv, (config_dir + "/modules.cfg").c_str()); if(fargc){ if(!parseArgumentPairs(fargv.data(), fargc)){ printf("Error in parsing modules.cfg\n"); return false; } fargv.clear(); } //! read parameters for feature detectors and descriptors fargc = readParams(fargv, (config_dir + "/feat.cfg").c_str()); if(fargc){ if(!parseArgumentPairs(fargv.data(), fargc)){ printf("Error in parsing feat.cfg\n"); return false; } fargv.clear(); } //! read parameters for example applications fargc = readParams(fargv, (config_dir + "/examples.cfg").c_str()); if(fargc){ if(!parseArgumentPairs(fargv.data(), fargc)){ printf("Error in parsing examples.cfg\n"); return false; } fargv.clear(); } //! read standard deviations and means for stochastic modules fargc = readParams(fargv, (config_dir + "/sigma.cfg").c_str()); if(fargc){ if(!parseArgumentPairs(fargv.data(), fargc)){ printf("Error in parsing sigma.cfg\n"); return false; } fargv.clear(); } //! read parameters for third party trackers fargc = readParams(fargv, (config_dir + "/thirdparty.cfg").c_str()); if(fargc){ if(!parseArgumentPairs(fargv.data(), fargc)){ printf("Error in parsing thirdparty.cfg\n"); return false; } fargv.clear(); } } //! parse command line arguments if(cmd_argc > 0 && !parseArgumentPairs(cmd_argv, cmd_argc, 1, 0)){ printf("Error in parsing command line arguments\n"); return false; } if(!postProcessParams()){ printf("Error in post processing params\n"); return false; } return true; } inline bool readParams(const char* param_str){ if(!param_str || !strlen(param_str)) { return true; } std::vector<char*> fargv; fargv.push_back(nullptr); std::string _param_str = std::string(param_str); std::istringstream iss(_param_str); do{ string subs; iss >> subs; if(subs.empty()){ continue; } //printf("subs: %s\n", subs.c_str()); char *cstr = new char[subs.length() + 1]; strcpy(cstr, subs.c_str()); fargv.push_back(cstr); } while(iss); //fargv.pop_back(); //printf("fargv.size(): %d\n", fargv.size()); if(fargv.size() % 2 == 0){ //printf("param_str: %s\n", param_str); std::cout << "Parameters must be provided in pairs\n"; return false; } return readParams(fargv.size(), fargv.data()); } inline void getSamplerParams(vectorvd &sigma, vectorvd &mean, const vectori &sigma_ids, const vectori &mean_ids, const char* name){ //printf("ssm_sigma.size(): %ld\n", ssm_sigma.size()); //for(int i = 0; i < ssm_sigma.size(); ++i){ // for(vectord::const_iterator iter = ssm_sigma[i].begin(); iter != ssm_sigma[i].end(); ++iter){ // printf("%f\t", *iter); // } // printf("\n"); //} //printf("ssm_mean.size(): %ld\n", ssm_mean.size()); //for(int i = 0; i < ssm_mean.size(); ++i){ // for(vectord::const_iterator iter = ssm_mean[i].begin(); iter != ssm_mean[i].end(); ++iter){ // printf("%f\t", *iter); // } // printf("\n"); //} for(auto sigma_id : sigma_ids){ if(sigma_id < 0 || static_cast<unsigned int>(sigma_id) >= ssm_sigma.size()){ printf("Skipping invalid %s sigma ID: %d\n", name, sigma_id); continue; } sigma.push_back(ssm_sigma[sigma_id]); } for(auto mean_id : mean_ids){ if(mean_id < 0 || static_cast<unsigned int>(mean_id) >= ssm_mean.size()){ //printf("Skipping invalid %s SSM mean ID: %d\n", name, mean_id); continue; } mean.push_back(ssm_mean[mean_id]); } } inline void getAMSamplerParams(vectorvd &sigma, vectorvd &mean, const vectori &sigma_ids, const vectori &mean_ids, const char* name){ for(auto sigma_id : sigma_ids){ if(sigma_id < 0 || static_cast<unsigned int>(sigma_id) >= am_sigma.size()){ printf("Skipping invalid %s sigma ID: %d\n", name, sigma_id); continue; } sigma.push_back(am_sigma[sigma_id]); } for(auto mean_id : mean_ids){ if(mean_id < 0 || static_cast<unsigned int>(mean_id) >= am_mean.size()){ continue; } mean.push_back(am_mean[mean_id]); } } inline void freeParams(){} } } #endif
26.865429
100
0.63525
[ "vector", "model" ]
2077cfe07adaa7b217f3b759656322a88c631d2a
3,217
h
C
src/ledger/bin/app/active_page_manager_container.h
zhangpf/fuchsia-rs
903568f28ddf45f09157ead36d61b50322c9cf49
[ "BSD-3-Clause" ]
1
2019-04-21T18:02:26.000Z
2019-04-21T18:02:26.000Z
src/ledger/bin/app/active_page_manager_container.h
zhangpf/fuchsia-rs
903568f28ddf45f09157ead36d61b50322c9cf49
[ "BSD-3-Clause" ]
16
2020-09-04T19:01:11.000Z
2021-05-28T03:23:09.000Z
src/ledger/bin/app/active_page_manager_container.h
ZVNexus/fuchsia
c5610ad15208208c98693618a79c705af935270c
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SRC_LEDGER_BIN_APP_ACTIVE_PAGE_MANAGER_CONTAINER_H_ #define SRC_LEDGER_BIN_APP_ACTIVE_PAGE_MANAGER_CONTAINER_H_ #include <lib/fidl/cpp/interface_request.h> #include <lib/fit/function.h> #include <string> #include "src/ledger/bin/app/active_page_manager.h" #include "src/ledger/bin/app/page_connection_notifier.h" #include "src/ledger/bin/app/page_impl.h" #include "src/ledger/bin/app/page_usage_listener.h" #include "src/ledger/bin/app/types.h" #include "src/ledger/bin/storage/public/types.h" namespace ledger { // Container for a ActivePageManager that keeps track of in-flight page // requests and callbacks and fires them when the ActivePageManager is // available. class ActivePageManagerContainer { public: ActivePageManagerContainer(std::string ledger_name, storage::PageId page_id, PageUsageListener* page_usage_listener); ~ActivePageManagerContainer(); void set_on_empty(fit::closure on_empty_callback); // Keeps track of |page| and |callback|. Binds |page| and fires |callback| // when a ActivePageManager is available or an error occurs. void BindPage(fidl::InterfaceRequest<Page> page_request, fit::function<void(Status)> callback); // Registers a new internal request for PageStorage. void NewInternalRequest(fit::function<void(Status, ExpiringToken, ActivePageManager*)> callback); // Sets the ActivePageManager or the error status for the container. This // notifies all awaiting callbacks and binds all pages in case of success. void SetActivePageManager(Status status, std::unique_ptr<ActivePageManager> active_page_manager); // Returns true if there is at least one active external page connection. bool PageConnectionIsOpen(); private: // Checks whether this container is empty, and calls the |on_empty_callback_| // if it is. void CheckEmpty(); const storage::PageId page_id_; std::unique_ptr<ActivePageManager> active_page_manager_; // |status_| holds the status given to |SetActivePageManager|. If // |active_page_manager_is_set_| is true, |status_| is |Status::OK| if and // only if |active_page_manager_| is not null. Status status_ = Status::OK; // |active_page_manager_is_set_| if |SetActivePageManager| has been called. // |active_page_manager_| may still be null. bool active_page_manager_is_set_ = false; PageConnectionNotifier connection_notifier_; // page_impls_ is only populated before active_page_manager_ is set. Once the // ActivePageManager is created and assigned to active_page_manager_, the // PageImpls stored in page_impls_ are handed off to that ActivePageManager // and page_impls_ is not used again. std::vector<std::pair<std::unique_ptr<PageImpl>, fit::function<void(Status)>>> page_impls_; std::vector<fit::function<void(Status, ExpiringToken, ActivePageManager*)>> internal_request_callbacks_; fit::closure on_empty_callback_; FXL_DISALLOW_COPY_AND_ASSIGN(ActivePageManagerContainer); }; } // namespace ledger #endif // SRC_LEDGER_BIN_APP_ACTIVE_PAGE_MANAGER_CONTAINER_H_
40.721519
99
0.775878
[ "vector" ]
207bd0623d7676190e01dd548ac22255e4f2d990
4,238
c
C
nitan/d/wudu/npc/obj/hanshasheying.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/d/wudu/npc/obj/hanshasheying.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/d/wudu/npc/obj/hanshasheying.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// hanshasheying.c 含沙射影 #include <ansi.h> #include <armor.h> inherit WAIST; void create() { set_name("含沙射影", ({ "han sha she ying", "hssy" }) ); set_weight(500); if( clonep() ) set_default_object(__FILE__); else { set("long", "這是五毒教的奇門暗器「含沙射影」,樣子象一條腰帶,可以束在腰間。\n帶中間有一個扁扁的小鐵盒,只要在腰間一按(shot)就可以發射出細如牛毛的毒針。\n") ; set("unit", "個"); set("value", 0); set("zhen", 10); set("material", "iron"); set("armor_prop/armor", 3); } setup(); } void init() { add_action("do_shot","shot"); } int do_shot(string arg) { object me,ob,target; int myskill , tgskill; int mylev ,damage; string fam; me = this_player(); if( query_temp("armor/waist", me) != this_object() ) return notify_fail("你對着你的腰間一摸,糟糕!你還沒把含沙射影裝上呢!\n"); if( !arg ) return notify_fail("你想對誰發射含沙射影?\n"); if( !objectp(target = present(arg, environment(me))) ) return notify_fail("這裏沒有這個人。\n"); if( query("id", target) == query("id", me) ) return notify_fail("你想殺自己嗎?\n"); if( !target || !target->is_character() || !me->is_fighting(target) ) return notify_fail("含沙射影只能對戰鬥中的對手使用。\n"); if( query("no_fight", environment(me)) ) return notify_fail ("這裏不準戰鬥!\n"); if( !target->is_character() || target->is_corpse() ) return notify_fail("看清楚一點,那並不是活物。\n"); if(me->is_busy() ) return notify_fail("你正忙着哪。\n"); if( query("zhen", this_object())<1 ) { remove_call_out("destroy_box"); call_out ("destroy_box" , 0 ) ; return notify_fail("鐵盒中的毒針已經射光了。\n"); } if( !objectp(ob = present("han sha she ying", me)) ) return notify_fail("你沒有這種東西。\n"); myskill = me->query_skill("five-poison",1) + me->query_skill("dodge",1); tgskill = target->query_skill("dodge",1); mylev = me->query_skill("five-poison"); if( query("family/family_name", this_player()) != "五毒教" ) { message_vision("\n$N左手在腰間一陣亂按!\n", me); return 1; } if( query("own_name", ob) != query("id", me) ) { message_vision("\n$N左手在腰間一陣亂按!\n", me); remove_call_out("destroy_box"); call_out ("destroy_box" , 0 ) ; return 1; } if ( mylev <= 50 ) return notify_fail("你的毒技還不熟練,無法使用含沙射影!\n"); addn("zhen", -1, this_object()); message_vision(HIR"\n$N一聲輕笑,左手不經意的在腰間一按。只聽得一陣嗤嗤的破空聲。\n"NOR,me,target); me->start_busy(2+random(2)) ; if( !target->is_killing(me) ) target->kill_ob(me); if( random(myskill) < tgskill ) message_vision("\n$n大叫一聲,猛的一個旱地拔葱身行衝起數丈來高,堪堪躲過了$N的毒針!\n",me,target); else { message_vision("\n$n躲閃不及,被無數細如牛毛的毒針打了一身,不由的發出一聲慘嚎!\n",me,target); tell_object (target, HIR "\n你只覺得臉上、胸前一痛,而後是奇癢難熬,一定是中毒了。\n"NOR); damage=me->query_skill("five-poison",1)*4-(query("max_neili", target)/5); if( damage < 100 ) damage = 100; if( damage > 800 ) damage = 800; target->receive_wound ("qi",damage) ; target->apply_condition("snake_poison", (int)target->query_condition("snake_poison") + damage/5 ); target->apply_condition("wugong_poison", (int)target->query_condition("wugong_poison") + damage/5 ); target->apply_condition("zhizhu_poison", (int)target->query_condition("zhizhu_poison") + damage/5 ); target->apply_condition("xiezi_poison", (int)target->query_condition("xiezi_poison") + damage/5 ); target->apply_condition("chanchu_poison", (int)target->query_condition("chanchu_poison")+damage/5 ); target->start_busy (4); } return 1; } void destroy_box() { message_vision("忽然"+query("name", this_object())+"掉在地上,摔成了一堆鐵片。\n",environment(this_object())); destruct(this_object()); }
35.613445
116
0.53799
[ "object" ]
208058b80d114f9ca8ca20c8308d6249fa9b43c2
14,858
c
C
ewmh.c
XCaminhante/windwm
c8d5656a942c71916782b4ef3faf476d5659cecb
[ "MIT" ]
4
2020-07-10T11:15:17.000Z
2022-01-13T19:56:19.000Z
ewmh.c
XCaminhante/windwm
c8d5656a942c71916782b4ef3faf476d5659cecb
[ "MIT" ]
null
null
null
ewmh.c
XCaminhante/windwm
c8d5656a942c71916782b4ef3faf476d5659cecb
[ "MIT" ]
2
2018-12-17T01:09:44.000Z
2022-01-15T15:34:29.000Z
/* * Copyright 2010 Johan Veenhuizen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <X11/Xatom.h> #include <X11/Xlib.h> #include "wind.h" #define DEFAULT_NUMBER_OF_DESKTOPS 12 #define xatom(name) XInternAtom(dpy, (name), False) #define NET_WM_STATE_REMOVE 0 #define NET_WM_STATE_ADD 1 #define NET_WM_STATE_TOGGLE 2 static void addclient(Window); static void delclient(Window); static unsigned long ewmh_getndesktops(void); static void setcurrentdesktop(unsigned long); static void reloadwindowname(struct client *); static void reloadwindowstate(struct client *); static void reloadwindowtype(struct client *); static void reloadwindowdesktop(struct client *); static Bool hasstate(Window, Atom); static void removestate(Window, Atom); static void addstate(Window, Atom); static void changestate(Window, int, Atom); /* * The list of supported properties. Note that we need to * include some properties that we actually never use in * the _NET_SUPPORTED list in order to show applications * that we do indeed know about them. For example, pagers * act strangely if we don't mention _NET_WM_STATE_HIDDEN. * * NB: Keep this list sorted. */ static Atom NET_ACTIVE_WINDOW; static Atom NET_CLIENT_LIST; static Atom NET_CLIENT_LIST_STACKING; static Atom NET_CLOSE_WINDOW; static Atom NET_CURRENT_DESKTOP; static Atom NET_DESKTOP_GEOMETRY; static Atom NET_DESKTOP_VIEWPORT; static Atom NET_FRAME_EXTENTS; static Atom NET_NUMBER_OF_DESKTOPS; static Atom NET_REQUEST_FRAME_EXTENTS; static Atom NET_SUPPORTED; static Atom NET_SUPPORTING_WM_CHECK; static Atom NET_WM_ACTION_CHANGE_DESKTOP; static Atom NET_WM_ACTION_CLOSE; static Atom NET_WM_ACTION_FULLSCREEN; static Atom NET_WM_ACTION_MINIMIZE; static Atom NET_WM_ALLOWED_ACTIONS; static Atom NET_WM_DESKTOP; static Atom NET_WM_ICON_NAME; static Atom NET_WM_NAME; static Atom NET_WM_STATE; static Atom NET_WM_STATE_ABOVE; static Atom NET_WM_STATE_BELOW; static Atom NET_WM_STATE_FULLSCREEN; static Atom NET_WM_STATE_HIDDEN; static Atom NET_WM_STATE_SKIP_TASKBAR; static Atom NET_WM_VISIBLE_ICON_NAME; static Atom NET_WM_VISIBLE_NAME; static Atom NET_WM_WINDOW_TYPE; static Atom NET_WM_WINDOW_TYPE_DOCK; static Atom NET_WORKAREA; static Atom UTF8_STRING; static Window wmcheckwin = None; static struct { Window *v; size_t n; size_t lim; } clientlist = { NULL, 0, 0 }; void ewmh_notifyclientdesktop(Window w, unsigned long i) { setprop(w, NET_WM_DESKTOP, XA_CARDINAL, 32, &i, 1); } void ewmh_notifycurdesk(unsigned long n) { setprop(root, NET_CURRENT_DESKTOP, XA_CARDINAL, 32, &n, 1); } void ewmh_notifyframeextents(Window w, struct extents e) { unsigned long v[4] = { e.left, e.right, e.top, e.bottom }; setprop(w, NET_FRAME_EXTENTS, XA_CARDINAL, 32, v, NELEM(v)); } static void addclient(Window w) { if (clientlist.n == clientlist.lim) { clientlist.lim += 32; clientlist.v = xrealloc(clientlist.v, clientlist.lim * sizeof clientlist.v[0]); } clientlist.v[clientlist.n++] = w; setprop(root, NET_CLIENT_LIST, XA_WINDOW, 32, clientlist.v, clientlist.n); } static void delclient(Window w) { int i; for (i = 0; i < clientlist.n && clientlist.v[i] != w; i++) ; if (i < clientlist.n) { for (; i < clientlist.n - 1; i++) clientlist.v[i] = clientlist.v[i + 1]; clientlist.n--; } setprop(root, NET_CLIENT_LIST, XA_WINDOW, 32, clientlist.v, clientlist.n); if (clientlist.n == 0) { free(clientlist.v); clientlist.v = NULL; clientlist.lim = 0; } } static unsigned long ewmh_getndesktops(void) { unsigned long ndesk = DEFAULT_NUMBER_OF_DESKTOPS; unsigned long n; unsigned long *p = getprop(root, NET_NUMBER_OF_DESKTOPS, XA_CARDINAL, 32, &n); if (p != NULL) { if (n == 1) ndesk = *p & 0xffffffffUL; XFree(p); } return ndesk; } void ewmh_notifyndesk(unsigned long n) { long *viewport = xmalloc(n * 2 * sizeof (long)); long *workarea = xmalloc(n * 4 * sizeof (long)); for (unsigned long i = 0; i < n; i++) { viewport[2 * i + 0] = 0; viewport[2 * i + 1] = 0; workarea[4 * i + 0] = 0; workarea[4 * i + 1] = 0; workarea[4 * i + 2] = DisplayWidth(dpy, scr); workarea[4 * i + 3] = DisplayHeight(dpy, scr); } setprop(root, NET_DESKTOP_VIEWPORT, XA_CARDINAL, 32, viewport, n * 2); setprop(root, NET_WORKAREA, XA_CARDINAL, 32, workarea, n * 4); free(workarea); free(viewport); setprop(root, NET_NUMBER_OF_DESKTOPS, XA_CARDINAL, 32, &n, 1); } static void setcurrentdesktop(unsigned long i) { setprop(root, NET_CURRENT_DESKTOP, XA_CARDINAL, 32, &i, 1); } void ewmh_startwm(void) { UTF8_STRING = xatom("UTF8_STRING"); Atom v[] = { // Keep sorted NET_ACTIVE_WINDOW = xatom("_NET_ACTIVE_WINDOW"), NET_CLIENT_LIST = xatom("_NET_CLIENT_LIST"), NET_CLIENT_LIST_STACKING = xatom("_NET_CLIENT_LIST_STACKING"), NET_CLOSE_WINDOW = xatom("_NET_CLOSE_WINDOW"), NET_CURRENT_DESKTOP = xatom("_NET_CURRENT_DESKTOP"), NET_DESKTOP_GEOMETRY = xatom("_NET_DESKTOP_GEOMETRY"), NET_DESKTOP_VIEWPORT = xatom("_NET_DESKTOP_VIEWPORT"), NET_FRAME_EXTENTS = xatom("_NET_FRAME_EXTENTS"), NET_NUMBER_OF_DESKTOPS = xatom("_NET_NUMBER_OF_DESKTOPS"), NET_REQUEST_FRAME_EXTENTS = xatom("_NET_REQUEST_FRAME_EXTENTS"), NET_SUPPORTED = xatom("_NET_SUPPORTED"), NET_SUPPORTING_WM_CHECK = xatom("_NET_SUPPORTING_WM_CHECK"), NET_WM_ACTION_CHANGE_DESKTOP = xatom("_NET_WM_ACTION_CHANGE_DESKTOP"), NET_WM_ACTION_CLOSE = xatom("_NET_WM_ACTION_CLOSE"), NET_WM_ACTION_FULLSCREEN = xatom("_NET_WM_ACTION_FULLSCREEN"), NET_WM_ACTION_MINIMIZE = xatom("_NET_WM_ACTION_MINIMIZE"), NET_WM_ALLOWED_ACTIONS = xatom("_NET_WM_ALLOWED_ACTIONS"), NET_WM_DESKTOP = xatom("_NET_WM_DESKTOP"), NET_WM_ICON_NAME = xatom("_NET_WM_ICON_NAME"), NET_WM_NAME = xatom("_NET_WM_NAME"), NET_WM_STATE = xatom("_NET_WM_STATE"), NET_WM_STATE_ABOVE = xatom("_NET_WM_STATE_ABOVE"), NET_WM_STATE_BELOW = xatom("_NET_WM_STATE_BELOW"), NET_WM_STATE_FULLSCREEN = xatom("_NET_WM_STATE_FULLSCREEN"), NET_WM_STATE_HIDDEN = xatom("_NET_WM_STATE_HIDDEN"), NET_WM_STATE_SKIP_TASKBAR = xatom("_NET_WM_STATE_SKIP_TASKBAR"), NET_WM_VISIBLE_ICON_NAME = xatom("_NET_WM_VISIBLE_ICON_NAME"), NET_WM_VISIBLE_NAME = xatom("_NET_WM_VISIBLE_NAME"), NET_WM_WINDOW_TYPE = xatom("_NET_WM_WINDOW_TYPE"), NET_WM_WINDOW_TYPE_DOCK = xatom("_NET_WM_WINDOW_TYPE_DOCK"), NET_WORKAREA = xatom("_NET_WORKAREA"), }; setprop(root, NET_SUPPORTED, XA_ATOM, 32, v, NELEM(v)); long geometry[2] = { DisplayWidth(dpy, scr), DisplayHeight(dpy, scr) }; setprop(root, NET_DESKTOP_GEOMETRY, XA_CARDINAL, 32, geometry, 2); setndesk(ewmh_getndesktops()); unsigned long n = 0; unsigned long *deskp = getprop(root, NET_CURRENT_DESKTOP, XA_CARDINAL, 32, &n); setcurrentdesktop(0); if (deskp != NULL) { if (n == 1) { gotodesk(*deskp & 0xffffffffUL); refocus(CurrentTime); } XFree(deskp); } Window none = None; setprop(root, NET_ACTIVE_WINDOW, XA_WINDOW, 32, &none, 1); // Finally create the WM_CHECK window to announce our EWMH support. wmcheckwin = XCreateWindow(dpy, root, 0, 0, 1, 1, 0, CopyFromParent, InputOnly, CopyFromParent, 0, NULL); setprop(wmcheckwin, NET_SUPPORTING_WM_CHECK, XA_WINDOW, 32, &wmcheckwin, 1); setprop(wmcheckwin, NET_WM_NAME, UTF8_STRING, 8, PACKAGE_NAME, strlen(PACKAGE_NAME)); setprop(root, NET_SUPPORTING_WM_CHECK, XA_WINDOW, 32, &wmcheckwin, 1); } void ewmh_stopwm(void) { XDestroyWindow(dpy, wmcheckwin); } static void reloadwindowname(struct client *c) { unsigned long n = 0; char *name = getprop(cgetwin(c), NET_WM_NAME, UTF8_STRING, 8, &n); csetnetwmname(c, name); if (name != NULL) XFree(name); } static void reloadwindowstate(struct client *c) { Window w = cgetwin(c); Bool skiptaskbar = False; Bool isfullscreen = False; unsigned long n = 0; Atom *states = getprop(w, NET_WM_STATE, XA_ATOM, 32, &n); for (int i = 0; i < n; i++) if (states[i] == NET_WM_STATE_SKIP_TASKBAR) skiptaskbar = True; else if (states[i] == NET_WM_STATE_FULLSCREEN) isfullscreen = True; else removestate(w, states[i]); if (states != NULL) XFree(states); csetskiptaskbar(c, skiptaskbar); csetfull(c, isfullscreen); } static void reloadwindowtype(struct client *c) { Bool isdock = False; unsigned long n = 0; Atom *types = getprop(cgetwin(c), NET_WM_WINDOW_TYPE, XA_ATOM, 32, &n); if (types != NULL) { for (unsigned long i = 0; i < n; i++) if (types[i] == NET_WM_WINDOW_TYPE_DOCK) isdock = True; XFree(types); } csetdock(c, isdock); } static void reloadwindowdesktop(struct client *c) { Window w = cgetwin(c); unsigned long n = 0; long *deskp = getprop(w, NET_WM_DESKTOP, XA_CARDINAL, 32, &n); if (deskp != NULL) { if (n == 1) csetdesk(c, *deskp & 0xffffffffUL); XFree(deskp); } else ewmh_notifyclientdesktop(w, cgetdesk(c)); } void ewmh_maprequest(struct client *c) { /* * The order of the following calls is optimized * for visual appearance. */ reloadwindowdesktop(c); reloadwindowstate(c); reloadwindowtype(c); } void ewmh_manage(struct client *c) { Window w = cgetwin(c); addclient(w); // Remove properties that other window managers may have set. XDeleteProperty(dpy, w, NET_WM_VISIBLE_NAME); XDeleteProperty(dpy, w, NET_WM_VISIBLE_ICON_NAME); Atom v[] = { NET_WM_ACTION_CHANGE_DESKTOP, NET_WM_ACTION_CLOSE, NET_WM_ACTION_FULLSCREEN, }; setprop(w, NET_WM_ALLOWED_ACTIONS, XA_ATOM, 32, v, NELEM(v)); /* * The order of the following calls is optimized * for visual appearance. */ reloadwindowdesktop(c); reloadwindowstate(c); reloadwindowname(c); reloadwindowtype(c); } void ewmh_unmanage(struct client *c) { Window w = cgetwin(c); ewmh_notifyfocus(w, None); delclient(w); XDeleteProperty(dpy, w, NET_WM_ALLOWED_ACTIONS); } void ewmh_withdraw(struct client *c) { Window w = cgetwin(c); ewmh_notifyfocus(w, None); delclient(w); XDeleteProperty(dpy, w, NET_WM_ALLOWED_ACTIONS); XDeleteProperty(dpy, w, NET_WM_DESKTOP); XDeleteProperty(dpy, w, NET_WM_STATE); } /* * Notify change in focus. The focus change is only * accepted if 'old' matches the last recorded focus * window, or if it is None. * * The reason this function takes two arguments is to * avoid race conditions between FocusIn and FocusOut * events. * * A FocusIn handler should use None as 'old' and the * event window as 'new', while a FocusOut handler * should use the event window as 'old' and None as * 'new'. This way, it doesn't matter in which order * the events are reported. */ void ewmh_notifyfocus(Window old, Window new) { // The last recorded focus window static Window current = None; if (old == None || old == current) { setprop(root, NET_ACTIVE_WINDOW, XA_WINDOW, 32, &new, 1); current = new; } } void ewmh_notifyrestack(void) { Window *v; size_t n; getwindowstack(&v, &n); setprop(root, NET_CLIENT_LIST_STACKING, XA_WINDOW, 32, v, n); free(v); } void ewmh_propertynotify(struct client *c, XPropertyEvent *e) { if (e->atom == NET_WM_NAME) reloadwindowname(c); } static Bool hasstate(Window w, Atom state) { unsigned long n = 0; Atom *v = getprop(w, NET_WM_STATE, XA_ATOM, 32, &n); Bool found = False; for (unsigned long i = 0; i < n; i++) if (v[i] == state) { found = True; break; } if (v != NULL) XFree(v); return found; } /* * Removes a _NET_WM_STATE property (including duplicates). */ static void removestate(Window w, Atom state) { unsigned long n = 0; Atom *v = getprop(w, NET_WM_STATE, XA_ATOM, 32, &n); unsigned long k = 0; for (unsigned long i = 0; i < n; i++) if (v[i] != state) v[k++] = v[i]; setprop(w, NET_WM_STATE, XA_ATOM, 32, v, k); if (v != NULL) XFree(v); } /* * Adds a _NET_WM_STATE property, unless it is already present. */ static void addstate(Window w, Atom state) { unsigned long n = 0; Atom *old = getprop(w, NET_WM_STATE, XA_ATOM, 32, &n); Bool present = False; for (unsigned long i = 0; i < n; i++) if (old[i] == state) { present = True; break; } if (!present) { Atom *new = xmalloc((n + 1) * sizeof (Atom)); memcpy(new, old, n * sizeof (Atom)); new[n] = state; setprop(w, NET_WM_STATE, XA_ATOM, 32, new, n + 1); free(new); } if (old != NULL) XFree(old); } static void changestate(Window w, int how, Atom state) { switch (how) { case NET_WM_STATE_REMOVE: removestate(w, state); break; case NET_WM_STATE_ADD: addstate(w, state); break; case NET_WM_STATE_TOGGLE: if (hasstate(w, state)) removestate(w, state); else addstate(w, state); break; } } void ewmh_notifyfull(Window w, Bool full) { if (full) { if (!hasstate(w, NET_WM_STATE_FULLSCREEN)) addstate(w, NET_WM_STATE_FULLSCREEN); } else removestate(w, NET_WM_STATE_FULLSCREEN); } void ewmh_clientmessage(struct client *c, XClientMessageEvent *e) { if (e->message_type == NET_ACTIVE_WINDOW && e->format == 32) { cpopapp(c); gotodesk(cgetdesk(c)); cfocus(c, (Time)e->data.l[1]); } else if (e->message_type == NET_CLOSE_WINDOW && e->format == 32) { cdelete(c, (Time)e->data.l[0]); } else if (e->message_type == NET_WM_DESKTOP && e->format == 32) { csetappdesk(c, e->data.l[0] & 0xffffffff); } else if (e->message_type == NET_WM_STATE && e->format == 32) { int how = e->data.l[0]; for (int i = 1; i <= 2; i++) if (e->data.l[i] != 0) changestate(cgetwin(c), how, e->data.l[i]); reloadwindowstate(c); } } void ewmh_rootclientmessage(XClientMessageEvent *e) { if (e->message_type == NET_CURRENT_DESKTOP && e->format == 32) { gotodesk(e->data.l[0]); refocus((Time)e->data.l[1]); } else if (e->message_type == NET_REQUEST_FRAME_EXTENTS) { struct extents ext = estimateframeextents(e->window); ewmh_notifyframeextents(e->window, ext); } else if (e->message_type == NET_NUMBER_OF_DESKTOPS && e->format == 32) { setndesk(e->data.l[0]); refocus(CurrentTime); } }
27.463956
77
0.717459
[ "geometry" ]
2083a82dec8e82e1d1576188f4e45ebd6a11ba9a
3,186
h
C
cpp/include/srl/io/BinaryReader.h
311labs/SRL
c3f0069270ada3784f2a81d9ec9e390e31e53a59
[ "MIT" ]
2
2018-12-21T01:55:23.000Z
2021-11-29T01:30:37.000Z
cpp/include/srl/io/BinaryReader.h
311labs/SRL
c3f0069270ada3784f2a81d9ec9e390e31e53a59
[ "MIT" ]
null
null
null
cpp/include/srl/io/BinaryReader.h
311labs/SRL
c3f0069270ada3784f2a81d9ec9e390e31e53a59
[ "MIT" ]
null
null
null
/** * File: BinaryReader.h * Project: srl3 * Created by: Ian Starnes on 2006-11-20. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef __SRL_BINARYREADER__ #define __SRL_BINARYREADER__ #include "srl/String.h" //#include "srl/io/Serializable.h" namespace SRL { namespace IO { //class Serializable; /** Class for reading bytes or characters from a stream */ class SRL_API BinaryReader { public: BinaryReader(){}; virtual ~BinaryReader(){}; /** is the object ready to be read from */ virtual bool canRead(int msec=SRL::NOW)const=0; /** is at the end of the stream */ virtual bool atEnd() const = 0; /** read 1 byte from the object */ virtual SRL::byte read()=0; /** read bytes from an IO Object */ virtual int read(void* obj, uint32 objsize, uint32 arrysize=1)=0; /** read byte from the buffer */ int read(byte* value, uint32 arrysize=1); /** read int16 from an IO Object */ int read(int16 *obj, uint32 arrysize=1); /** read int32 from an IO Object */ int read(int32 *obj, uint32 arrysize=1); /** read int64 from an IO Object */ int read(int64 *obj, uint32 arrysize=1); /** read uint16 from an IO Object */ int read(uint16 *obj, uint32 arrysize=1); /** read uint32 from an IO Object */ int read(uint32 *obj, uint32 arrysize=1); /** read uint64 from an IO Object */ int read(uint64 *obj, uint32 arrysize=1); /** read at32 from an IO Object */ int read(float32 *obj, uint32 arrysize=1); /** read float64 from an IO Object */ int read(float64 *obj, uint32 arrysize=1); /** read bool from an IO Object */ int read(bool *obj, uint32 arrysize=1); /** read String from an IO Object */ int read(char *str, uint32 arrysize=0); /** read String from an IO Object */ int read(String &str, uint32 arrysize=0); /** read serializable object in */ //int read(Serializable *object); }; } } #endif // __SRL_BINARYREADER__
39.333333
81
0.563089
[ "object" ]
20a51f7997d03fb65707fc8a1bb65b3ff8a6cb01
6,873
c
C
nitan/clone/fam/item/zhangpeng2.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/clone/fam/item/zhangpeng2.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/clone/fam/item/zhangpeng2.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
#include <ansi.h> inherit ITEM; int is_zhangpeng() { return 1;} void create() { set_name(HIM "雙人帳篷" NOR, ({ "shuangren zhangpeng", "shuangren", "zhangpeng"}) ); set_weight(4000); set_max_encumbrance(1000000); if (clonep()) set_default_object(__FILE__); else { set("value", 1000000); set("long", HIM "這是一個雙人帳篷,你可以打開帳篷來休息(指令:openzp)。\n" NOR); set("unit", "個"); set("no_hand", 1); set("no_steal", 1); set("no_clean_up", 1); } setup(); } void init() { add_action("do_open", "openzp"); add_action("do_close", "closezp"); add_action("do_out", "outzp"); add_action("do_enter", "enterzp"); add_action("do_joinzp", "joinzp"); // 設置允許進入帳篷的ID } // 設置允許進入帳篷的ID int do_joinzp(string arg) { object me, ob; me = this_player(); ob = this_object(); if (! arg)return notify_fail("設置失敗!指令格式:joinzp ID\n"); ob->set("join_id", arg); tell_object(me, HIG "設置成功!\n" NOR); return 1; } // 進入帳篷 int do_enter() { object me, ob, obj; object *obs; int i; me = this_player(); ob = this_object(); if (ob->query("opening") != me->query("id") && ob->query("join_id") != me->query("id")) return notify_fail("你目前無法進入這個帳篷。\n"); if (environment(me) == ob) return notify_fail("你不是已經進來了嗎?\n"); // 多人檢查 obs = all_inventory(ob); i = 0; foreach (obj in obs) { if (userp(obj))i ++; } if (i >= 2) return notify_fail("對不起,雙人帳篷已經人滿了。\n"); me->move(ob); message_vision(HIC "$N一頭鑽進" + ob->name() + HIC "。\n" NOR, me); return 1; } // 出帳篷 int do_out() { object me, ob; me = this_player(); ob = this_object(); if (environment(me) != ob) return notify_fail("你並沒有在帳篷裏啊。\n"); if (! ob->query("out")) return notify_fail("目前無法出帳篷。\n"); message_vision(HIC "$N鑽出帳篷。\n" NOR, me); me->move(ob->query("out")); return 1; } // 打開帳篷 int do_open() { object me; object env; object obt, obj; object *obs; me = this_player(); if (environment(this_object()) != me)return 0; if (me->query("shuangren_zhangpeng/flag")) { return notify_fail("你已經有雙人帳篷被打開了,不能再打開帳篷。\n"); } if (this_object()->query("opening")) return notify_fail("帳篷不是打開的麼?\n"); env = environment(me); if (env->is_zhangpeng()) return notify_fail("這個地方不能再打開雙人帳篷了。\n"); if (! env->query("outdoors")) return notify_fail("帳篷只能在户外打開。\n"); if (me->is_busy() || me->is_fighting()) return notify_fail("你現在正忙於做其他事情,無法打開帳篷。\n"); // 一個地點只能開一個帳篷 obs = all_inventory(env); foreach(obj in obs) { if (obj->is_zhangpeng()) { return notify_fail("這個地方已經有人擺帳篷了,你還是換個地方吧。\n"); } } obt = new("/clone/fam/item/zhangpeng2"); // 設置主人 obt->set("opening", me->query("id")); obt->set("no_get", 1); // 設置描述 obt->set("long", HIW "這是一個雙人帳篷,你可以收起帳篷(指令:closezp)。\n" HIW "****設置允許進入帳篷的朋友ID(指令:joinzp ID)。\n" HIW "****如果覺得悶了可以到外面透透氣(outzp),進入帳篷使用指令(enterzp)。\n" NOR); // 設置特殊屬性 obt->set("sleep_room", 1); obt->set("no_fight", 1); // 設置出口 obt->set("out", file_name(env)); message_vision(HIC "$N打開" + this_object()->name() + HIC "一頭鑽了進去。\n" NOR, me); me->move(obt); obt->move(env); // 設置特殊標誌 me->set("shuangren_zhangpeng/flag", 1); me->set("shuangren_zhangpeng/ob", obt); me->save(); destruct(this_object()); return 1; } int do_close(string arg) { object me, obt; object *obs; object obj, newob; me = this_player(); obt = this_object(); if (! obt->query("opening")) return notify_fail("雙人帳篷不是關閉着的麼?\n"); if (obt->query("opening") != me->query("id")) return notify_fail("你沒有權利收起這個帳篷。\n"); // 複製一個帳篷給該玩家 newob = new("/clone/fam/item/zhangpeng2"); message_vision(HIW "$N將帳篷收了起來,裝進行囊。\n" NOR, me); // 檢查負重 if (newob->query_weight() + me->query_encumbrance() >= me->query_max_encumbrance()) { tell_object(HIR "對不起,你的負重不足,無法收起這個帳篷。\n" NOR); destruct(newob); return 1; } // 想將帳篷裏的人移出來,然後摧毀帳篷,最後複製一個帳篷給該玩家 obs = all_inventory(obt); // 將帳篷裏的人都移出來 if (sizeof(obs)) { foreach(obj in obs) { obj->move(environment(obt)); } } // 將複製的帳篷給該玩家 newob->move(me, 1); me->delete("shuangren_zhangpeng"); me->save(); // 摧毀這個帳篷 destruct(this_object()); return 1; } int query_autoload() { return 1; }
28.6375
103
0.374218
[ "object" ]
20a5d9defbde093bfede97b02e48d129eb1a91fc
1,153
h
C
Plugins/uk.ac.kcl.VascularModeling/src/FaceListTableModel.h
carthurs/CRIMSONGUI
1464df9c4d04cf3ba131ca90b91988a06845c68e
[ "BSD-3-Clause" ]
10
2020-09-17T18:55:31.000Z
2022-02-23T02:52:38.000Z
Plugins/uk.ac.kcl.VascularModeling/src/FaceListTableModel.h
carthurs/CRIMSONGUI
1464df9c4d04cf3ba131ca90b91988a06845c68e
[ "BSD-3-Clause" ]
null
null
null
Plugins/uk.ac.kcl.VascularModeling/src/FaceListTableModel.h
carthurs/CRIMSONGUI
1464df9c4d04cf3ba131ca90b91988a06845c68e
[ "BSD-3-Clause" ]
3
2021-05-19T09:02:21.000Z
2021-07-26T17:39:57.000Z
#pragma once #include <set> #include <mitkDataNode.h> #include <FaceIdentifier.h> #include <QAbstractTableModel> #include "uk_ac_kcl_VascularModeling_Export.h" /*! \brief A QAbstractTableModel representing a list of faces of a solid model. */ class VASCULARMODELING_EXPORT FaceListTableModel : public QAbstractTableModel { Q_OBJECT public: static const int FaceIdRole = Qt::UserRole + 100; public: FaceListTableModel(QObject* parent = nullptr) : QAbstractTableModel(parent) {} void setVesselTreeNode(const mitk::DataNode::Pointer& vesselTreeNode); void setFaces(const std::set<crimson::FaceIdentifier>& faces); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; protected: mitk::DataNode::Pointer _vesselTreeNode; mitk::DataNode::Pointer _solidModelNode; std::set<crimson::FaceIdentifier> _faces; };
34.939394
109
0.752819
[ "model", "solid" ]
e35864e8cc7645aa1525a4f4704daf2b2a631175
2,509
h
C
Rumble3D/include/R3D/ParticleEngine/ParticleWorld.h
Nelaty/Rumble3D
801b9feec27ceeea91db3b759083f6351634e062
[ "MIT" ]
1
2020-01-21T16:01:53.000Z
2020-01-21T16:01:53.000Z
Rumble3D/include/R3D/ParticleEngine/ParticleWorld.h
Nelaty/Rumble3D
801b9feec27ceeea91db3b759083f6351634e062
[ "MIT" ]
1
2019-10-08T08:25:33.000Z
2019-10-09T06:39:06.000Z
Rumble3D/include/R3D/ParticleEngine/ParticleWorld.h
Nelaty/Rumble3D
801b9feec27ceeea91db3b759083f6351634e062
[ "MIT" ]
1
2019-05-14T13:48:16.000Z
2019-05-14T13:48:16.000Z
#pragma once #include "R3D/Common/Common.h" #include "R3D/PhysicsEngineModule.h" #include "R3D/ParticleEngine/ParticleDef.h" #include "R3D/ParticleEngine/ParticleForceRegistry.h" #include "R3D/ParticleEngine/ParticleContactGeneratorRegistry.h" #include <vector> namespace r3 { class Particle; class ParticleContactGenerator; class ParticleEngineCI; /** * \brief A ParticleWorld is a physics engine module, used to * simulate particles. */ class R3D_DECLSPEC ParticleWorld : public PhysicsEngineModule { public: using Particle_Ptr = Particle*; using Particle_Container = std::vector<Particle_Ptr>; explicit ParticleWorld() = default; ~ParticleWorld() = default; /** * \brief Change the computation interface, used by the module. * \param computationInterface The new computation interface. */ void setComputationInterface(ParticleEngineCI* computationInterface); /** * \brief Get the module's computation interface. * \return The currently used computation interface. */ IComputationInterface* getComputationInterface() const override; /** * \brief Add an existent particle */ void addParticle(Particle* particle); /** * \brief Remove a registered particle */ void removeParticle(Particle* particle); /** * \brief Get the module's particle force registry * \return The particle force registry */ ParticleForceRegistry& getParticleForceRegistry(); /** * \brief Get the module's particle force registry * \return The particle force registry */ const ParticleForceRegistry& getParticleForceRegistry() const; /** * \brief Get the module's particles. * \return All currently registered particles. */ Particle_Container& getParticles(); /** * \brief Get the module's particles. * \return All currently registered particles. */ const Particle_Container& getParticles() const; /** * \brief Get the module's particle contact generator registry. * \return The particle contact generator registry */ ParticleContactGeneratorRegistry& getContactGeneratorRegistry(); /** * \brief Get the module's particle contact generator registry. * \return The particle contact generator registry */ const ParticleContactGeneratorRegistry& getContactGeneratorRegistry() const; private: ParticleEngineCI* m_computationInterface{}; ParticleForceRegistry m_forceRegistry; ParticleContactGeneratorRegistry m_contactGeneratorRegistry; Particle_Container m_particles; }; }
27.571429
78
0.743723
[ "vector" ]
e35a23055a68af9dc2449e1a7588e73ada4d5b95
11,717
c
C
source/ti/sail/led/led.c
seank-com/azure-iot-sdk-tirtos-cc3220
7d7d89195cda2a5698fd9fdd5f153caf410bb4c7
[ "MIT" ]
null
null
null
source/ti/sail/led/led.c
seank-com/azure-iot-sdk-tirtos-cc3220
7d7d89195cda2a5698fd9fdd5f153caf410bb4c7
[ "MIT" ]
null
null
null
source/ti/sail/led/led.c
seank-com/azure-iot-sdk-tirtos-cc3220
7d7d89195cda2a5698fd9fdd5f153caf410bb4c7
[ "MIT" ]
null
null
null
/* * Copyright (c) 2016-2017, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * ======== led.c ======== */ /* Driver Header files */ #include <ti/drivers/GPIO.h> #include <ti/drivers/PWM.h> /* Module Header */ #include <ti/sail/led/led.h> #define LED_BLINKPERIOD_ZERO 0U /* To indicate no blinking operation*/ #define LED_PWMPERIOD_1MS 1000U /* Default PWM period is 1 ms*/ /* Default LED parameters structure */ const LED_Params LED_defaultParams = { LED_GPIO_CONTROLLED, /* By default, LED is GPIO controlled*/ NULL, /* As default is GPIO, PWM handle is NULL*/ LED_PWMPERIOD_1MS, /* Default PWM period is 1 ms*/ LED_BRIGHTNESS_MIN, /* To keep minimum brightness*/ LED_STATE_OFF, /* Set LED state to OFF*/ LED_BLINKPERIOD_ZERO /* Blink period zero i.e. no blinking*/ }; extern LED_Config LED_config[]; /* Used to check status and initialization */ static int LED_count = -1; /* Static Functions followed by regular ones*/ static void timerTimeoutHandler(sigval val) { LED_toggle((LED_Handle)val.sival_ptr); } /* * ======== LED_close ======== * Closes an instance of a led sensor. */ void LED_close(LED_Handle ledHandle) { LED_Object *obj = (LED_Object *)(ledHandle->object); LED_stopBlinking(ledHandle); LED_setOff(ledHandle); /* Delete opened timer*/ timer_delete(obj->timer); } /* * ======== LED_getState ======== */ LED_State LED_getState(LED_Handle ledHandle) { LED_Object *obj = (LED_Object *)(ledHandle->object); return (obj->state); } /* * ======== LED_init ======== */ void LED_init() { if (LED_count == -1) { /* Call each driver's init function */ for (LED_count = 0; LED_config[LED_count].object != NULL; LED_count++) { ((LED_Object *)(LED_config[LED_count].object))->ledType = LED_GPIO_CONTROLLED; ((LED_Object *)(LED_config[LED_count].object))->pwmHandle = NULL; ((LED_Object *)(LED_config[LED_count].object))->pwmPeriod = LED_PWMPERIOD_1MS; ((LED_Object *)(LED_config[LED_count].object))->blinkPeriod= LED_BLINKPERIOD_ZERO; ((LED_Object *)(LED_config[LED_count].object))->brightness = LED_BRIGHTNESS_MIN; ((LED_Object *)(LED_config[LED_count].object))->state = LED_STATE_OFF; ((LED_Object *)(LED_config[LED_count].object))->rawState = LED_STATE_OFF; } } } /* * ======== LED_open ======== * Sets up led sensor and returns LED_Handle */ LED_Handle LED_open(unsigned int ledIndex, LED_Params *params) { LED_Handle ledHandle; LED_Object *obj; sigevent sev; int retc; /* ledIndex cannot be more than number of available LEDs*/ if ((ledIndex >= LED_count)) { return (NULL); } /* If params are NULL use defaults. */ if (params == NULL) { params = (LED_Params *)(&LED_defaultParams); } else if ((params->ledType == LED_PWM_CONTROLLED) & (params->pwmHandle == NULL)) { /* Need valid pwmHandle for PWM controlled LEDs*/ return (NULL); } /* Get handle for this driver instance */ ledHandle = (LED_Handle)(&LED_config[ledIndex]); obj = (LED_Object *)(LED_config[ledIndex].object); /* create the timer instance*/ sev.sigev_notify = SIGEV_SIGNAL; sev.sigev_value.sival_ptr = ledHandle; sev.sigev_notify_function = &timerTimeoutHandler; sev.sigev_notify_attributes = NULL; retc = timer_create(CLOCK_MONOTONIC,&sev, &obj->timer); if (0 != retc) { return (NULL); } /* Update Object fields*/ obj->ledType = params->ledType; obj->pwmHandle = params->pwmHandle; obj->pwmPeriod = params->pwmPeriod; obj->brightness = params->brightness; /* Set LED state, default is Off if setState is not modified by user*/ switch (params->setState) { case LED_STATE_OFF: LED_setOff(ledHandle); break; case LED_STATE_ON: LED_setOn(ledHandle, obj->brightness); break; case LED_STATE_BLINKING: LED_startBlinking(ledHandle, params->blinkPeriod); break; default: /* Invalid setState value*/ break; } return (ledHandle); } /* * ======== LED_initParams ======== * Initialize a LED_Params struct to default settings. */ void LED_initParams(LED_Params *params) { *params = LED_defaultParams; } /* * ======== LED_setBrightnessLevel ======== * Sets brightness level as requested. */ bool LED_setBrightnessLevel(LED_Handle ledHandle, uint16_t level) { uint32_t duty = 0; LED_Object *obj = (LED_Object *)(ledHandle->object); /* Report false if brightness request is more than maximum(100%) level */ if (level > LED_BRIGHTNESS_MAX) { return false; } /* For PWM LED, calculate duty based on requested level and set that */ if (obj->ledType == LED_PWM_CONTROLLED) { duty = (obj->pwmPeriod * level)/100; PWM_setDuty(obj->pwmHandle, duty); obj->brightness = level; } /* For GPIO LED, return 'false' to reflect invalid request as GPIO LED can * be just turned On or Off and intermediate brightness level can't be set*/ else if (obj->ledType == LED_GPIO_CONTROLLED) { return false; } return true; } /* * ======== LED_setOff ======== * Turns Off a specified a led sensor. */ void LED_setOff(LED_Handle ledHandle) { LED_Object *obj = (LED_Object *)(ledHandle->object); uint16_t level; if (obj->ledType == LED_GPIO_CONTROLLED) { GPIO_write(((LED_HWAttrs*)ledHandle->hwAttrs)->gpioIndex, LED_OFF); } /* For PWM LED, set brightness to zero * Also, restoring brightness level which was there before turning it Off * so that Toggle APIs can set same brightness while turning it On */ else { level = obj->brightness; LED_setBrightnessLevel(ledHandle, LED_BRIGHTNESS_MIN); obj->brightness = level; } /* Set LED state and rawState * If LED is blinking, which is a separate state(mix of ON + OFF), no need * to change state; rawState contains the actual ON or OFF state*/ if (obj->state != LED_STATE_BLINKING) { obj->state = LED_STATE_OFF; } obj->rawState = LED_STATE_OFF; } /* * ======== LED_setOn ======== * Turns On a specified led sensor. */ bool LED_setOn(LED_Handle ledHandle,uint16_t brightness) { bool ret = true; LED_Object *obj = (LED_Object *)(ledHandle->object); if (obj->ledType == LED_GPIO_CONTROLLED) { GPIO_write(((LED_HWAttrs*)ledHandle->hwAttrs)->gpioIndex, LED_ON); } /* For PWM LED, turn it On with requested level, also pouplate error */ else { ret = LED_setBrightnessLevel(ledHandle, brightness); } /* Set LED state(conditional) and rawState(always)*/ if (ret == true) { if (obj->state != LED_STATE_BLINKING) { obj->state = LED_STATE_ON; } obj->rawState = LED_STATE_ON; } return ret; } /* * ======== LED_startBlinking ======== * Starts blinking a led with specified period. */ void LED_startBlinking(LED_Handle ledHandle, uint16_t blinkPeriod) { LED_Object *obj = (LED_Object *)(ledHandle->object); struct itimerspec its; /* If LED is starting to blink afresh*/ if (obj->state != LED_STATE_BLINKING) { /* No need to start blinking if blinkperiod is passed as zero*/ if (blinkPeriod == LED_BLINKPERIOD_ZERO) { /* do nothing*/ } else { /* start the periodic timer with period = blinkperiod * in ms units*/ its.it_interval.tv_sec = blinkPeriod/1000; its.it_interval.tv_nsec = (blinkPeriod%1000) * 1000000; its.it_value.tv_sec = blinkPeriod/1000; its.it_value.tv_nsec = (blinkPeriod%1000) * 1000000; timer_settime(obj->timer, 0, &its, NULL); obj->blinkPeriod = blinkPeriod; obj->state = LED_STATE_BLINKING; } } else if (obj->state == LED_STATE_BLINKING) { /* If LED is already blinking and requested to change the blink period * Execute sequence: do a settime again*/ if (obj->blinkPeriod != blinkPeriod) { /* start the periodic timer with period = blinkperiod * in ms units*/ its.it_interval.tv_sec = blinkPeriod/1000; its.it_interval.tv_nsec = (blinkPeriod%1000) * 1000000; its.it_value.tv_sec = blinkPeriod/1000; its.it_value.tv_nsec = (blinkPeriod%1000) * 1000000; timer_settime(obj->timer, 0, &its, NULL); obj->blinkPeriod = blinkPeriod; obj->state = LED_STATE_BLINKING; } else { /* If LED is already blinking with same period, do nothing*/ } } } /* * ======== LED_stopBlinking ======== * Stops blinking a led. */ void LED_stopBlinking(LED_Handle ledHandle) { LED_Object *obj = (LED_Object *)(ledHandle->object); struct itimerspec its; if (obj->state == LED_STATE_BLINKING) { /* stop the periodic timer with period*/ its.it_interval.tv_sec = 0; its.it_interval.tv_nsec = 0; its.it_value.tv_sec = 0; its.it_value.tv_nsec = 0; timer_settime(obj->timer, 0, &its, NULL);; /* After stoping blinking, sets LED Off, a default LED state*/ LED_setOff(ledHandle); obj->state = LED_STATE_OFF; } else { /* If LED is not bliking, no need to stop it, so ignore the request*/ } } /* * ======== LED_toggle ======== * Toggle a led. */ void LED_toggle(LED_Handle ledHandle) { LED_Object *obj = (LED_Object *)(ledHandle->object); if (obj->rawState == LED_STATE_ON) { LED_setOff(ledHandle); } else if (obj->rawState == LED_STATE_OFF) { LED_setOn(ledHandle, obj->brightness); } }
29.146766
94
0.624819
[ "object" ]
e360a3cf88670abb025a93d4db92347b911451ef
22,135
c
C
maze.c
creachadair/mazegen
b571be0f0ba8c3bcd34070196d0cc7c2b0747f2b
[ "BSD-3-Clause" ]
null
null
null
maze.c
creachadair/mazegen
b571be0f0ba8c3bcd34070196d0cc7c2b0747f2b
[ "BSD-3-Clause" ]
null
null
null
maze.c
creachadair/mazegen
b571be0f0ba8c3bcd34070196d0cc7c2b0747f2b
[ "BSD-3-Clause" ]
null
null
null
/* Name: maze.c Purpose: Maze generation library. Author: M. J. Fromberger <http://github.com/creachadair> Copyright (C) 1998-2006 M. J. Fromberger, All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "maze.h" #include <assert.h> #include <ctype.h> #include <stdlib.h> #include "gd.h" #define LINE_WIDTH 80 /* characters */ /* Population count for adjacent cell values */ static unsigned int adj_pop[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; /* s_can_move(*mp, r, c, dir) Return true if it is possible to move in the given direction from the cell whose row and column are specified. You can move in a direction from a cell if there is no wall in the way. Note that there are magic unbreakable walls around the entire maze. */ static int s_can_move(maze_t *mp, rowcol_t r, rowcol_t c, unsigned int dir) { assert(0 <= dir && dir < 4); switch (dir) { case DIR_U: return (r > 0 && CELLV(mp, r - 1, c).b_wall == 0); case DIR_R: return (c < mp->n_cols && CELLV(mp, r, c).r_wall == 0); case DIR_D: return (r < mp->n_rows - 1 && CELLV(mp, r, c).b_wall == 0); default: return (c > 0 && CELLV(mp, r, c - 1).r_wall == 0); } } /* s_findset(mp, pos) Find which path set the given position occupies. Performs path compression as needed. */ rowcol_t s_findset(maze_t *mp, rowcol_t pos) { if (mp->sets[pos] != pos) { rowcol_t real = s_findset(mp, mp->sets[pos]); mp->sets[pos] = real; } return mp->sets[pos]; } /* s_union(mp, pos1, pos2) Put positions pos1 and pos2 into the same path set. */ void s_union(maze_t *mp, rowcol_t pos1, rowcol_t pos2) { rowcol_t set1 = s_findset(mp, pos1); rowcol_t set2 = s_findset(mp, pos2); mp->sets[set1] = set2; } /* s_adj(*mp, pos) Return a bit vector flagging which directions you can go from the given maze position to reach a different path set than the position is currently in. */ rowcol_t s_adj(maze_t *mp, rowcol_t pos) { rowcol_t set = s_findset(mp, pos); rowcol_t out = 0, r, c; r = pos / mp->n_cols; c = pos % mp->n_cols; if (r > 0 && s_findset(mp, OFFSET(mp, r - 1, c)) != set) out |= (1 << DIR_U); if (r < mp->n_rows - 1 && s_findset(mp, OFFSET(mp, r + 1, c)) != set) out |= (1 << DIR_D); if (c > 0 && s_findset(mp, OFFSET(mp, r, c - 1)) != set) out |= (1 << DIR_L); if (c < mp->n_cols - 1 && s_findset(mp, OFFSET(mp, r, c + 1)) != set) out |= (1 << DIR_R); return out; } /* maze_init(*mp, nr, nc) Create a new maze structure with nr rows and nc columns. The resulting maze is initialized to "all walls". */ int maze_init(maze_t *mp, rowcol_t nr, rowcol_t nc) { unsigned int n_cells = nr * nc; assert(mp != NULL); assert(n_cells > 0); if ((mp->cells = malloc(n_cells * sizeof(*(mp->cells)))) == NULL) return 0; /* out of memory */ mp->n_rows = nr; mp->n_cols = nc; mp->sets = NULL; mp->exit_1 = EXIT(0, DIR_L); mp->exit_2 = EXIT(nr - 1, DIR_R); maze_reset(mp); return 1; } /* maze_load(*mp, *ifp) Load a maze from the given file stream, in the pickled format generated by maze_store(). Returns false in case of error; a true result means the load was successful. */ int maze_load(maze_t *mp, FILE *ifp) { rowcol_t rows, cols, exit_1, exit_2; rowcol_t r, c; int result, ch; result = fscanf(ifp, "%u %u %u %u\n", &rows, &cols, &exit_1, &exit_2); if (result == EOF || result < 4) { fprintf(stderr, "maze_load: missing dimension line\n"); return 0; } if (!maze_init(mp, rows, cols)) return 0; mp->exit_1 = exit_1; mp->exit_2 = exit_2; ch = fgetc(ifp); for (r = 0; r < rows; ++r) { while (isspace(ch)) ch = fgetc(ifp); for (c = 0; c < cols; ++c) { maze_node cell = {0, 0, DIR_U, 0}; rowcol_t v; if (ch == EOF) { fprintf(stderr, "maze_load: premature end of input at %u x %u\n", r, c); return 0; } cell.visit = isupper(ch) ? 1 : 0; v = cell.visit ? (ch - 'A') : (ch - 'a'); cell.r_wall = v & 1; cell.b_wall = (v >> 1) & 1; cell.marker = (v >> 2) & 3; CELLV(mp, r, c) = cell; do ch = fgetc(ifp); while (isspace(ch)); } } return 1; } /* maze_store(*mp, *ofp) Write a compact representation of the maze as text to the given output file stream. */ void maze_store(maze_t *mp, FILE *ofp) { rowcol_t r, c, pos = 0; fprintf(ofp, "%u %u %u %u\n", mp->n_rows, mp->n_cols, mp->exit_1, mp->exit_2); for (r = 0; r < mp->n_rows; ++r) { for (c = 0; c < mp->n_cols; ++c) { maze_node cell = CELLV(mp, r, c); rowcol_t v = 0; v |= cell.marker << 2; v |= cell.b_wall << 1; v |= cell.r_wall; if (cell.visit) fputc('A' + v, ofp); else fputc('a' + v, ofp); pos = (pos + 1) % LINE_WIDTH; if (!pos) fputc('\n', ofp); } } if (pos) fputc('\n', ofp); } /* maze_clear(*mp) Release the memory occupied by a maze structure. It is safe to call this multiple times on the same structure. */ void maze_clear(maze_t *mp) { assert(mp != NULL); if (mp->cells != NULL) free(mp->cells); mp->cells = NULL; mp->n_rows = 0; mp->n_cols = 0; } /* maze_reset(*mp) Reset every cell of the maze to have two walls (right and bottom), its marker oriented UP, and its visited bit off. */ void maze_reset(maze_t *mp) { rowcol_t r, c; maze_node def; assert(mp != NULL); def.r_wall = 1; def.b_wall = 1; def.marker = DIR_U; def.visit = 0; for (r = 0; r < mp->n_rows; ++r) for (c = 0; c < mp->n_cols; ++c) CELLV(mp, r, c) = def; } /* maze_unmark(*mp) Clear all visitation marks and reset markers to up. */ void maze_unmark(maze_t *mp) { rowcol_t pos, n_cells; assert(mp != NULL); n_cells = mp->n_rows * mp->n_cols; for (pos = 0; pos < n_cells; ++pos) { mp->cells[pos].visit = 0; mp->cells[pos].marker = DIR_U; } } /* maze_generate(*mp, start_row, start_col, random) Generate a random maze, starting at th */ int maze_generate(maze_t *mp, rand_f random) { rowcol_t n_cells = mp->n_rows * mp->n_cols; rowcol_t *queue; rowcol_t pos, count = 0; maze_reset(mp); if ((mp->sets = malloc(n_cells * sizeof(*(mp->sets)))) == NULL) return 0; /* out of memory */ if ((queue = malloc(n_cells * sizeof(*queue))) == NULL) { free(mp->sets); mp->sets = NULL; return 0; /* out of memory */ } /* Initially, all cells belong to their own set, and the queue is in scan order. */ for (pos = 0; pos < n_cells; ++pos) { queue[pos] = pos; mp->sets[pos] = pos; } while (count < n_cells) { /* As long as there are cells which have neighbours not in their own set, scan the queue and connect unrelated regions. Each cell is examined to see if it has any adjacent cells which are in a different path set. If not, randomly choose a neighbor in a different path set, and kick down the wall between them. */ /* Reshuffle the queue */ for (pos = n_cells - 1; pos > 0; --pos) { double v = random(); rowcol_t exch = (rowcol_t)(v * (pos + 1)), t; t = queue[pos]; queue[pos] = queue[exch]; queue[exch] = t; } /* Scan the queue */ for (pos = 0; pos < n_cells; ++pos) { rowcol_t cur = queue[pos]; rowcol_t adj, apop, wall, r, c; rowcol_t skip = 0; adj = s_adj(mp, cur); apop = adj_pop[adj]; if (apop == 0) { count += 1; continue; } if (apop > 1) skip = (rowcol_t)(random() * apop); for (wall = 0; wall < 4; ++wall) { if ((adj >> wall) & 1) { if (skip == 0) break; --skip; } } /* Now, wall is the direction of the wall to kick down */ r = cur / mp->n_cols; c = cur % mp->n_cols; switch (wall) { case DIR_U: --r; CELLV(mp, r, c).b_wall = 0; break; case DIR_R: CELLV(mp, r, c).r_wall = 0; ++c; break; case DIR_D: CELLV(mp, r, c).b_wall = 0; ++r; break; case DIR_L: --c; CELLV(mp, r, c).r_wall = 0; break; default: assert(0 && "Unreachable case in switch(wall) of " "maze_generate(...)"); break; } /* Join this cell to the path set of the one we just connected to */ s_union(mp, OFFSET(mp, r, c), cur); } } /* When finished, clean up temporary memory */ free(mp->sets); mp->sets = NULL; free(queue); return 1; } /* maze_find_path(*mp, start_row, start_col, end_row, end_col) Find and mark a path from the specified starting position of the maze to the specified ending position, if possible. This assumes the maze is a connected graph. The algorithm is simple right-handed depth-first search, using the markers and visited bits of the maze cells to keep track of where the search has been. It is possible this will not terminate if the goal is not reachable from the start. */ void maze_find_path(maze_t *mp, rowcol_t start_row, rowcol_t start_col, rowcol_t end_row, rowcol_t end_col) { rowcol_t c_row, c_col; maze_unmark(mp); c_row = start_row; c_col = start_col; for (;;) { unsigned int c_dir, num_walls; if (c_row == end_row && c_col == end_col) break; /* done, found the goal */ /* Find a direction to go which is a clear path */ c_dir = CELLV(mp, c_row, c_col).marker; for (num_walls = 0; num_walls < 4; ++num_walls) { c_dir = (c_dir + 1) % 4; /* Mark which way we're about to move */ if (s_can_move(mp, c_row, c_col, c_dir)) { CELLV(mp, c_row, c_col).marker = c_dir; break; } } /* Safety check, shouldn't trigger unless you're trying to find a path in an incomplete maze, which is an error. */ assert(num_walls < 4 || "Unescapable start position in maze_find_path(...)"); /* Move in that new direction, and set the new cell's marker to point the way back in case we need to backtrack. */ switch (c_dir) { case DIR_U: c_row--; CELLV(mp, c_row, c_col).marker = DIR_D; break; case DIR_R: c_col++; CELLV(mp, c_row, c_col).marker = DIR_L; break; case DIR_D: c_row++; CELLV(mp, c_row, c_col).marker = DIR_U; break; case DIR_L: c_col--; CELLV(mp, c_row, c_col).marker = DIR_R; break; default: assert(0 && "Unreachable case in switch(c_dir) " "of maze_find_path(...)"); break; } } /* end for(ever) */ /* At this point, we have found the path, and the markers point the route back to the starting cell. This loop traverses the path back to the start and sets all the visited flags of the cells that are on-route. */ c_row = start_row; c_col = start_col; do { CELLV(mp, c_row, c_col).visit = 1; switch (CELLV(mp, c_row, c_col).marker) { case DIR_U: c_row--; break; case DIR_R: c_col++; break; case DIR_D: c_row++; break; case DIR_L: c_col--; break; default: assert(0 && "Unreachable case in switch(marker) " "of maze_find_path(...)"); } } while (c_row != end_row || c_col != end_col); CELLV(mp, c_row, c_col).visit = 1; } /* maze_write_png(*mp, *ofp, h_res, v_res) Write the specified maze as a PNG file to the given output stream. The resulting image file is h_res pixels wide and v_res pixels tall. Solutions are plotted if present. */ void maze_write_png(maze_t *mp, FILE *ofp, unsigned int h_res, unsigned int v_res) { gdImagePtr img; unsigned int h_wid, v_wid; int clr_black, clr_white, clr_path; rowcol_t r, c, h_base, v_base; rowcol_t p1, p2, dir1, dir2; p1 = EPOS(mp->exit_1); dir1 = EDIR(mp->exit_1); if (dir1 == DIR_R) CELLV(mp, p1, mp->n_cols - 1).r_wall = 0; else if (dir1 == DIR_D) CELLV(mp, mp->n_rows - 1, p1).b_wall = 0; p2 = EPOS(mp->exit_2); dir2 = EDIR(mp->exit_2); if (dir2 == DIR_R) CELLV(mp, p2, mp->n_cols - 1).r_wall = 0; else if (dir2 == DIR_D) CELLV(mp, mp->n_rows - 1, p2).b_wall = 0; img = gdImageCreate(h_res + 1, v_res + 1); h_wid = h_res / mp->n_cols; v_wid = v_res / mp->n_rows; /* Allocate colours for background, maze lines, and solutions */ clr_black = gdImageColorAllocate(img, 0, 0, 0); clr_white = gdImageColorAllocate(img, 255, 255, 255); clr_path = gdImageColorAllocate(img, 102, 102, 255); /* Clear the image to the background colour */ gdImageFilledRectangle(img, 0, 0, h_res, v_res, clr_white); /* Draw the top and left exterior walls */ for (c = 0; c < mp->n_cols; ++c) { if ((dir1 == DIR_U && p1 == c) || (dir2 == DIR_U && p2 == c)) continue; else gdImageLine(img, c * h_wid, 0, c * h_wid + h_wid, 0, clr_black); } for (r = 0; r < mp->n_rows; ++r) { if ((dir1 == DIR_L && p1 == r) || (dir2 == DIR_L && p2 == r)) continue; else { gdImageLine(img, 0, r * v_wid, 0, r * v_wid + v_wid, clr_black); } } for (r = 0; r < mp->n_rows; ++r) { v_base = r * v_wid; for (c = 0; c < mp->n_cols; ++c) { h_base = c * h_wid; if (CELLV(mp, r, c).r_wall) gdImageLine(img, h_base + h_wid, v_base, h_base + h_wid, v_base + v_wid, clr_black); if (CELLV(mp, r, c).b_wall) gdImageLine(img, h_base, v_base + v_wid, h_base + h_wid, v_base + v_wid, clr_black); /* Mark path components, if present */ if (CELLV(mp, r, c).visit) { rowcol_t left = 0, top = 0, width = 0, height = 0; switch (CELLV(mp, r, c).marker) { case DIR_U: case DIR_D: width = h_wid - 4; height = 2 * v_wid - 4; break; case DIR_L: case DIR_R: width = 2 * h_wid - 4; height = v_wid - 4; break; } switch (CELLV(mp, r, c).marker) { case DIR_R: case DIR_D: left = h_base + 2; top = v_base + 2; break; case DIR_L: left = h_base - h_wid + 2; top = v_base + 2; break; case DIR_U: left = h_base + 2; top = v_base - v_wid + 2; break; } gdImageFilledRectangle(img, left, top, left + width, top + height, clr_path); } } /* end column loop */ } /* end row loop */ gdImagePng(img, ofp); gdImageDestroy(img); } /* maze_write_eps(*mp, *ofp, h_res, v_res) Write an Encapsulated PostScript (EPS) version of the given maze to the specified output stream. A two-point padding is placed around the bounding box of the resulting figure. */ void maze_write_eps(maze_t *mp, FILE *ofp, unsigned int h_res, unsigned int v_res) { static const double line_width = 1.0; /* Weight of walls */ static const double line_grey = 0.0; /* Colour of walls */ static const double soln_grey = 0.7; /* Colour of solution markers */ static const double soln_gap = 0.2; /* % marker gap from walls */ double d_hres = (double)h_res, d_vres = (double)v_res; double h_wid = d_hres / mp->n_cols; double v_wid = d_vres / mp->n_rows; rowcol_t r, c; rowcol_t p1, p2, dir1, dir2; p1 = EPOS(mp->exit_1); dir1 = EDIR(mp->exit_1); if (dir1 == DIR_R) CELLV(mp, p1, mp->n_cols - 1).r_wall = 0; else if (dir1 == DIR_D) CELLV(mp, mp->n_rows - 1, p1).b_wall = 0; p2 = EPOS(mp->exit_2); dir2 = EDIR(mp->exit_2); if (dir2 == DIR_R) CELLV(mp, p2, mp->n_cols - 1).r_wall = 0; else if (dir2 == DIR_D) CELLV(mp, mp->n_rows - 1, p2).b_wall = 0; /* Emit minimal EPS header */ fprintf(ofp, "%%!PS-Adobe-3.0 EPSF-3.0\n" "%%%%BoundingBox: %d %d %u %u\n" "%%%%DocumentData: Clean7Bit\n\n", -2, -2, h_res + 2, v_res + 2); /* Emit common definitions */ fprintf(ofp, "/np {newpath} bind def\n" "/slw {setlinewidth} bind def\n" "/sg {setgray} bind def\n" "/mt {moveto} bind def\n" "/rmt {rmoveto} bind def\n" "/lt {lineto} bind def\n" "/rlt {rlineto} bind def\n" "/stk {stroke} bind def\n" "/sgrey %.1f def\n" "/lgrey %.1f def\n" "/lwid %.1f def\n" "/dr {lwid slw lgrey sg stk} def\n\n", soln_grey, line_grey, line_width); /* Draw top and left walls */ fprintf(ofp, "%% Exterior walls\n" "np\n%u %u mt\n", 0, v_res); for (c = 0; c < mp->n_cols; ++c) { if ((dir1 == DIR_U && p1 == c) || (dir2 == DIR_U && p2 == c)) fprintf(ofp, "%.1f 0 rmt ", h_wid); else fprintf(ofp, "%.1f 0 rlt ", h_wid); } fprintf(ofp, "dr\n" "np\n%u %u mt\n", 0, v_res); for (r = 0; r < mp->n_rows; ++r) { if ((dir1 == DIR_L && p1 == r) || (dir2 == DIR_L && p2 == r)) fprintf(ofp, "0 %.1f neg rmt ", v_wid); else fprintf(ofp, "0 %.1f neg rlt ", v_wid); } fputs("dr\n\n", ofp); for (r = 0; r < mp->n_rows; ++r) { double v_base = r * v_wid; for (c = 0; c < mp->n_cols; ++c) { double h_base = c * h_wid; maze_node n = CELLV(mp, r, c); if (n.r_wall || n.b_wall) { fprintf(ofp, "np "); if (n.r_wall) fprintf(ofp, "%.1f %.1f mt 0 %.1f neg rlt ", h_base + h_wid, v_res - v_base, v_wid); if (n.b_wall) fprintf(ofp, "%.1f %.1f mt %.1f 0 rlt ", h_base, v_res - v_base - v_wid, h_wid); fprintf(ofp, "dr\n"); } if (n.visit) { double hp = 0., vp = 0., h_dis = 0., v_dis = 0.; switch (n.marker) { case DIR_U: case DIR_D: h_dis = (1.0 - 2 * soln_gap) * h_wid; v_dis = (2.0 - 2 * soln_gap) * v_wid; break; case DIR_L: case DIR_R: h_dis = (2.0 - 2 * soln_gap) * h_wid; v_dis = (1.0 - 2 * soln_gap) * v_wid; break; } switch (n.marker) { case DIR_U: hp = h_base + soln_gap * h_wid; vp = v_base - (1.0 - soln_gap) * v_wid; break; case DIR_D: case DIR_R: hp = h_base + soln_gap * h_wid; vp = v_base + soln_gap * v_wid; break; case DIR_L: hp = h_base - (1.0 - soln_gap) * h_wid; vp = v_base + soln_gap * v_wid; break; } fprintf(ofp, "np %.1f %.1f mt %.1f 0 rlt 0 %.1f neg rlt " "%.1f neg 0 rlt 0 %.1f rlt ", hp, v_res - vp, h_dis, v_dis, h_dis, v_dis); fprintf(ofp, "sgrey sg fill\n"); } } /* end column loop */ } /* end row loop */ } /* maze_write_text(*mp, *ofp, h_res, v_res) Write a maze in a plain-text format. The h_res and v_res parameters are ignored (they are accepted so that the write functions will have a uniform interface). */ void maze_write_text(maze_t *mp, FILE *ofp, unsigned int h_res, unsigned int v_res) { rowcol_t r, c, p1, dir1, p2, dir2; /* Down-facing and right-facing exits can be modelled by editing the maze to kick out the walls in the appropriate cells. */ p1 = EPOS(mp->exit_1); dir1 = EDIR(mp->exit_1); if (dir1 == DIR_D) CELLV(mp, mp->n_rows - 1, p1).b_wall = 0; else if (dir1 == DIR_R) CELLV(mp, p1, mp->n_cols - 1).r_wall = 0; p2 = EPOS(mp->exit_2); dir2 = EDIR(mp->exit_2); if (dir2 == DIR_D) CELLV(mp, mp->n_rows - 1, p2).b_wall = 0; else if (dir2 == DIR_R) CELLV(mp, p2, mp->n_cols - 1).r_wall = 0; /* Draw the top border, respecting possible exits */ for (r = 0; r < mp->n_cols; ++r) { if ((dir1 == DIR_U && p1 == r) || (dir2 == DIR_U && p2 == r)) { fprintf(ofp, "+ "); } else fprintf(ofp, "+---"); } fputc('+', ofp); fputc('\n', ofp); /* Draw all the cells. The left border is drawn as we go, because of the line-oriented nature of stream output. */ for (r = 0; r < mp->n_rows; ++r) { if ((dir1 == DIR_L && p1 == r) || (dir2 == DIR_L && p2 == r)) fputc(' ', ofp); else fputc('|', ofp); for (c = 0; c < mp->n_cols; ++c) { if (CELLV(mp, r, c).visit) fprintf(ofp, " @ "); else fprintf(ofp, " "); fputc(CELLV(mp, r, c).r_wall ? '|' : ' ', ofp); } fputc('\n', ofp); fputc('+', ofp); for (c = 0; c < mp->n_cols; ++c) fputs(CELLV(mp, r, c).b_wall ? "---+" : " +", ofp); fputc('\n', ofp); } } /* Here there be dragons */
26.797821
80
0.552338
[ "vector" ]
e368b258f5005f3868f9a21ef10c55bb53ed7ba2
2,513
h
C
include/SimEngine/ObjectOfObservation.h
buzyaba/SimEngine
e5469f927154de43ea52ad74c0ca4a0af9a7b721
[ "MIT" ]
5
2019-10-21T11:38:56.000Z
2020-05-30T04:50:50.000Z
include/SimEngine/ObjectOfObservation.h
buzyaba/SimEngine
e5469f927154de43ea52ad74c0ca4a0af9a7b721
[ "MIT" ]
2
2020-03-16T13:16:27.000Z
2020-10-10T07:35:15.000Z
include/SimEngine/ObjectOfObservation.h
buzyaba/SimEngine
e5469f927154de43ea52ad74c0ca4a0af9a7b721
[ "MIT" ]
3
2019-10-10T15:10:57.000Z
2020-02-14T13:11:50.000Z
#pragma once #include "SimEngine/Object.h" /// Базовая реализация для наблюдаемых объектов class TObjectOfObservation : public TObject { protected: /// предок данного объекта TObjectOfObservation* parentObject; /// Потомки данного объекта, если потомков несколько, тоНужно оставить только одного std::vector<TObjectOfObservation*> childObjects; /// Соседние потомки std::vector<TObjectOfObservation*> neighboringObjects; /// Все свойства объекта начиная с себя самого std::vector<IProperties*> allProperties; public: TObjectOfObservation(std::string _name, std::vector<TObjectOfObservation*> _neighboringObject = { nullptr }, TObjectOfObservation* _parentObject = nullptr, TObjectOfObservation* _childObject = nullptr); TObjectOfObservation(const TObjectOfObservation& obj); /// Добавить объект который является хранилищем текущего объекта virtual void AddParentObject(TObjectOfObservation* object); /// Добавить дочерний объект virtual int AddChildObject(TObjectOfObservation* object); /// Возвращает вектор дочерних объектов virtual std::vector<TObjectOfObservation*>& GetChildObjects(); virtual TObjectOfObservation* GetChildObject(std::string name); virtual std::vector<TObjectOfObservation*>& GetNeighboringObjects(); virtual TObjectOfObservation* GetNeighboringObject(std::string name); virtual TObjectOfObservation* GetParentObject(); /// Добавить соседний объект, между ними может происходить объмен дочерними объектами virtual void AddNeighboringObject(TObjectOfObservation* object); /// Исключить дочерний объект virtual void ExcludeChildObject(TObjectOfObservation* object); /// Обновляет свойства данного объекта virtual void Update(); /// Возвращает все свойства объекта virtual std::vector<IProperties*>& GetAllProperties(); //maybe something wrong??? /// Создание клона объекта virtual TObjectOfObservation* Clone() { return new TObjectOfObservation("ObjectOfObservation"); } virtual bool isDrawable() { return true; } }; ///Тип функции-фабрики, которая экспортируется подключаемой библиотекой с объектами typedef TObjectOfObservation* CreateObjectOfObservation(); ///Префикс для фуккций, экспортируемых подключаемой библиотекой #ifdef WIN32 #define LIB_EXPORT_API __declspec(dllexport) #else #define LIB_EXPORT_API #endif
43.327586
94
0.730999
[ "object", "vector" ]
e37d9cd08ffc285a26f05967446d58fb6e0f505c
4,887
h
C
editor/renderer/include/CameraArcball.h
lizardkinger/blacksun
0119948726d2a057c13d208044c7664a8348a1ea
[ "Linux-OpenIB" ]
null
null
null
editor/renderer/include/CameraArcball.h
lizardkinger/blacksun
0119948726d2a057c13d208044c7664a8348a1ea
[ "Linux-OpenIB" ]
null
null
null
editor/renderer/include/CameraArcball.h
lizardkinger/blacksun
0119948726d2a057c13d208044c7664a8348a1ea
[ "Linux-OpenIB" ]
null
null
null
/*************************************************************************** * Copyright (C) 2006-07 by Reinhard Jeschull * rjeschu@fh-landshut.de * * 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. * (See COPYING for details.) *************************************************************************** * * Module: Renderer (BlackSun) * File: CameraArcball.h * Created: 12.12.2006 * Author: Reinhard Jeschull (rjeschu) * **************************************************************************/ #ifndef CAMERAARCBALL_H_ #define CAMERAARCBALL_H_ #include "RendererTypes.h" #include "Camera.h" /*! \file * * \brief Describes the class CameraArcball, their methodes and attributes. * \author Reinhard Jeschull * */ namespace BSRenderer { /*! \brief The perspective arcball camera * * A perspective camera that can be handled via arcball rotation. The camera can be rotated * around the scene by moving the mouse. */ class CameraArcball: public Camera { public: /*! * \brief The constructor * * Sets the viewport and set up a standard arcball camera * * \param nWidth The viewport width * \param nHeight The viewport height */ CameraArcball(int nWidth, int nHeight); /*! * \brief The destructor */ virtual ~CameraArcball() { } /*! * \brief Set the position of the camera * * \param vPos The position */ virtual void setPosition(const Vector& vPos) { Camera::setPosition(vPos); calcViewMatrix(); } /*! * \brief Set the dimension of the viewport * * \param nWidth The viewport width * \param nHeight The viewport height */ virtual void setViewport(int nWidth, int nHeight); /*! * \brief Set the clipping planes * * \param dNearPlane The near clipping plane * \param dFarPlane The far clipping plane */ virtual void setClippingPlanes(double dNearPlane = 0.1, double dFarPlane = 1000); /*! * \brief Set the field of view * * \param dFOV The field of view */ virtual void setFOV(double dFOV); /*! * \brief Reset the camera to default * * The camera will be reseted by restoring the variables to their default values */ virtual void reset(); /*! * \brief Tells the camera, that the mouse button was pressed * * \param nPosX The x-coordinate of the mouse position * (in relation the the widget-origin) * \param nPosY The y-coordinate of the mouse position * (in relation the the widget-origin) */ virtual void mousePress(int nPosX, int nPosY); /*! * \brief Tells the camera, that the mouse was moved * * \param nPosX The new x-coordinate of the mouse position * (in relation the the widget-origin) * \param nPosY The new y-coordinate of the mouse position * (in relation the the widget-origin) */ virtual void mouseMove(int nPosX, int nPosY); /*! * \brief Tells the camera, that the mouse was moved and should be translated * * \param nPosX The new x-coordinate of the mouse position * (in relation the the widget-origin) * \param nPosY The new y-coordinate of the mouse position * (in relation the the widget-origin) */ void mouseMoveTranslate(int nPosX, int nPosY); /*! * \brief Calls the camera, that the mouse wheel was rotated * * \param nDelta The delta-value of the mouse wheel */ virtual void mouseWheel(int nDelta); private: /*! * \brief Calculates the view matrix * * Calculates the matrix of the quaternion and applies the camera position */ void calcViewMatrix(); /*! * \brief Caluclates the projection matrix * * Calculates a perspective matrix (FOV) of viewport and clipping informations */ void calcProjMatrix(); private: Quat m_qRot; /*!< \brief The current rotation quaternion */ Quat m_qRotOld; /*!< \brief The old rotation quaternion (last move) */ Arcball<double> m_arcball; /*!< \brief The arcball */ int m_nLastMousePosX; /*!< \brief The last x-coordinate of the mouse */ int m_nLastMousePosY; /*!< \brief The last y-coordinate of the mouse */ }; } #endif /*CAMERAARCBALL_H_*/
27.767045
91
0.640065
[ "vector" ]
e37df43244aa7e428aa4a7a421d36e989ecfe5a5
2,985
h
C
rocksdb/options/db_options.h
YukioZzz/ls1-sys-prog-task7-performance-YukioZzz
841cc516958f27ff0a5d87403a5b1efe07bcd9d5
[ "MIT" ]
null
null
null
rocksdb/options/db_options.h
YukioZzz/ls1-sys-prog-task7-performance-YukioZzz
841cc516958f27ff0a5d87403a5b1efe07bcd9d5
[ "MIT" ]
null
null
null
rocksdb/options/db_options.h
YukioZzz/ls1-sys-prog-task7-performance-YukioZzz
841cc516958f27ff0a5d87403a5b1efe07bcd9d5
[ "MIT" ]
null
null
null
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. // This source code is licensed under both the GPLv2 (found in the // COPYING file in the root directory) and Apache 2.0 License // (found in the LICENSE.Apache file in the root directory). #pragma once #include <string> #include <vector> #include "rocksdb/options.h" namespace rocksdb { struct ImmutableDBOptions { ImmutableDBOptions(); explicit ImmutableDBOptions(const DBOptions &options); void Dump(Logger *log) const; bool create_if_missing; bool create_missing_column_families; bool error_if_exists; bool paranoid_checks; Env *env; std::shared_ptr<RateLimiter> rate_limiter; std::shared_ptr<SstFileManager> sst_file_manager; std::shared_ptr<Logger> info_log; InfoLogLevel info_log_level; int max_file_opening_threads; std::shared_ptr<Statistics> statistics; bool use_fsync; std::vector<DbPath> db_paths; std::string db_log_dir; std::string wal_dir; uint32_t max_subcompactions; int max_background_flushes; size_t max_log_file_size; size_t log_file_time_to_roll; size_t keep_log_file_num; size_t recycle_log_file_num; uint64_t max_manifest_file_size; int table_cache_numshardbits; uint64_t wal_ttl_seconds; uint64_t wal_size_limit_mb; size_t manifest_preallocation_size; bool allow_mmap_reads; bool allow_mmap_writes; bool use_direct_reads; bool use_direct_io_for_flush_and_compaction; bool allow_fallocate; bool is_fd_close_on_exec; bool advise_random_on_open; size_t db_write_buffer_size; std::shared_ptr<WriteBufferManager> write_buffer_manager; DBOptions::AccessHint access_hint_on_compaction_start; bool new_table_reader_for_compaction_inputs; size_t compaction_readahead_size; size_t random_access_max_buffer_size; size_t writable_file_max_buffer_size; bool use_adaptive_mutex; uint64_t bytes_per_sync; uint64_t wal_bytes_per_sync; std::vector<std::shared_ptr<EventListener> > listeners; bool enable_thread_tracking; bool enable_pipelined_write; bool allow_concurrent_memtable_write; bool enable_write_thread_adaptive_yield; uint64_t write_thread_max_yield_usec; uint64_t write_thread_slow_yield_usec; bool skip_stats_update_on_db_open; WALRecoveryMode wal_recovery_mode; bool allow_2pc; std::shared_ptr<Cache> row_cache; #ifndef ROCKSDB_LITE WalFilter *wal_filter; #endif // ROCKSDB_LITE bool fail_if_options_file_error; bool dump_malloc_stats; bool avoid_flush_during_recovery; bool allow_ingest_behind; }; struct MutableDBOptions { MutableDBOptions(); explicit MutableDBOptions(const MutableDBOptions &options) = default; explicit MutableDBOptions(const DBOptions &options); void Dump(Logger *log) const; int max_background_jobs; int base_background_compactions; int max_background_compactions; bool avoid_flush_during_shutdown; uint64_t delayed_write_rate; uint64_t max_total_wal_size; uint64_t delete_obsolete_files_period_micros; unsigned int stats_dump_period_sec; int max_open_files; }; } // namespace rocksdb
28.980583
70
0.829481
[ "vector" ]
e3a2fc3b009bca587ec6780108fad1c0014b9420
2,354
h
C
Hydroq/src/Game/GameView.h
dormantor/Hydroq
b3561fa576752db8366410c1e16f1edcf090d9c3
[ "MIT" ]
null
null
null
Hydroq/src/Game/GameView.h
dormantor/Hydroq
b3561fa576752db8366410c1e16f1edcf090d9c3
[ "MIT" ]
null
null
null
Hydroq/src/Game/GameView.h
dormantor/Hydroq
b3561fa576752db8366410c1e16f1edcf090d9c3
[ "MIT" ]
null
null
null
#pragma once #include "Behavior.h" #include "HydroqDef.h" #include "MsgPayloads.h" #include "GameMap.h" #include "GameModel.h" #include "PlayerModel.h" /** * Hydroq game view */ class GameView : public Behavior { private: // link to default sprite set spt<SpriteSet> defaultSpriteSet; // collection of all sprite types, mapped by its name map<string, vector<Sprite>> spriteTypes; // collection of static sprites spt<MultiSpriteMesh> staticSprites; // collection of static sprites, mapping by position map<Vec2i, spt<SpriteInst>> staticSpriteMap; // collection of dynamic sprites spt<MultiSpriteMesh> dynamicSprites; // hydroq settings Settings hydroqSettings; vector<spt<SpriteInst>> explosions; // collection of dynamic sprites, mapping by identifier map<int, spt<SpriteInst>> dynamicSpriteEntities; vector<Node*> rigsToAnimate; map<int, Sprite> spriteBuffer; PlayerModel* playerModel; GameModel* gameModel; bool firstUpdate = false; // the time the game has ended uint64 gameEndedTime = 0; public: ~GameView() { } void OnInit(); void OnMessage(Msg& msg); void LoadSprites(Setting sprites); /** Gets collection of static sprites */ spt<MultiSpriteMesh> GetStaticSprites() { return staticSprites; } /** * Gets collection of dynamic sprites (including both moving and dynamic objects) */ spt<MultiSpriteMesh> GetDynamicSprites() { return dynamicSprites; } /** * Saves map image into file (for debug purposes) */ void SaveMapImageToFile(string file); /** * Gets sprite by its frame */ Sprite& GetSprite(int frame); virtual void Update(const uint64 delta, const uint64 absolute); Node* animNode = nullptr; Node* animTextNode = nullptr; void CreateAnimationText(string message); void OnMultiplayerConnectionLost(); void OnMultiplayerReconnect(); protected: // =================== OnMessage actions ====================== void OnDynamicObjectCreated(spt<MapObjectChangedEvent> evt); void OnDynamicObjectRemoved(spt<MapObjectChangedEvent> evt); void OnStaticObjectChanged(spt<MapObjectChangedEvent> evt); void OnRigTaken(spt<MapObjectChangedEvent> evt); // =================== Update actions ========================= void UpdateMovingObjects(); void UpdateRigAnimations(); void UpdateBridgeAnimations(); void UpdatePlatformAnimations(); void UpdateActionAnimations(); };
23.54
81
0.727273
[ "vector" ]
e3b17e041dcc19a187d68a9197e9c6c7a40463f1
938
h
C
src/qc_algorithms.h
urr027/qc
11de337887efa32b36e1495f20acb11396c63ccb
[ "MIT" ]
null
null
null
src/qc_algorithms.h
urr027/qc
11de337887efa32b36e1495f20acb11396c63ccb
[ "MIT" ]
null
null
null
src/qc_algorithms.h
urr027/qc
11de337887efa32b36e1495f20acb11396c63ccb
[ "MIT" ]
null
null
null
#pragma once #include "cmatrix.h" namespace QC_Algorithms { cdouble_vector BraFromKet(const cdouble_vector & ket); cdouble TransitionAmplitude(const cdouble_vector & oldState, const cdouble_vector & newState); double ObservationProbability(const cdouble_vector & state, size_t position); cdouble_matrix HadamardMatrix(size_t order); cdouble_matrix AveragerMatrix(size_t size); cdouble_vector InverseAboutMean(const cdouble_vector & vector); cdouble_matrix FillWithBinaryVectorsInOrder(size_t n); cdouble_vector CreateQubitStateVectorAndInitializeToZero(size_t numberOfQubits); size_t Measure(const cdouble_vector & state); // returns the index of the state that got measured (random operation) std::vector<double> MeasurementProbabilitiesVector(const cdouble_vector & state); double RandomNumber(); // between 0 and 1 cint_vector PowersOfModulo(int a, int N, size_t count); // 6.5, page 206 }
36.076923
118
0.787846
[ "vector" ]
e3b1c1b9e02c841e2bf5222197636e52902d8f14
4,707
h
C
TommyGun/FrameWork/fMessage.h
tonyt73/TommyGun
2c2ffae3dcd5dc25fd64d68a9f4cc96d99a1cd36
[ "BSD-3-Clause" ]
34
2017-05-08T18:39:13.000Z
2022-02-13T05:05:33.000Z
TommyGun/FrameWork/fMessage.h
tonyt73/TommyGun
2c2ffae3dcd5dc25fd64d68a9f4cc96d99a1cd36
[ "BSD-3-Clause" ]
null
null
null
TommyGun/FrameWork/fMessage.h
tonyt73/TommyGun
2c2ffae3dcd5dc25fd64d68a9f4cc96d99a1cd36
[ "BSD-3-Clause" ]
6
2017-05-27T01:14:20.000Z
2020-01-20T14:54:30.000Z
/*--------------------------------------------------------------------------- (c) 2004 Scorpio Software 19 Wittama Drive Glenmore Park Sydney NSW 2745 Australia ----------------------------------------------------------------------------- $Workfile:: $ $Revision:: $ $Date:: $ $Author:: $ ---------------------------------------------------------------------------*/ #ifndef fMessageH #define fMessageH //-- SYSTEM ----------------------------------------------------------------- #include <stdio.h> #include <dos.h> //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <Buttons.hpp> #include <ExtCtrls.hpp> #include <Graphics.hpp> #include <ComCtrls.hpp> //#include "pngimage.hpp" //--------------------------------------------------------------------------- #include <vector> //--------------------------------------------------------------------------- typedef enum { mbbOk , mbbOkCancel, mbbYesNoCancel } ZXMessageBoxButtons; #ifndef MESSAGE_TYPES #define MESSAGE_TYPES typedef enum { mbtError, mbtWarning , mbtInformation, mbtQuestion } ZXMessageBoxType; #endif //--------------------------------------------------------------------------- __declspec (dllexport) class TfrmMessage : public TForm { __published: // IDE-managed Components TPanel *panMessageHeader; TLabel *lblMessageTitle; TLabel *lblShortMessage; TBevel *bvlMessageTop; TImage *imgError; TImage *imgWarning; TImage *imgQuestion; TImage *imgInformation; TLabel *lblLongMessage; TBevel *bvlMessageBottom; TButton *cmdButton1; TButton *cmdButton2; TButton *cmdButton3; TButton *cmdHelp; TPanel *Panel10; TPanel *Panel11; TPanel *Panel12; TPanel *Panel13; TImage *imgMessageIcon; void __fastcall cmdButton1Click(TObject *Sender); private: // User declarations int m_iResponse; int m_iNextMessageID; void __fastcall CheckButton(TButton* Button); public: // User declarations int __fastcall Show(unsigned int Type, const AnsiString& Title, const AnsiString& ShortMsg, const AnsiString& LongMsg, const AnsiString& Button1, const AnsiString& Button2, const AnsiString& Button3); void __fastcall Remove(unsigned int MessageID); void __fastcall ShowException( const AnsiString& OwnerOfException, const AnsiString& Vendor, DWORD AddressBase, DWORD Address, const AnsiString& Message, bool bIsAPlugin = true ); void __fastcall ShowException( const AnsiString& ExceptionMessage, const String& File, const String& Function, int Line); void __fastcall ShowWindowsMessage( const AnsiString& Title, const DWORD ErrorCode, const String& File, const String& Function, int Line); void __fastcall ShowGeneralMessage( const AnsiString& Title, const AnsiString& Problem, const String& File, const String& Function, int Line); int __fastcall Post(unsigned int MessageID); __fastcall TfrmMessage(TComponent* Owner); __fastcall ~TfrmMessage(); }; //--------------------------------------------------------------------------- //extern PACKAGE TfrmMessage *frmMessage; //--------------------------------------------------------------------------- #endif
38.581967
88
0.397281
[ "vector" ]
e3b2335dd42d420c8fecc2fc65d95814d43e8414
1,059
h
C
src/pack/force_packer.h
crystal-md/Crystal-MD
d43e7ed52fc5cc0f65b7d91918e313eba0f2f919
[ "BSD-3-Clause" ]
6
2020-12-17T02:17:45.000Z
2022-03-23T12:25:33.000Z
src/pack/force_packer.h
crystal-md/Crystal-MD
d43e7ed52fc5cc0f65b7d91918e313eba0f2f919
[ "BSD-3-Clause" ]
1
2021-05-05T13:54:29.000Z
2021-05-05T13:54:29.000Z
src/pack/force_packer.h
crystal-md/Crystal-MD
d43e7ed52fc5cc0f65b7d91918e313eba0f2f919
[ "BSD-3-Clause" ]
5
2020-11-03T03:40:24.000Z
2022-03-23T12:25:34.000Z
// // Created by genshen on 2019-03-16. // #ifndef MISA_MD_FORCE_PACKER_H #define MISA_MD_FORCE_PACKER_H #include <vector> #include <mpi.h> #include <comm/packer.h> #include "atom/atom_list.h" /** * @brief force data packer for communicating with neighbour processes. */ class ForcePacker : public comm::Packer<double> { public: ForcePacker(AtomList &atom_list, std::vector<std::vector<_type_atom_id>> &send_list, std::vector<std::vector<_type_atom_id>> &receive_list); const unsigned long sendLength(const int dimension, const int direction) override; void onSend(double buffer[], const unsigned long send_len, const int dimension, const int direction) override; void onReceive(double buffer[], const unsigned long receive_len, const int dimension, const int direction) override; private: AtomList &atom_list; std::vector<std::vector<_type_atom_id>> &send_list; std::vector<std::vector<_type_atom_id>> &receive_list; }; #endif //MISA_MD_FORCE_PACKER_H
27.868421
86
0.703494
[ "vector" ]
e3c67a93f9423700e784ecb6a23023fb60b4af5a
737
h
C
Tangram/Fork/View/ITangramRootView.h
ljunb/Tangram-iOS
98cfe53a6295a119638b65f61444654f2a9a66f8
[ "MIT" ]
null
null
null
Tangram/Fork/View/ITangramRootView.h
ljunb/Tangram-iOS
98cfe53a6295a119638b65f61444654f2a9a66f8
[ "MIT" ]
null
null
null
Tangram/Fork/View/ITangramRootView.h
ljunb/Tangram-iOS
98cfe53a6295a119638b65f61444654f2a9a66f8
[ "MIT" ]
null
null
null
// // XTangramBaseView.h // Tangram // // Created by linjunbing on 2021/7/29. // #import "TangramView.h" #import "ITangramViewLoadProtocol.h" @class TangramDefaultItemModel; @class ITangramRootView; NS_ASSUME_NONNULL_BEGIN @protocol ITangramViewHostProtocol <NSObject> /// 完成首屏渲染内容获取 /// /// @param tangramView 页面绑定的tangramView实例 /// @param data 首屏渲染内容数组 - (void)tangramView:(ITangramRootView *)tangramView didLoadFirstRenderData:(NSArray *)data; @end @interface ITangramRootView : TangramView /// 数据加载相关代理 @property (nonatomic, weak) id<ITangramViewLoadProtocol> loadDelegate; /// TangramView宿主对象 @property (nonatomic, weak) id<ITangramViewHostProtocol> hostInstance; /// 首屏渲染方法 - (void)render; @end NS_ASSUME_NONNULL_END
18.897436
91
0.772049
[ "render" ]
e3c926f400305b65625180461bff115447f75b0f
7,485
c
C
sig2img.c
sansculotte/sig2img
2dd08cacd49d188259c354473ca2e2f7233ddd1b
[ "BSD-2-Clause" ]
1
2020-03-05T19:25:32.000Z
2020-03-05T19:25:32.000Z
sig2img.c
sansculotte/sig2img
2dd08cacd49d188259c354473ca2e2f7233ddd1b
[ "BSD-2-Clause" ]
null
null
null
sig2img.c
sansculotte/sig2img
2dd08cacd49d188259c354473ca2e2f7233ddd1b
[ "BSD-2-Clause" ]
1
2018-02-12T15:42:30.000Z
2018-02-12T15:42:30.000Z
// vim: softtabstop=4 :shiftwidth=4 :expandtab /******************************************************************************* * * sig2img * write an audiobuffer as a sequence of image files * can be usefull for an audio-based texture in a 3D * application. * 062011 u@sansculotte.net * * todo: * - pixelbuffer > audiobuffer: shift * - audiobuffer > pixelbuffer: squeeze? truncate? * - option to seperate channels * - distort an input image with soundbuffer * - float fps * - test compile and run on different systems */ #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <sndfile.h> #include <png.h> #include <math.h> #include <unistd.h> #include <string.h> #define MINFPS 1 #define MAXFPS 1024 #define MAXWIDTH 8196 #define MAXHEIGHT 8196 #define MINWIDTH 1 #define MINHEIGHT 1 #define MINBUFSIZE 64 #define MAXBUFSIZE 2^32 #define BYTES_PER_PIXEL 1 typedef struct { uint16_t width; uint16_t height; uint32_t audio_frames; uint16_t channels; uint16_t bit_depth; } s_dimension; char const *audio_path; char output_dir[256] = ""; static void frame_loop(size_t frame, SNDFILE* audio_file, s_dimension d); static void set_filename(char* file_name, const char* dir, size_t index); static int min(int val1, int val2); /** * entry point */ int main (int argc, char *argv[]) { uint16_t width, height, fps = 25, bit_depth = 8; uint32_t audio_buffer_size, pixel_buffer_size; size_t audio_frames, video_frames; SNDFILE *audio_file; SF_INFO info; if (argc<5) { printf("Usage: %s <audio file> <width> <height> <fps> [<ouput dir>]\n", argv[0]); return(EXIT_FAILURE); } audio_path = argv[1]; if (argc>=6) { if (strlen(argv[5]) > 255) { puts("output_dir too long\n"); return(EXIT_FAILURE); } strcpy(output_dir, argv[5]); if(access(output_dir, W_OK) != 0) { printf("output_dir '%s' is not accessible\n", output_dir); return(EXIT_FAILURE); } printf("strlen(output_dir) = %lu", strlen(output_dir)); } if (argc>=4) { fps = atoi(argv[4]); } width = atoi(argv[2]); height = atoi(argv[3]); if (width<MINWIDTH || width>MAXWIDTH || height<MINHEIGHT || height>MAXHEIGHT) { printf("width must be beetween %d and %d, height between %d %d\n", MINWIDTH, MAXWIDTH, MINHEIGHT, MAXHEIGHT); return(EXIT_FAILURE); } if (fps<MINFPS || fps>MAXFPS) { printf("frames per second must be between %d and %d\n", MINFPS, MAXFPS ); return(EXIT_FAILURE); } memset(&info, 0, sizeof(info)); // open soundfile audio_file = sf_open(audio_path, SFM_READ, &info); if (audio_file == NULL) { printf("failed to open file '%s' : \n%s\n", audio_path, sf_strerror (NULL)); return(EXIT_FAILURE); } if (info.channels < 1) { puts("no audio channels."); return(EXIT_FAILURE); } // allocate buffer audio_frames = floor(info.samplerate / fps); audio_buffer_size = info.channels * audio_frames; pixel_buffer_size = width * height * BYTES_PER_PIXEL; if (audio_buffer_size > pixel_buffer_size) { printf( "audiobuffer (%d) greater than pixel buffer (%d). can't handle this atm.\n", audio_buffer_size, pixel_buffer_size ); printf("samplerate: %d, channels: %d\n", info.samplerate, info.channels); return(EXIT_FAILURE); } video_frames = ceil(fps * info.frames / (int) info.samplerate); //printf("frames: %lu\n", info.frames); //printf("video_frames: %u, audioframes: %u, samplerate: %u\n", v_frames, info.frames, (int) info.samplerate); if (video_frames < 1) { puts("not enough samples for a video frame"); return(EXIT_FAILURE); } s_dimension dimension = { width, height, audio_frames, (short)info.channels, bit_depth }; for (size_t frame=0; frame<video_frames; frame++) { frame_loop(frame, audio_file, dimension); } sf_close(audio_file); return(EXIT_SUCCESS); } /* * write audio block to png file */ void frame_loop(size_t frame, SNDFILE* audio_file, s_dimension d) { size_t x, y; size_t area = d.width * d.height; size_t wsec = ceil(d.width / d.channels); sf_count_t req, cnt; sf_count_t copy_frames = ceil(area / d.channels); png_uint_32 i; png_infop info_ptr; png_structp png_ptr; png_color_8 sig_bit; png_byte pixelbuffer[d.height][d.width * BYTES_PER_PIXEL]; png_bytep row_pointers[d.height]; short int audiobuffer[d.channels * area]; char file_name[268] = ""; set_filename(file_name, output_dir, frame); FILE *fp = fopen(file_name, "wb"); if (!fp) { exit(EXIT_FAILURE); } printf("%s\n", file_name); // clear pixelbuffer memset(&pixelbuffer, 0, area * BYTES_PER_PIXEL); // assign row pointers for (i = 0; i < d.height; i++) { row_pointers[i] = &(pixelbuffer[i][0]); } req = (size_t)sf_seek(audio_file, d.audio_frames * frame, SEEK_SET); if (req == -1) { puts("[!] audiofile seek error"); // skip frame return; } cnt = sf_readf_short(audio_file, audiobuffer, copy_frames); // more pixel than audioframes? => scroll if (area * BYTES_PER_PIXEL > d.audio_frames) { puts("pixelbuffer scroll not implemented"); } // copy block from audiobuffer to pixelbuffer for (x=0; x<cnt; x++) { //pixelbuffer[ (int) floor(x / width) ][x % width] = (char) audiobuffer[x * channels]; for(y=0; y<d.channels; y++) { size_t ix = min(floor(x / wsec), d.height-1); size_t iy = x % wsec + y * wsec; pixelbuffer[ix][iy] = abs(audiobuffer[x * d.channels + y] / 128); //printf("%lu ", (audiobuffer[x * channels + y] + sizeof(short int)) / 2); //printf("%i ", abs((audiobuffer[x * channels + y]) / 128)); } //printf("\n"); } // generate png from pixelbuffer png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { fclose(fp); exit(EXIT_FAILURE); } info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_write_struct(&png_ptr, NULL); fclose(fp); exit(EXIT_FAILURE); } if (setjmp(png_jmpbuf(png_ptr))) { puts("png error"); png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); exit(EXIT_FAILURE); } // write png png_init_io(png_ptr, fp); png_set_IHDR( png_ptr, info_ptr, d.width, d.height, d.bit_depth, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT ); sig_bit.gray = d.bit_depth; png_set_sBIT(png_ptr, info_ptr, &sig_bit); png_write_info(png_ptr, info_ptr); png_write_image(png_ptr, row_pointers); png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); } int min(int val1, int val2) { return val2 > val1 ? val1 : val2; } void set_filename(char* file_name, const char* dir, size_t index) { size_t num = index + 1; if(strlen(dir) == 0) { sprintf(file_name, "f%06lu.png", num); } else if (strcmp(dir, "/") == 0) { sprintf(file_name, "/f%06lu.png", num); } else { sprintf(file_name, "%s/f%06lu.png", dir, num); } }
25.989583
115
0.613894
[ "3d" ]
e3c9a532519c0c74e0a7969f26ad84be090e41be
2,214
h
C
resources/home/dnanexus/root/include/TDrawFeedback.h
edawson/parliament2
2632aa3484ef64c9539c4885026b705b737f6d1e
[ "Apache-2.0" ]
null
null
null
resources/home/dnanexus/root/include/TDrawFeedback.h
edawson/parliament2
2632aa3484ef64c9539c4885026b705b737f6d1e
[ "Apache-2.0" ]
null
null
null
resources/home/dnanexus/root/include/TDrawFeedback.h
edawson/parliament2
2632aa3484ef64c9539c4885026b705b737f6d1e
[ "Apache-2.0" ]
1
2020-05-28T23:01:44.000Z
2020-05-28T23:01:44.000Z
// @(#)root/proofplayer:$Id$ // Author: Maarten Ballintijn 28/10/2003 /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_TDrawFeedback #define ROOT_TDrawFeedback ////////////////////////////////////////////////////////////////////////// // // // TDrawFeedback // // // // Utility class to draw objects in the feedback list during queries. // // Draws histograms in separated canvases and user-defined objects via // // Draw(). Users requiring advanced treatment should implement their // // own version following this example. See also TStatsFeedback. // // // ////////////////////////////////////////////////////////////////////////// #include "TQObject.h" #include "TObject.h" class TProof; class TProof; class THashList; class TSeqCollection; class TDrawFeedback : public TObject, public TQObject { private: TString fName; // Identfier for this object Bool_t fAll; //draw all or selected objects THashList *fNames; //selected objects protected: Option_t *fOption; //draw option TProof *fProof; //handle to PROOF session public: TDrawFeedback(TProof *proof = 0, TSeqCollection *names = 0); ~TDrawFeedback(); void Feedback(TList *objs); const char *GetName() const { return fName.Data(); } ULong_t Hash() const { return fName.Hash(); } void SetOption(Option_t *option) { fOption = option; } ClassDef(TDrawFeedback,0) // Present PROOF query feedback }; #endif
38.172414
75
0.459801
[ "object" ]
e3cdea4a2db864bc48d18f2f3ff1ba888a51cc50
3,156
h
C
src/born_again_dp/FSpace.h
vidalt/BA-Trees
39cd89130d7d950791fc6b1ae802debadd91a300
[ "MIT" ]
45
2020-07-12T12:55:15.000Z
2022-03-23T12:31:11.000Z
src/born_again_dp/FSpace.h
gassantos/BA-Trees
39cd89130d7d950791fc6b1ae802debadd91a300
[ "MIT" ]
2
2021-02-25T02:48:17.000Z
2021-07-23T16:58:12.000Z
src/born_again_dp/FSpace.h
gassantos/BA-Trees
39cd89130d7d950791fc6b1ae802debadd91a300
[ "MIT" ]
2
2020-11-05T19:44:57.000Z
2020-12-21T21:02:51.000Z
/*MIT License Copyright(c) 2020 Thibaut Vidal Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #ifndef FSPACE_H #define FSPACE_H #include "Params.h" #include "RandomForest.h" class FSpace { public: Params * params; // Access to the problem and dataset parameters RandomForest * randomForest; // Access to the random forest serving as input std::vector<std::vector<double>> orderedHyperplaneLevels; // Lists all hyperplane levels std::vector<int> codeBook; // Codebook used to convert cells into indices std::vector<int> cells; // Class of each cell. Indexed based on the codeBook long int nbCells; // Number of cells double nbPossibleRegions; // Bound on the number of possible DP states // Auxiliary variables for some recursive functions std::vector<double> myCellValues; bool detectedDifference; int hypFeature, hypLevel; // Converts a cell to its associated hash code int cellToKey(const std::vector<int> & myCell); // Gets the kth value of the cell for a given hash code int keyToCell(int key, int k); // Generates the hash code for a region (useful for perfect hashing) int keyToHash(int keyBottomLeft, int keyTopRight); // Evaluates the majority class for each cell void enumerateCellsRecursion(int k, int myCellIndex); // Helper function to filter unnecessary hyperplanes void hyperplaneFilteringRecursion(int k, int myCellIndex); // Initializes the cells based on a list of hyperplanes void initializeCells(const std::vector<std::vector<double>> & hyperplanes, bool isFiltered); // Exports only the useful hyperplanes std::vector<std::vector<double>> exportUsefulHyperplanes(); // Constructor FSpace(Params * params, RandomForest * randomForest) : params(params), randomForest(randomForest) { orderedHyperplaneLevels = std::vector<std::vector<double>>(params->nbFeatures); codeBook = std::vector<int>(params->nbFeatures, 1); myCellValues = std::vector<double>(params->nbFeatures); } }; #endif
41.526316
114
0.719265
[ "vector" ]
e3d2c2368e062998d5819225eb32016398e9e531
546
h
C
src/graphics/vulkan/vulkanswapchain.h
Xienex/Solis
0648b036c167e00c53b06e5c316ac25921a6395d
[ "BSD-3-Clause" ]
null
null
null
src/graphics/vulkan/vulkanswapchain.h
Xienex/Solis
0648b036c167e00c53b06e5c316ac25921a6395d
[ "BSD-3-Clause" ]
null
null
null
src/graphics/vulkan/vulkanswapchain.h
Xienex/Solis
0648b036c167e00c53b06e5c316ac25921a6395d
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include "vulkancontext.h" #include "vulkandevice.h" #include "solisdevice.h" class VulkanSwapchain { public: VulkanSwapchain(SolisDevice *, std::shared_ptr<VulkanContext>, std::shared_ptr<VulkanDevice>); ~VulkanSwapchain(); std::shared_ptr<VulkanContext> context; std::shared_ptr<VulkanDevice> device; std::shared_ptr<VkSurfaceKHR> surface; VkSwapchainKHR swapchain; std::vector<VkImage> images; std::vector<VkImageView> imageViews; VkFormat imageFormat; VkExtent2D dimensions; };
27.3
96
0.728938
[ "vector" ]
e3e3b926a7a24917d568810bb1933a46fed17f59
1,674
h
C
aws-cpp-sdk-amplifyuibuilder/include/aws/amplifyuibuilder/model/GetThemeResult.h
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2021-12-06T20:36:35.000Z
2021-12-06T20:36:35.000Z
aws-cpp-sdk-amplifyuibuilder/include/aws/amplifyuibuilder/model/GetThemeResult.h
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-amplifyuibuilder/include/aws/amplifyuibuilder/model/GetThemeResult.h
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2021-12-30T04:25:33.000Z
2021-12-30T04:25:33.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/amplifyuibuilder/AmplifyUIBuilder_EXPORTS.h> #include <aws/amplifyuibuilder/model/Theme.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace AmplifyUIBuilder { namespace Model { class AWS_AMPLIFYUIBUILDER_API GetThemeResult { public: GetThemeResult(); GetThemeResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); GetThemeResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>Represents the configuration settings for the theme.</p> */ inline const Theme& GetTheme() const{ return m_theme; } /** * <p>Represents the configuration settings for the theme.</p> */ inline void SetTheme(const Theme& value) { m_theme = value; } /** * <p>Represents the configuration settings for the theme.</p> */ inline void SetTheme(Theme&& value) { m_theme = std::move(value); } /** * <p>Represents the configuration settings for the theme.</p> */ inline GetThemeResult& WithTheme(const Theme& value) { SetTheme(value); return *this;} /** * <p>Represents the configuration settings for the theme.</p> */ inline GetThemeResult& WithTheme(Theme&& value) { SetTheme(std::move(value)); return *this;} private: Theme m_theme; }; } // namespace Model } // namespace AmplifyUIBuilder } // namespace Aws
24.617647
102
0.689964
[ "model" ]
e3e58c7f0abfaa9f4c65bd96972b84660b44eee0
953
h
C
include/Ess3D/core/IGame.h
essar05/Ess3D
0c3c648bf4d6b92d47c1acf1d51eca592ffe7e95
[ "MIT" ]
2
2019-05-28T12:00:00.000Z
2020-09-03T11:51:50.000Z
include/Ess3D/core/IGame.h
essar05/Ess3D
0c3c648bf4d6b92d47c1acf1d51eca592ffe7e95
[ "MIT" ]
null
null
null
include/Ess3D/core/IGame.h
essar05/Ess3D
0c3c648bf4d6b92d47c1acf1d51eca592ffe7e95
[ "MIT" ]
1
2019-05-28T12:00:08.000Z
2019-05-28T12:00:08.000Z
#pragma once #include <Ess3D/definitions.h> #include <Ess3D/core/ScreenManager.h> #include <Ess3D/gl/Window.h> #include <Ess3D/utils/Timing.h> #include <Ess3D/input/InputManager.h> #include <Ess3D/core/Config.h> #include <Ess3D/core/State.h> namespace Ess3D { class API IGame { public: virtual ~IGame(); virtual void boot(); virtual void destroy(); virtual void run(); virtual void addScreens() = 0; virtual void onInit() = 0; virtual void onExit() = 0; void onSDLEvent(SDL_Event& event); protected: IGame(); void update(float deltaTime, int simulationSteps); void render(); virtual void onUpdate() {} bool init(); bool initSystems(); std::shared_ptr<ScreenManager> _screenManager; IGameScreen* _currentScreen = nullptr; State* _state{}; Config* _config{}; private: void processInput(IGameScreen* screen); }; }
20.276596
56
0.635887
[ "render" ]
e3e638f10ea7d1d4f486b441a01ee731ecb2db8e
2,050
h
C
lib/fields/extended/stl/cjson_std_map_field.h
bouviervj/cjson
abc96451f02f1b6fc7dfa0b21cd459593c0b9e1e
[ "Apache-2.0" ]
4
2015-10-28T17:12:43.000Z
2018-09-11T14:45:11.000Z
lib/fields/extended/stl/cjson_std_map_field.h
bouviervj/cjson
abc96451f02f1b6fc7dfa0b21cd459593c0b9e1e
[ "Apache-2.0" ]
null
null
null
lib/fields/extended/stl/cjson_std_map_field.h
bouviervj/cjson
abc96451f02f1b6fc7dfa0b21cd459593c0b9e1e
[ "Apache-2.0" ]
2
2016-10-21T12:36:56.000Z
2020-08-13T11:07:27.000Z
/* * Copyright 2013 BOUVIER-VOLAILLE Julien * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _CJSON_STD_MAP_FIELD_H_ #define _CJSON_STD_MAP_FIELD_H_ #include <string> #include "../cjson_extended_field.h" namespace cjson { namespace field { class std_map_field : public extended_field { public: std_map_field(const std::string& iName, cjson::dictionary* iDict) : extended_field(iName,iDict) { _init = false; } virtual ~std_map_field(){}; unsigned long getAlignedSize(unsigned long iSize); void decodeKeyValuePair(std::ostringstream& iStream, std::_Rb_tree_node_base* aNode, field* iFirst, field* iSecond); void readRedBlackTree(std::vector<std::string>& iElementsList , std::_Rb_tree_node_base* iNode, field* iFirst, field* iSecond); void copyNode(std::_Rb_tree_node<std::pair<field_value, jsonxx::Value> >* iNodeToCopy, field* iSecond, void* iParent, void*& ioPointer, void*& iFirst, void*& iLast); virtual void toJson(std::ostringstream& iStream, const void* iEntryPoint); virtual void toJsonMap(std::ostringstream& iStream, const void* iEntryPoint); virtual void* fromJson(const std::string& iJson); virtual void fromJson(const jsonxx::Value& iJson, void* iEntryPoint); virtual void fromJsonMap(const jsonxx::Value& iJson, void* iEntryPoint); virtual void toCpp(std::ostringstream& iStream); private: bool _init; field* _first; field* _second; void init(); public : ADD_FIELD_TYPE_FACTORY(cjson::field::std_map_field) }; }} #endif
28.472222
168
0.733171
[ "vector" ]
e3fbacdecf8aba6c3a55df66b2d151288227d6d4
2,376
h
C
src/torque/csa-generator.h
RiyoCoder/v8
e073edfc7dc990cc5f71c4e51ac27b19be16fcb7
[ "BSD-3-Clause" ]
2
2020-08-27T09:36:44.000Z
2020-09-23T14:01:12.000Z
src/torque/csa-generator.h
RiyoCoder/v8
e073edfc7dc990cc5f71c4e51ac27b19be16fcb7
[ "BSD-3-Clause" ]
null
null
null
src/torque/csa-generator.h
RiyoCoder/v8
e073edfc7dc990cc5f71c4e51ac27b19be16fcb7
[ "BSD-3-Clause" ]
3
2019-03-11T14:35:18.000Z
2021-07-01T07:51:00.000Z
// Copyright 2018 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_TORQUE_CSA_GENERATOR_H_ #define V8_TORQUE_CSA_GENERATOR_H_ #include <iostream> #include "src/torque/cfg.h" #include "src/torque/declarable.h" namespace v8 { namespace internal { namespace torque { class CSAGenerator { public: CSAGenerator(const ControlFlowGraph& cfg, std::ostream& out, base::Optional<Builtin::Kind> linkage = base::nullopt) : cfg_(cfg), out_(out), linkage_(linkage) {} base::Optional<Stack<std::string>> EmitGraph(Stack<std::string> parameters); static constexpr const char* ARGUMENTS_VARIABLE_STRING = "arguments"; static void EmitCSAValue(VisitResult result, const Stack<std::string>& values, std::ostream& out); private: const ControlFlowGraph& cfg_; std::ostream& out_; size_t fresh_id_ = 0; base::Optional<Builtin::Kind> linkage_; std::string PreCallableExceptionPreparation( base::Optional<Block*> catch_block); void PostCallableExceptionPreparation(const std::string& catch_name, const Type* return_type, base::Optional<Block*> catch_block, Stack<std::string>* stack); std::string FreshNodeName() { return "tmp" + std::to_string(fresh_id_++); } std::string FreshCatchName() { return "catch" + std::to_string(fresh_id_++); } std::string BlockName(const Block* block) { return "block" + std::to_string(block->id()); } void ProcessArgumentsCommon(const TypeVector& parameter_types, std::vector<std::string>* args, std::vector<std::string>* constexpr_arguments, Stack<std::string>* stack); Stack<std::string> EmitBlock(const Block* block); void EmitInstruction(const Instruction& instruction, Stack<std::string>* stack); #define EMIT_INSTRUCTION_DECLARATION(T) \ void EmitInstruction(const T& instruction, Stack<std::string>* stack); TORQUE_INSTRUCTION_LIST(EMIT_INSTRUCTION_DECLARATION) #undef EMIT_INSTRUCTION_DECLARATION }; } // namespace torque } // namespace internal } // namespace v8 #endif // V8_TORQUE_CSA_GENERATOR_H_
35.462687
80
0.662458
[ "vector" ]
541881cf18f36751e543e73cc38c86394cbe5bf1
2,072
h
C
navigation_actions/include/planner_navigation_actions/actionExecutorROSNavigationGrounding.h
GKIFreiburg/gki_pr2_symbolic_planning
28035f782e3253e76d93bbbbba3c7d8dc883ad72
[ "BSD-3-Clause" ]
null
null
null
navigation_actions/include/planner_navigation_actions/actionExecutorROSNavigationGrounding.h
GKIFreiburg/gki_pr2_symbolic_planning
28035f782e3253e76d93bbbbba3c7d8dc883ad72
[ "BSD-3-Clause" ]
null
null
null
navigation_actions/include/planner_navigation_actions/actionExecutorROSNavigationGrounding.h
GKIFreiburg/gki_pr2_symbolic_planning
28035f782e3253e76d93bbbbba3c7d8dc883ad72
[ "BSD-3-Clause" ]
null
null
null
#ifndef ACTION_EXECUTOR_R_O_S_NAVIGATION_GROUNDING_H #define ACTION_EXECUTOR_R_O_S_NAVIGATION_GROUNDING_H #include "continual_planning_executive/actionExecutorInterface.h" #include "continual_planning_executive/symbolicState.h" #include <actionlib/client/simple_action_client.h> #include <move_base_msgs/MoveBaseAction.h> #include <moveit/move_group_interface/move_group.h> #include <vector> #include <utility> namespace navigation_actions { class ActionExecutorROSNavigationGrounding : public continual_planning_executive::ActionExecutorInterface { public: /** * Parameters: * action_plan_name action_server_name * [start (<predicate> true|false)+] [goal (<predicate> true|false)+] * Ex: drive /move_base start visited true goal exploring true */ virtual void initialize(const std::deque<std::string> & arguments); virtual bool canExecute(const DurativeAction & a, const SymbolicState & currentState) const; virtual bool executeBlocking(const DurativeAction & a, SymbolicState & currentState); virtual void cancelAction(); protected: std::string action_name_; std::string action_topic_move_base_; std::string predicate_table_inspected_recently_; actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction>* action_move_base_; // also possible to use action client for lifting torso // topic: "torso_controller/position_joint_action" // actionlib::SimpleActionClient<control_msgs::SingleJointPositionAction>* action_lift_torso_; // using move group instead of normal action server because move group also checks for collisions moveit::planning_interface::MoveGroup* torso_group_; bool executeMoveBase(const geometry_msgs::PoseStamped& target_pose); bool executeLiftTorso(const geometry_msgs::PoseStamped& target_pose); }; }; #endif // ACTION_EXECUTOR_R_O_S_NAVIGATION_GROUNDING_H
37
109
0.718147
[ "vector" ]
5418ba8684b13bbb8e006d064b99de3eff68d3ed
1,463
h
C
ComplexAttractor.h
lkesteloot/ifs
a82846339f2ba90faf78791523dfca102ec5f7a1
[ "Apache-2.0" ]
1
2019-07-25T16:26:19.000Z
2019-07-25T16:26:19.000Z
ComplexAttractor.h
lkesteloot/ifs
a82846339f2ba90faf78791523dfca102ec5f7a1
[ "Apache-2.0" ]
null
null
null
ComplexAttractor.h
lkesteloot/ifs
a82846339f2ba90faf78791523dfca102ec5f7a1
[ "Apache-2.0" ]
null
null
null
#ifndef COMPLEX_ATTRACTOR_H #define COMPLEX_ATTRACTOR_H #include "Attractor.h" /** * Attractor that treats the point like a complex number (with X the real value * and Y the imaginary value). The constructor takes two values, S and A. * The transform brings the point a fraction of the way to A. If S is (0,0), * the point is moved to A. If it's (1,0), it stays where it is. */ class ComplexAttractor : public Attractor { double mSr; double mSi; double mAr; double mAi; public: ComplexAttractor(double sr, double si, double ar, double ai) : mSr(sr), mSi(si), mAr(ar), mAi(ai) { // Nothing. } ComplexAttractor(std::istream &is) { is >> mSr >> mSi >> mAr >> mAi; } virtual void transform(double &x, double &y) const { // P' = S*P + (1 - S)*A // = S*P + A - S*A // = S*(P - A) + A double new_x = multReal(mSr, mSi, x, y) + multReal(1 - mSr, mSi, mAr, mAi); double new_y = multImg(mSr, mSi, x, y) + multImg(1 - mSr, mSi, mAr, mAi); x = new_x; y = new_y; } private: /** * Real part of complex product. */ static double multReal(double ar, double ai, double br, double bi) { return ar*br - ai*bi; } /** * Imaginary part of complex product. */ static double multImg(double ar, double ai, double br, double bi) { return ar*bi + ai*br; } }; #endif // COMPLEX_ATTRACTOR_H
25.666667
83
0.578947
[ "transform" ]
542265c73eb0351f11637dca1964d5729d7dab42
758
h
C
src/main/cpp/weismarts/zmq/ZMsg.h
match08/zmq-android
d13c2277ec76cb6fef3cf23fa9572d9dc24a4d16
[ "MIT" ]
null
null
null
src/main/cpp/weismarts/zmq/ZMsg.h
match08/zmq-android
d13c2277ec76cb6fef3cf23fa9572d9dc24a4d16
[ "MIT" ]
null
null
null
src/main/cpp/weismarts/zmq/ZMsg.h
match08/zmq-android
d13c2277ec76cb6fef3cf23fa9572d9dc24a4d16
[ "MIT" ]
null
null
null
// // Created by weismarts on 9/26/21. // #ifndef ZMQLIBRARY_ZMSG_H #define ZMQLIBRARY_ZMSG_H #include <string> #include <cppzmq/zmq.hpp> #include <cppzmq/zmq_addon.hpp> #include <weismarts/zmq/ZMQSocket.h> class ZMsg { public: ZMsg(); void Add(char* msg); void Add(void* msg, size_t len); void Add(zmq::message_t &msg); void Add(std::string msg); void AddAll(std::vector<std::string> msgs); void Destroy(); bool Send(ZMQSocket *socket, int flags=0); size_t Size(); std::string Peekstr(size_t index); std::string Str(); void *AtData(size_t n); static ZMsg RecvMsg(ZMQSocket *socket, bool wait= false); private: zmq::multipart_t _multipart; size_t _size; }; #endif //ZMQLIBRARY_ZMSG_H
17.227273
61
0.664908
[ "vector" ]
54241fd4db3b613b1c7577fb6a684ca4fef4c9a1
1,188
h
C
Code/GraphMol/Basement/FeatTrees/FeatTreeUtils.h
docking-org/rdk
6eb710254f027b348a8e3089e6a92c3d40de0949
[ "PostgreSQL" ]
null
null
null
Code/GraphMol/Basement/FeatTrees/FeatTreeUtils.h
docking-org/rdk
6eb710254f027b348a8e3089e6a92c3d40de0949
[ "PostgreSQL" ]
null
null
null
Code/GraphMol/Basement/FeatTrees/FeatTreeUtils.h
docking-org/rdk
6eb710254f027b348a8e3089e6a92c3d40de0949
[ "PostgreSQL" ]
2
2017-12-04T02:28:18.000Z
2018-11-29T01:18:46.000Z
// // Copyright (C) 2005-2006 Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. // The contents are covered by the terms of the BSD license // which is included in the file license.txt, found at the root // of the RDKit source tree. // /*! \file FeatTreeUtils.h \brief No user-serviceable parts inside This functionality is used in the construction of feature trees from molecules. It's exposed here so that it can be tested. */ #ifndef _RD_FEATTREEUTILS_H_ #define _RD_FEATTREEUTILS_H_ #include "FeatTree.h" #include <vector> namespace RDKit { typedef std::vector<int> INT_VECT; class ROMol; namespace FeatTrees { void addRingsAndConnectors(const ROMol &mol, FeatTreeGraph &featGraph); void addRingRingBonds(const ROMol &mol, FeatTreeGraph &featGraph); std::vector<unsigned int> addNonringAtoms(const ROMol &mol, FeatTreeGraph &featGraph); void addBondsFromNonringAtoms(const ROMol &mol, FeatTreeGraph &featGraph, std::vector<unsigned int> &atomIndices); void addZeroNodes(FeatTreeGraph &featGraph); void replaceCycles(FeatTreeGraph &featGraph); } } #endif
30.461538
73
0.719697
[ "vector" ]
5428dbcfee698d5446a6aa88dbc1294e3237fd4f
2,479
h
C
testbed/x/mobilesdk/osx/5.5.1.GA/android/native/include/org_appcelerator_kroll_runtime_v8_V8Object.h
appcelerator-forks/BranchMetrics.titanium-branch-deep-linking
723b0a6ddb0e010a41223bb7b0e611847c717ea3
[ "MIT" ]
null
null
null
testbed/x/mobilesdk/osx/5.5.1.GA/android/native/include/org_appcelerator_kroll_runtime_v8_V8Object.h
appcelerator-forks/BranchMetrics.titanium-branch-deep-linking
723b0a6ddb0e010a41223bb7b0e611847c717ea3
[ "MIT" ]
null
null
null
testbed/x/mobilesdk/osx/5.5.1.GA/android/native/include/org_appcelerator_kroll_runtime_v8_V8Object.h
appcelerator-forks/BranchMetrics.titanium-branch-deep-linking
723b0a6ddb0e010a41223bb7b0e611847c717ea3
[ "MIT" ]
null
null
null
/* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class org_appcelerator_kroll_runtime_v8_V8Object */ #ifndef _Included_org_appcelerator_kroll_runtime_v8_V8Object #define _Included_org_appcelerator_kroll_runtime_v8_V8Object #ifdef __cplusplus extern "C" { #endif #undef org_appcelerator_kroll_runtime_v8_V8Object_MSG_RELEASE #define org_appcelerator_kroll_runtime_v8_V8Object_MSG_RELEASE 100L #undef org_appcelerator_kroll_runtime_v8_V8Object_MSG_SET_WINDOW #define org_appcelerator_kroll_runtime_v8_V8Object_MSG_SET_WINDOW 101L #undef org_appcelerator_kroll_runtime_v8_V8Object_MSG_LAST_ID #define org_appcelerator_kroll_runtime_v8_V8Object_MSG_LAST_ID 101L /* * Class: org_appcelerator_kroll_runtime_v8_V8Object * Method: nativeInitObject * Signature: (Ljava/lang/Class;Ljava/lang/Object;)V */ JNIEXPORT void JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeInitObject (JNIEnv *, jclass, jclass, jobject); /* * Class: org_appcelerator_kroll_runtime_v8_V8Object * Method: nativeCallProperty * Signature: (JLjava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeCallProperty (JNIEnv *, jclass, jlong, jstring, jobjectArray); /* * Class: org_appcelerator_kroll_runtime_v8_V8Object * Method: nativeRelease * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeRelease (JNIEnv *, jclass, jlong); /* * Class: org_appcelerator_kroll_runtime_v8_V8Object * Method: nativeSetProperty * Signature: (JLjava/lang/String;Ljava/lang/Object;)V */ JNIEXPORT void JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeSetProperty (JNIEnv *, jobject, jlong, jstring, jobject); /* * Class: org_appcelerator_kroll_runtime_v8_V8Object * Method: nativeFireEvent * Signature: (JLjava/lang/Object;JLjava/lang/String;Ljava/lang/Object;ZZILjava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeFireEvent (JNIEnv *, jobject, jlong, jobject, jlong, jstring, jobject, jboolean, jboolean, jint, jstring); /* * Class: org_appcelerator_kroll_runtime_v8_V8Object * Method: nativeSetWindow * Signature: (JLjava/lang/Object;)V */ JNIEXPORT void JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeSetWindow (JNIEnv *, jobject, jlong, jobject); #ifdef __cplusplus } #endif #endif
36.455882
98
0.817668
[ "object" ]
542f50beaa4fca128009df99dfcd7b5180aaa00f
600
h
C
image.h
slavik81/ray
a62ae969d4efcb3b08d7c7890cdb595360d1bd5b
[ "MIT" ]
null
null
null
image.h
slavik81/ray
a62ae969d4efcb3b08d7c7890cdb595360d1bd5b
[ "MIT" ]
null
null
null
image.h
slavik81/ray
a62ae969d4efcb3b08d7c7890cdb595360d1bd5b
[ "MIT" ]
null
null
null
#ifndef IMAGE_H #define IMAGE_H #include <vector> #include "vec3f.h" struct image { image(unsigned width, unsigned height); std::vector<vec3f> pixels; vec3f& px(unsigned x, unsigned y); const vec3f& px(unsigned x, unsigned y) const; bool save_as_png(const char* path) const; void clamp_colors(); private: unsigned height() const; unsigned width() const; private: unsigned width_; }; inline vec3f& image::px(unsigned x, unsigned y) { return pixels[y * width_ + x]; } inline const vec3f& image::px(unsigned x, unsigned y) const { return pixels[y * width_ + x]; } #endif
17.142857
61
0.693333
[ "vector" ]
5430c7f767457239eaa0e633887852860d50b5d5
11,940
h
C
DIR819_v1.06/src/kernel/linux-2.6.36.x/drivers/net/eip93_drivers/quickSec/src/lib/sshutil/sshnet/sshdnspacket.h
Sirherobrine23/Dir819gpl_code
8af92d65416198755974e3247b7bbe7f1151d525
[ "BSD-2-Clause" ]
1
2022-03-19T06:38:01.000Z
2022-03-19T06:38:01.000Z
DIR819_v1.06/src/kernel/linux-2.6.36.x/drivers/net/eip93_drivers/quickSec/src/lib/sshutil/sshnet/sshdnspacket.h
Sirherobrine23/Dir819gpl_code
8af92d65416198755974e3247b7bbe7f1151d525
[ "BSD-2-Clause" ]
null
null
null
DIR819_v1.06/src/kernel/linux-2.6.36.x/drivers/net/eip93_drivers/quickSec/src/lib/sshutil/sshnet/sshdnspacket.h
Sirherobrine23/Dir819gpl_code
8af92d65416198755974e3247b7bbe7f1151d525
[ "BSD-2-Clause" ]
1
2022-03-19T06:38:03.000Z
2022-03-19T06:38:03.000Z
/* * Author: Tero Kivinen <kivinen@iki.fi> * * Copyright (c) 2004 SFNT Finland Oy. */ /* * Program: sshdns * * Creation : 15:54 Apr 6 2004 kivinen * Last Modification : 14:50 Sep 11 2006 kivinen * Version : 1.93 * * * Description : DNS packet encode and decode routines. * */ #ifndef SSHDNSPACKET_H #define SSHDNSPACKET_H /* DNS Response codes. Codes from 0-15 are defined by the DNS specification, codes starting from 65536 are internal to the DNS library. */ typedef enum { SSH_DNS_OK = 0, /* No error condition */ SSH_DNS_FORMAT_ERROR = 1, /* The name server was unable to interpret the query. */ SSH_DNS_SERVER_FAILURE = 2, /* The name server was unable to process this query due to a problem with a name server. */ SSH_DNS_NONEXISTENT_DOMAIN = 3, /* The domain name references in the query does not exist. */ SSH_DNS_UNIMPLEMENTED = 4, /* The name server does not support the requested kind of query. */ SSH_DNS_QUERY_REFUSED = 5, /* The name server refuses to perform the specified operation for policy reasons. */ SSH_DNS_YXDOMAIN = 6, /* Name exists when it should not */ SSH_DNS_YXRRSET = 7, /* RR set exists when it should not */ SSH_DNS_NXRRSET = 8, /* RR set that should exists does not */ SSH_DNS_NOTAUTH = 9, /* Server not authorative for zone */ SSH_DNS_NOTZONE = 10, /* Name not contained in zone */ /* Extended response codes. */ SSH_DNS_BADVERS = 16, /* Bad OPT Version */ SSH_DNS_BADSIG = 16, /* TSIG Signature Failure */ SSH_DNS_BADKEY = 17, /* Key not recognized */ SSH_DNS_BADTIME = 18, /* Signature out of time window */ SSH_DNS_BADMODE = 19, /* Bad TKEY Mode */ SSH_DNS_BADNAME = 20, /* Duplicate key name */ SSH_DNS_BADALG = 21, /* Algorithm not supported */ /* Internal codes. These are above 16 bit values, thus they cannot be used by extended response codes. */ SSH_DNS_MEMORY_ERROR = 65536, /* Out of memory during operation. */ SSH_DNS_TIMEOUT = 65537, /* The operation timed out. */ SSH_DNS_UNREACHABLE = 65538, /* Host is unreachable. */ SSH_DNS_REFUSED = 65539, /* The connection was refused in transport protocol level (not by dns server). */ SSH_DNS_UNABLE_TO_SEND = 65540, /* Lower layer cannot send packet now, because of some error (out of buffers, tcp stream blocked etc). */ SSH_DNS_LIMIT_REACHED = 65541, /* The operation looped and was aborted after the limit was reached. */ SSH_DNS_INTERNAL_ERROR = 65542, /* Internal error, something went wrong. */ SSH_DNS_PARSE_ERROR = 65543 /* Error parsing the reply packet from name server. */ } SshDNSResponseCode; /* Resource records type. */ typedef enum { SSH_DNS_RESOURCE_A = 1, /* Host address, rfc1035 */ SSH_DNS_RESOURCE_NS = 2, /* Authoritative server, rfc1035 */ SSH_DNS_RESOURCE_MD = 3, /* Mail destination, obs rfc1035 */ SSH_DNS_RESOURCE_MF = 4, /* Mail forwarder, obs rfc1035 */ SSH_DNS_RESOURCE_CNAME = 5, /* Canonical name, rfc1035 */ SSH_DNS_RESOURCE_SOA = 6, /* Start of authority zone, rfc1035 */ SSH_DNS_RESOURCE_MB = 7, /* Mailbox domain name, exp rfc1035 */ SSH_DNS_RESOURCE_MG = 8, /* Mail group member, exp rfc1035 */ SSH_DNS_RESOURCE_MR = 9, /* Mail rename name, exp rfc1035 */ SSH_DNS_RESOURCE_NULL = 10, /* Null resource record, exp rfc1035*/ SSH_DNS_RESOURCE_WKS = 11, /* Well known service, rfc1035 */ SSH_DNS_RESOURCE_PTR = 12, /* Domain name pointer, rfc1035 */ SSH_DNS_RESOURCE_HINFO = 13, /* Host information, rfc1035 */ SSH_DNS_RESOURCE_MINFO = 14, /* Mailbox information, rfc1035 */ SSH_DNS_RESOURCE_MX = 15, /* Mail routing information, rfc1035 */ SSH_DNS_RESOURCE_TXT = 16, /* Text strings, rfc1035 */ SSH_DNS_RESOURCE_RP = 17, /* Responsible person, rfc1183 */ SSH_DNS_RESOURCE_AFSDB = 18, /* AFS cell database, rfc1183 */ SSH_DNS_RESOURCE_X25 = 19, /* X_25, calling address, rfc1183 */ SSH_DNS_RESOURCE_ISDN = 20, /* ISDN calling address, rfc1183 */ SSH_DNS_RESOURCE_RT = 21, /* Router through, rfc1183 */ SSH_DNS_RESOURCE_NSAP = 22, /* NSAP address, rfc1706 */ SSH_DNS_RESOURCE_NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated) */ SSH_DNS_RESOURCE_SIG = 24, /* Security signature, rfc2931 */ SSH_DNS_RESOURCE_KEY = 25, /* Security key, rfc2535 */ SSH_DNS_RESOURCE_PX = 26, /* X.400, mail mapping, rfc2163 */ SSH_DNS_RESOURCE_GPOS = 27, /* Geographical position, withdrawn rfc1712 */ SSH_DNS_RESOURCE_AAAA = 28, /* IP6, Address */ SSH_DNS_RESOURCE_LOC = 29, /* Location Information */ SSH_DNS_RESOURCE_NXT = 30, /* Next Valid Name in Zone, rfc2535 */ SSH_DNS_RESOURCE_EID = 31, /* Endpoint identifier */ SSH_DNS_RESOURCE_NIMLOC = 32, /* Nimrod locator */ SSH_DNS_RESOURCE_SRV = 33, /* Server selection, rfc2782 */ SSH_DNS_RESOURCE_ATMA = 34, /* ATM Address */ SSH_DNS_RESOURCE_NAPTR = 35, /* Naming Authority PoinTeR, rfc2168, rfc2915 */ SSH_DNS_RESOURCE_KX = 36, /* Key Exchanger, rfc2230 */ SSH_DNS_RESOURCE_CERT = 37, /* Certificate, rfc2538 */ SSH_DNS_RESOURCE_A6 = 38, /* A6, rfc2874 */ SSH_DNS_RESOURCE_DNAME = 39, /* DNAME, rfc2672 */ SSH_DNS_RESOURCE_SINK = 40, /* SINK */ SSH_DNS_RESOURCE_OPT = 41, /* OPT, rfc2671 */ SSH_DNS_RESOURCE_APL = 42, /* APL, rfc3123 */ SSH_DNS_RESOURCE_DS = 43, /* Delegation Signer, rfc3658 */ SSH_DNS_RESOURCE_SSHFP = 44, /* SSH Key Fingerprint */ SSH_DNS_RESOURCE_RRSIG = 46, /* RRSIG */ SSH_DNS_RESOURCE_NSEC = 47, /* NSEC */ SSH_DNS_RESOURCE_DNSKEY = 48, /* DNSKEY */ SSH_DNS_RESOURCE_UINFO = 100, /* User (finger) information */ SSH_DNS_RESOURCE_UID = 101, /* User ID */ SSH_DNS_RESOURCE_GID = 102, /* Group ID */ SSH_DNS_RESOURCE_UNSPEC = 103, /* Unspecified format (binary data) */ /* Query typedef values which do not appear in resource records */ SSH_DNS_QUERY_TKEY = 249, /* Transaction Key, rfc2930 */ SSH_DNS_QUERY_TSIG = 250, /* Transaction Signature, rfc2845 */ SSH_DNS_QUERY_IXFR = 251, /* Incremental zone transfer, rfc1995*/ SSH_DNS_QUERY_AXFR = 252, /* Transfer zone of authority, rfc1035 */ SSH_DNS_QUERY_MAILB = 253, /* Transfer mailbox records, rfc1035 */ SSH_DNS_QUERY_MAILA = 254, /* Transfer mail agent records, rfc1035 */ SSH_DNS_QUERY_ANY = 255 /* Wildcard match, rfc1035 */ } SshDNSRRType; /* Operation codes. */ typedef enum { SSH_DNS_OPCODE_QUERY = 0, /* Normal Query */ SSH_DNS_OPCODE_STATUS = 2, /* Status */ SSH_DNS_OPCODE_NOTIFY = 4, /* Notify */ SSH_DNS_OPCODE_UPDATE = 5 /* Update */ } SshDNSOpCode; /* Protocol classes. Only INTERNET is really supported. */ typedef enum { SSH_DNS_CLASS_INTERNET = 1, SSH_DNS_CLASS_CHAOS = 3, SSH_DNS_CLASS_HESIOD = 4, SSH_DNS_CLASS_ANY = 255 } SshDNSProtocolClass; /* These values correspond directly to the DNS standard. */ #define SSH_DNS_FLAG_IS_RESPONSE 0x8000 #define SSH_DNS_FLAG_AUTHORITATIVE 0x0400 #define SSH_DNS_FLAG_TRUNCATED 0x0200 #define SSH_DNS_FLAG_RECURSION_DESIRED 0x0100 #define SSH_DNS_FLAG_RECURSION_AVAILABLE 0x0080 #define SSH_DNS_FLAG_AUTHENTIC_DATA 0x0020 #define SSH_DNS_FLAG_CHECKING_DISABLED 0x0010 #define SSH_DNS_FLAG_MASK 0x87f0 /* DNS Questions structure. */ typedef struct SshDNSQuestionRec { /* Note, that this name is in the dns-format, i.e length byte followed by the label, not as in string (dot-separated). This field is nul terminated though, as there is root label at the end (marked as 0-length label). This will never be in the compressed format, the compression is always removed before data is stored here.*/ unsigned char *qname; SshDNSRRType qtype; SshDNSProtocolClass qclass; } *SshDNSQuestion, SshDNSQuestionStruct; /* DNS Record structure. */ typedef struct SshDNSRecordRec { /* Note, that this name is in the dns-format, i.e length byte followed by the label, not as in string (dot-separated). This field is nul terminated though, as there is root label at the end (marked as 0-length label). This will never be in the compressed format, the compression is always removed before data is stored here. */ unsigned char *name; SshDNSRRType type; SshDNSProtocolClass dns_class; SshUInt32 ttl; size_t rdlength; /* Note, that data in the rdata depends on the type, and it may contains names in the dns-format. The compression of the names is decoded before data is copied here. */ unsigned char *rdata; } *SshDNSRecord, SshDNSRecordStruct; /* DNS Packet structure. */ typedef struct SshDNSPacketRec { /* Id of the packet. */ SshUInt16 id; /* Flags. This has the opcode and rcode masked out. */ SshUInt16 flags; /* Operation code for the request. Normally SSH_DNS_OPCODE_QUERY. */ SshDNSOpCode op_code; /* Response code. */ SshDNSResponseCode response_code; /* Number of questions in the packet. */ SshUInt16 question_count; /* Array of questions. */ SshDNSQuestion question_array; /* Number of answers in the packet. */ SshUInt16 answer_count; /* Array of answers. */ SshDNSRecord answer_array; /* Number of authority records in the packet. */ SshUInt16 authority_count; /* Array of authority records (NS records). */ SshDNSRecord authority_array; /* Number of additional records in the packet. */ SshUInt16 additional_count; /* Array of additional records. */ SshDNSRecord additional_array; /* All data pointed by above is allocated from this obstack, and if you modify anything in this structure, then you can allocate data from this obstack, and it will be automatically freed when the packet is freed. No other data is freed, so if you allocate some data using any other means, you need to make sure it is freed when the packet is freed. */ SshObStackContext obstack; } *SshDNSPacket, SshDNSPacketStruct; /* Allocate new packet. This will also automatically allocate space for the given number of question, answer, authority, and additional records. Those records are initialized to zeros. Returns NULL if out of memory. */ SshDNSPacket ssh_dns_packet_allocate(SshUInt16 question_count, SshUInt16 answer_count, SshUInt16 authority_count, SshUInt16 additional_count); /* Free dns packet. */ void ssh_dns_packet_free(SshDNSPacket packet); /* Decode packet. This returns NULL if there is memory error or parse error, otherwise it will return the decoded packet. */ SshDNSPacket ssh_dns_packet_decode(const unsigned char *packet, size_t packet_length); /* Encode packet. This will store the packet to the given buffer of size packet_length. This will return the number of bytes consumed from the packet, and if the packet cannot fit to the buffer given then the truncated flag is set on the packet, and return value is number of bytes actually used from the buffer, but it is given out as negative number. */ int ssh_dns_packet_encode(SshDNSPacket packet, unsigned char *buffer, size_t buffer_length); /* Render function to render dnspacket for %@ format string for ssh_e*printf */ int ssh_dns_packet_render(unsigned char *buf, int buf_size, int precision, void *datum); /* Indention string used for packet render etc. */ extern const char ssh_dns_packet_indent[]; #endif /* SSHDNSPACKET_H */
44.386617
79
0.679062
[ "render" ]
543480ea4664c678bd37273430af02762d08ee30
54,736
h
C
01_Develop/libXMGraphics/Source/XMGRippleTable.h
mcodegeeks/OpenKODE-Framework
d4382d781da7f488a0e7667362a89e8e389468dd
[ "MIT" ]
2
2017-08-03T07:15:00.000Z
2018-06-18T10:32:53.000Z
01_Develop/libXMGraphics/Source/XMGRippleTable.h
mcodegeeks/OpenKODE-Framework
d4382d781da7f488a0e7667362a89e8e389468dd
[ "MIT" ]
null
null
null
01_Develop/libXMGraphics/Source/XMGRippleTable.h
mcodegeeks/OpenKODE-Framework
d4382d781da7f488a0e7667362a89e8e389468dd
[ "MIT" ]
2
2019-03-04T22:57:42.000Z
2020-03-06T01:32:26.000Z
/* * * File XMGRippleTable.h * Description Ripple effect table * Version 0.20.0801, 2011-08-01 * Author Y.H Mun * * -------------------------------------------------------------------------- * * Copyright (C) 2010-2011 XMSoft. All rights reserved. * * Contact Email: chris@xmsoft.co.kr * xmsoft77@gmail.com * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * */ #ifndef __XMGRippleTable_h__ #define __XMGRippleTable_h__ #pragma warning( disable : 4305 ) #define GRID_SIZE_X 32 #define GRID_SIZE_Y 32 #define RIPPLE_LENGTH 2048 typedef struct RIPPLE_VECTOR RIPPLE_VECTOR; // precomputed displacement vector table typedef struct RIPPLE_AMP RIPPLE_AMP; // precomputed ripple amplitude table struct RIPPLE_VECTOR { float dx[2]; int r; // distance from origin, in pixels }; struct RIPPLE_AMP { float amplitude; }; RIPPLE_VECTOR g_ripple_vector[ GRID_SIZE_X ][ GRID_SIZE_Y ] = { 0, 0, 0, 0, 1, 25, 0, 1, 51, 0, 1, 77, 0, 1, 103, 0, 1, 129, 0, 1, 154, 0, 1, 180, 0, 1, 206, 0, 1, 232, 0, 1, 258, 0, 1, 283, 0, 1, 309, 0, 1, 335, 0, 1, 361, 0, 1, 387, 0, 1, 412, 0, 1, 438, 0, 1, 464, 0, 1, 490, 0, 1, 516, 0, 1, 541, 0, 1, 567, 0, 1, 593, 0, 1, 619, 0, 1, 645, 0, 1, 670, 0, 1, 696, 0, 1, 722, 0, 1, 748, 0, 1, 774, 0, 1, 800, 1, 0, 25, 0.707107, 0.707107, 36, 0.447214, 0.894427, 57, 0.316228, 0.948683, 81, 0.242536, 0.970143, 106, 0.196116, 0.980581, 131, 0.164399, 0.986394, 156, 0.141421, 0.989949, 182, 0.124035, 0.992278, 208, 0.110432, 0.993884, 233, 0.0995037, 0.995037, 259, 0.0905357, 0.995893, 285, 0.0830455, 0.996546, 310, 0.0766965, 0.997055, 336, 0.071247, 0.997459, 362, 0.066519, 0.997785, 387, 0.0623783, 0.998053, 413, 0.058722, 0.998274, 439, 0.05547, 0.99846, 465, 0.0525588, 0.998618, 491, 0.0499376, 0.998752, 516, 0.0475651, 0.998868, 542, 0.0454077, 0.998969, 568, 0.0434372, 0.999056, 594, 0.0416305, 0.999133, 619, 0.039968, 0.999201, 645, 0.0384331, 0.999261, 671, 0.0370117, 0.999315, 697, 0.0356915, 0.999363, 723, 0.0344623, 0.999406, 748, 0.0333148, 0.999445, 774, 0.0322413, 0.99948, 800, 1, 0, 51, 0.894427, 0.447214, 57, 0.707107, 0.707107, 72, 0.5547, 0.83205, 93, 0.447214, 0.894427, 115, 0.371391, 0.928477, 138, 0.316228, 0.948683, 163, 0.274721, 0.961524, 187, 0.242536, 0.970143, 212, 0.21693 , 0.976187, 237, 0.196116, 0.980581, 263, 0.178885, 0.98387, 288, 0.164399, 0.986394, 313, 0.152057, 0.988372, 339, 0.141421, 0.989949, 364, 0.132164, 0.991228, 390, 0.124035, 0.992278, 416, 0.116841, 0.993151, 441, 0.110432, 0.993884, 467, 0.104685, 0.994505, 493, 0.0995037, 0.995037, 518, 0.0948091, 0.995495, 544, 0.0905357, 0.995893, 570, 0.0866296, 0.996241, 595, 0.0830455, 0.996546, 621, 0.0797452, 0.996815, 647, 0.0766965, 0.997055, 672, 0.0738717, 0.997268, 698, 0.071247, 0.997459, 724, 0.0688021, 0.99763, 750, 0.066519, 0.997785, 775, 0.0643823, 0.997925, 801, 1, 0, 77, 0.948683, 0.316228, 81, 0.83205, 0.5547, 93, 0.707107, 0.707107, 109, 0.6, 0.8, 129, 0.514496, 0.857493, 150, 0.447214, 0.894427, 173, 0.393919, 0.919145, 196, 0.351123, 0.936329, 220, 0.316228, 0.948683, 244, 0.287348, 0.957826, 269, 0.263117, 0.964764, 294, 0.242536, 0.970142, 319, 0.22486, 0.974391, 344, 0.209529, 0.977802, 369, 0.196116, 0.980581, 394, 0.184289, 0.982872, 420, 0.173785, 0.984784, 445, 0.164399, 0.986394, 470, 0.155963, 0.987763, 496, 0.14834, 0.988936, 521, 0.141421, 0.989949, 547, 0.135113, 0.99083, 572, 0.129339, 0.9916, 598, 0.124035, 0.992278, 624, 0.119145, 0.992877, 649, 0.114624, 0.993409, 675, 0.110432, 0.993884, 701, 0.106533, 0.994309, 726, 0.102899, 0.994692, 752, 0.0995037, 0.995037, 778, 0.0963242, 0.99535, 803, 1, 0, 103, 0.970143, 0.242536, 106, 0.894427, 0.447214, 115, 0.8, 0.6, 129, 0.707107, 0.707107, 145, 0.624695, 0.780869, 165, 0.5547, 0.83205, 186, 0.496139, 0.868243, 208, 0.447214, 0.894427, 230, 0.406138, 0.913812, 254, 0.371391, 0.928477, 277, 0.341743, 0.939793, 302, 0.316228, 0.948683, 326, 0.294086, 0.955779, 351, 0.274721, 0.961524, 375, 0.257663, 0.966235, 400, 0.242536, 0.970143, 425, 0.229039, 0.973417, 450, 0.21693, 0.976187, 475, 0.20601, 0.97855, 501, 0.196116, 0.980581, 526, 0.187112, 0.982339, 551, 0.178885, 0.98387, 577, 0.171341, 0.985212, 602, 0.164399, 0.986394, 627, 0.15799, 0.987441, 653, 0.152057, 0.988372, 678, 0.146549, 0.989204, 704, 0.141421, 0.989949, 729, 0.136637, 0.990621, 755, 0.132164, 0.991228, 781, 0.127971, 0.991778, 806, 1, 0, 129, 0.980581, 0.196116, 131, 0.928477, 0.371391, 138, 0.857493, 0.514496, 150, 0.780869, 0.624695, 165, 0.707107, 0.707107, 182, 0.640184, 0.768221, 201, 0.581238, 0.813733, 221, 0.529999, 0.847998, 243, 0.485643, 0.874157, 265, 0.447214, 0.894427, 288, 0.413803, 0.910366, 311, 0.384615, 0.923077, 335, 0.358979, 0.933346, 359, 0.336336, 0.941742, 383, 0.316228, 0.948683, 408, 0.298275, 0.95448, 432, 0.282166, 0.959365, 457, 0.267644, 0.963518, 482, 0.254493, 0.967075, 507, 0.242536, 0.970142, 532, 0.231621, 0.972806, 557, 0.221621, 0.975133, 582, 0.21243, 0.977176, 607, 0.203954, 0.97898, 632, 0.196116, 0.980581, 657, 0.188847, 0.982006, 683, 0.182089, 0.983282, 708, 0.175791, 0.984428, 734, 0.169907, 0.98546, 759, 0.164399, 0.986394, 784, 0.159232, 0.987241, 810, 1, 0, 154, 0.986394, 0.164399, 156, 0.948683, 0.316228, 163, 0.894427, 0.447214, 173, 0.83205, 0.5547, 186, 0.768221, 0.640184, 201, 0.707107, 0.707107, 218, 0.650791, 0.759257, 237, 0.6, 0.8, 258, 0.5547, 0.83205, 279, 0.514496, 0.857493, 300, 0.478852, 0.877896, 323, 0.447214, 0.894427, 346, 0.419058, 0.907959, 369, 0.393919, 0.919145, 393, 0.371391, 0.928477, 416, 0.351123, 0.936329, 440, 0.33282, 0.94299, 465, 0.316228, 0.948683, 489, 0.301131, 0.953583, 514, 0.287348, 0.957826, 538, 0.274721, 0.961524, 563, 0.263117, 0.964764, 588, 0.252422, 0.967617, 613, 0.242536, 0.970142, 638, 0.233373, 0.972387, 663, 0.22486, 0.974391, 688, 0.21693, 0.976187, 713, 0.209529, 0.977802, 738, 0.202606, 0.97926, 764, 0.196116, 0.980581, 789, 0.190022, 0.98178, 814, 1, 0, 180, 0.989949, 0.141421, 182, 0.961524, 0.274721, 187, 0.919145, 0.393919, 196, 0.868243, 0.496139, 208, 0.813733, 0.581238, 221, 0.759257, 0.650791, 237, 0.707107, 0.707107, 255, 0.658505, 0.752577, 274, 0.613941, 0.789352, 294, 0.573462, 0.819232, 315, 0.536875, 0.843661, 336, 0.503871, 0.863779, 358, 0.4741, 0.880471, 381, 0.447214, 0.894427, 403, 0.422885, 0.906183, 427, 0.400819, 0.916157, 450, 0.38075, 0.924678, 474, 0.362446, 0.932005, 498, 0.345705, 0.938343, 522, 0.33035, 0.943858, 546, 0.316228, 0.948683, 571, 0.303204, 0.952926, 595, 0.291162, 0.956674, 620, 0.28, 0.96, 645, 0.26963, 0.962964, 669, 0.259973, 0.965616, 694, 0.250962, 0.967997, 719, 0.242536, 0.970142, 744, 0.234641, 0.972082, 769, 0.22723, 0.973841, 794, 0.220261, 0.975441, 820, 1, 0, 206, 0.992278, 0.124035, 208, 0.970143, 0.242536, 212, 0.936329, 0.351123, 220, 0.894427, 0.447214, 230, 0.847998, 0.529999, 243, 0.8, 0.6, 258, 0.752577, 0.658505, 274, 0.707107, 0.707107, 291, 0.664364, 0.747409, 310, 0.624695, 0.780869, 330, 0.588172, 0.808736, 351, 0.5547, 0.83205, 372, 0.524097, 0.851658, 393, 0.496139, 0.868243, 416, 0.470588, 0.882353, 438, 0.447214, 0.894427, 461, 0.425797, 0.904819, 484, 0.406138, 0.913812, 508, 0.388057, 0.921635, 532, 0.371391, 0.928477, 555, 0.355995, 0.934488, 579, 0.341743, 0.939793, 604, 0.328521, 0.944497, 628, 0.316228, 0.948683, 652, 0.304776, 0.952424, 677, 0.294086, 0.955779, 702, 0.284088, 0.958798, 726, 0.274721, 0.961524, 751, 0.265929, 0.963993, 776, 0.257663, 0.966235, 801, 0.249878, 0.968277, 826, 1, 0, 232, 0.993884, 0.110432, 233, 0.976187, 0.21693, 237, 0.948683, 0.316228, 244, 0.913812, 0.406138, 254, 0.874157, 0.485643, 265, 0.83205, 0.5547, 279, 0.789352, 0.613941, 294, 0.747409, 0.664364, 310, 0.707107, 0.707107, 328, 0.668965, 0.743294, 347, 0.633238, 0.773957, 366, 0.6, 0.8, 387, 0.56921, 0.822192, 408, 0.540758, 0.841179, 429, 0.514496, 0.857493, 451, 0.490261, 0.871575, 473, 0.467888, 0.883788, 496, 0.447214, 0.894427, 519, 0.428086, 0.903738, 542, 0.410365, 0.911922, 565, 0.393919, 0.919145, 589, 0.378633, 0.925547, 613, 0.364399, 0.931243, 637, 0.351123, 0.936329, 661, 0.338719, 0.940887, 685, 0.327111, 0.944986, 710, 0.316228, 0.948683, 734, 0.306009, 0.952029, 758, 0.296399, 0.955064, 783, 0.287348, 0.957826, 808, 0.27881, 0.960346, 833, 1, 0, 258, 0.995037, 0.0995037, 259, 0.980581, 0.196116, 263, 0.957826, 0.287348, 269, 0.928477, 0.371391, 277, 0.894427, 0.447214, 288, 0.857493, 0.514496, 300, 0.819232, 0.573462, 315, 0.780869, 0.624695, 330, 0.743294, 0.668965, 347, 0.707107, 0.707107, 364, 0.672673, 0.73994, 383, 0.640184, 0.768221, 403, 0.609711, 0.792624, 423, 0.581238, 0.813733, 443, 0.5547, 0.83205, 465, 0.529999, 0.847998, 486, 0.50702, 0.861934, 508, 0.485643, 0.874157, 531, 0.465746, 0.884918, 554, 0.447214, 0.894427, 577, 0.429934, 0.902861, 600, 0.413803, 0.910366, 623, 0.398726, 0.91707, 647, 0.384615, 0.923077, 670, 0.371391, 0.928477, 694, 0.358979, 0.933346, 718, 0.347314, 0.937749, 743, 0.336336, 0.941742, 767, 0.325991, 0.945373, 791, 0.316228, 0.948683, 816, 0.307003, 0.951709, 840, 1, 0, 283, 0.995893, 0.0905357, 285, 0.98387, 0.178885, 288, 0.964764, 0.263117, 294, 0.939793, 0.341743, 302, 0.910366, 0.413803, 311, 0.877896, 0.478852, 323, 0.843661, 0.536875, 336, 0.808736, 0.588172, 351, 0.773957, 0.633238, 366, 0.73994, 0.672673, 383, 0.707107, 0.707107, 401, 0.675725, 0.737154, 420, 0.645942, 0.763386, 439, 0.617822, 0.786318, 459, 0.591364, 0.806405, 480, 0.566529, 0.824042, 501, 0.543251, 0.83957, 522, 0.52145, 0.853282, 544, 0.501036, 0.865426, 566, 0.481919, 0.876216, 589, 0.464007, 0.885832, 611, 0.447214, 0.894427, 634, 0.431455, 0.902134, 657, 0.416655, 0.909065, 681, 0.402739, 0.915315, 704, 0.38964, 0.920967, 728, 0.377297, 0.926092, 752, 0.365652, 0.930751, 776, 0.354654, 0.934998, 800, 0.344255, 0.938876, 824, 0.33441, 0.942428, 848, 1, 0, 309, 0.996546, 0.0830455, 310, 0.986394, 0.164399, 313, 0.970142, 0.242536, 319, 0.948683, 0.316228, 326, 0.923077, 0.384615, 335, 0.894427, 0.447214, 346, 0.863779, 0.503871, 358, 0.83205, 0.5547, 372, 0.8, 0.6, 387, 0.768221, 0.640184, 403, 0.737154, 0.675725, 420, 0.707107, 0.707107, 437, 0.67828, 0.734803, 456, 0.650791, 0.759257, 475, 0.624695, 0.780869, 495, 0.6, 0.8, 516, 0.576683, 0.816968, 536, 0.5547, 0.83205, 558, 0.533993, 0.845489, 579, 0.514496, 0.857493, 601, 0.496139, 0.868243, 624, 0.478852, 0.877896, 646, 0.462566, 0.886585, 669, 0.447214, 0.894427, 692, 0.432731, 0.901523, 715, 0.419058, 0.907959, 738, 0.406138, 0.913812, 762, 0.393919, 0.919145, 786, 0.382352, 0.924017, 809, 0.371391, 0.928477, 833, 0.360994, 0.932568, 857, 1, 0, 335, 0.997055, 0.0766965, 336, 0.988372, 0.152057, 339, 0.974391, 0.22486, 344, 0.955779, 0.294086, 351, 0.933346, 0.358979, 359, 0.907959, 0.419058, 369, 0.880471, 0.4741, 381, 0.851658, 0.524097, 393, 0.822192, 0.56921, 408, 0.792624, 0.609711, 423, 0.763386, 0.645942, 439, 0.734803, 0.67828, 456, 0.707107, 0.707107, 474, 0.680451, 0.732794, 493, 0.654931, 0.755689, 512, 0.630593, 0.776114, 532, 0.60745, 0.794358, 552, 0.585491, 0.810679, 572, 0.564684, 0.825307, 594, 0.544988, 0.838444, 615, 0.526355, 0.850265, 637, 0.508729, 0.860927, 659, 0.492057, 0.870563, 681, 0.476283, 0.879292, 704, 0.461353, 0.887217, 727, 0.447214, 0.894427, 750, 0.433816, 0.901002, 773, 0.421111, 0.907009, 796, 0.409056, 0.912509, 820, 0.397607, 0.917556, 843, 0.386727, 0.922194, 867, 1, 0, 361, 0.997459, 0.071247, 362, 0.989949, 0.141421, 364, 0.977802, 0.209529, 369, 0.961524, 0.274721, 375, 0.941742, 0.336336, 383, 0.919145, 0.393919, 393, 0.894427, 0.447214, 403, 0.868243, 0.496139, 416, 0.841179, 0.540758, 429, 0.813733, 0.581238, 443, 0.786318, 0.617822, 459, 0.759257, 0.650791, 475, 0.732794, 0.680451, 493, 0.707107, 0.707107, 510, 0.682318, 0.731055, 529, 0.658505, 0.752577, 548, 0.635707, 0.77193, 568, 0.613941, 0.789352, 588, 0.593199, 0.805056, 609, 0.573462, 0.819232, 630, 0.5547, 0.83205, 651, 0.536875, 0.843661, 672, 0.519947, 0.854199, 694, 0.503871, 0.863779, 717, 0.488603, 0.872506, 739, 0.4741, 0.880471, 762, 0.460317, 0.887755, 784, 0.447214, 0.894427, 807, 0.434749, 0.900552, 831, 0.422885, 0.906183, 854, 0.411587, 0.911371, 877, 1, 0, 387, 0.997785, 0.066519, 387, 0.991228, 0.132164, 390, 0.980581, 0.196116, 394, 0.966235, 0.257663, 400, 0.948683, 0.316228, 408, 0.928477, 0.371391, 416, 0.906183, 0.422885, 427, 0.882353, 0.470588, 438, 0.857493, 0.514496, 451, 0.83205, 0.5547, 465, 0.806405, 0.591364, 480, 0.780869, 0.624695, 495, 0.755689, 0.654931, 512, 0.731055, 0.682318, 529, 0.707107, 0.707107, 547, 0.683941, 0.729537, 565, 0.661622, 0.749838, 585, 0.640184, 0.768221, 604, 0.619644, 0.784883, 624, 0.6, 0.8, 645, 0.581238, 0.813733, 665, 0.563337, 0.826227, 687, 0.546268, 0.837611, 708, 0.529999, 0.847998, 730, 0.514496, 0.857493, 752, 0.499722, 0.866186, 774, 0.485643, 0.874157, 797, 0.472221, 0.88148, 819, 0.459423, 0.888218, 842, 0.447214, 0.894427, 865, 0.435561, 0.900159, 888, 1, 0, 412, 0.998053, 0.0623783, 413, 0.992278, 0.124035, 416, 0.982872, 0.184289, 420, 0.970143, 0.242536, 425, 0.95448, 0.298275, 432, 0.936329, 0.351123, 440, 0.916157, 0.400819, 450, 0.894427, 0.447214, 461, 0.871575, 0.490261, 473, 0.847998, 0.529999, 486, 0.824042, 0.566529, 501, 0.8, 0.6, 516, 0.776114, 0.630593, 532, 0.752577, 0.658505, 548, 0.729537, 0.683941, 565, 0.707107, 0.707107, 583, 0.685365, 0.7282, 602, 0.664364, 0.747409, 621, 0.644136, 0.764911, 641, 0.624695, 0.780869, 660, 0.606043, 0.795432, 681, 0.588172, 0.808736, 702, 0.571064, 0.820905, 723, 0.5547, 0.83205, 744, 0.539054, 0.842271, 765, 0.524097, 0.851658, 787, 0.509802, 0.860291, 809, 0.496139, 0.868243, 832, 0.483077, 0.875578, 854, 0.470588, 0.882353, 877, 0.458643, 0.888621, 900, 1, 0, 438, 0.998274, 0.058722, 439, 0.993151, 0.116841, 441, 0.984784, 0.173785, 445, 0.973417, 0.229039, 450, 0.959365, 0.282166, 457, 0.94299, 0.33282, 465, 0.924678, 0.38075, 474, 0.904819, 0.425797, 484, 0.883788, 0.467888, 496, 0.861934, 0.50702, 508, 0.83957, 0.543251, 522, 0.816968, 0.576683, 536, 0.794358, 0.60745, 552, 0.77193, 0.635707, 568, 0.749838, 0.661622, 585, 0.7282, 0.685365, 602, 0.707107, 0.707107, 620, 0.686624, 0.727013, 638, 0.666795, 0.745241, 657, 0.647648, 0.761939, 677, 0.629198, 0.777245, 697, 0.611448, 0.791285, 717, 0.594391, 0.804176, 738, 0.578017, 0.816024, 758, 0.56231, 0.826927, 780, 0.547249, 0.83697, 801, 0.532813, 0.846233, 823, 0.518978, 0.854788, 845, 0.505719, 0.862698, 867, 0.493013, 0.870022, 889, 0.480833, 0.876812, 912, 1, 0, 464, 0.99846, 0.05547, 465, 0.993884, 0.110432, 467, 0.986394, 0.164399, 470, 0.976187, 0.21693, 475, 0.963518, 0.267644, 482, 0.948683, 0.316228, 489, 0.932005, 0.362446, 498, 0.913812, 0.406138, 508, 0.894427, 0.447214, 519, 0.874157, 0.485643, 531, 0.853282, 0.52145, 544, 0.83205, 0.5547, 558, 0.810679, 0.585491, 572, 0.789352, 0.613941, 588, 0.768221, 0.640184, 604, 0.747409, 0.664364, 621, 0.727013, 0.686624, 638, 0.707107, 0.707107, 656, 0.687745, 0.725953, 675, 0.668965, 0.743294, 694, 0.650791, 0.759257, 713, 0.633238, 0.773957, 733, 0.616308, 0.787505, 753, 0.6, 0.8, 774, 0.584305, 0.811534, 794, 0.56921, 0.822192, 816, 0.5547, 0.83205, 837, 0.540758, 0.841179, 859, 0.527363, 0.84964, 880, 0.514496, 0.857493, 902, 0.502136, 0.864789, 925, 1, 0, 490, 0.998618, 0.0525588, 491, 0.994505, 0.104685, 493, 0.987763, 0.155963, 496, 0.97855, 0.20601, 501, 0.967075, 0.254493, 507, 0.953583, 0.301131, 514, 0.938343, 0.345705, 522, 0.921635, 0.388057, 532, 0.903738, 0.428086, 542, 0.884918, 0.465746, 554, 0.865426, 0.501036, 566, 0.845489, 0.533993, 579, 0.825307, 0.564684, 594, 0.805056, 0.593199, 609, 0.784883, 0.619644, 624, 0.764911, 0.644136, 641, 0.745241, 0.666795, 657, 0.725953, 0.687745, 675, 0.707107, 0.707107, 693, 0.688749, 0.724999, 711, 0.670913, 0.741536, 730, 0.65362, 0.756823, 750, 0.636881, 0.770962, 769, 0.620703, 0.784046, 789, 0.605083, 0.796162, 810, 0.590017, 0.807391, 831, 0.575493, 0.817806, 852, 0.561501, 0.827476, 873, 0.548026, 0.836461, 894, 0.535052, 0.844819, 916, 0.522562, 0.852601, 938, 1, 0, 516, 0.998752, 0.0499376, 516, 0.995037, 0.0995037, 518, 0.988936, 0.14834, 521, 0.980581, 0.196116, 526, 0.970142, 0.242536, 532, 0.957826, 0.287348, 538, 0.943858, 0.33035, 546, 0.928477, 0.371391, 555, 0.911922, 0.410365, 565, 0.894427, 0.447214, 577, 0.876216, 0.481919, 589, 0.857493, 0.514496, 601, 0.838444, 0.544988, 615, 0.819232, 0.573462, 630, 0.8, 0.6, 645, 0.780869, 0.624695, 660, 0.761939, 0.647648, 677, 0.743294, 0.668965, 694, 0.724999, 0.688749, 711, 0.707107, 0.707107, 729, 0.689655, 0.724138, 748, 0.672673, 0.73994, 767, 0.656179, 0.754606, 786, 0.640184, 0.768221, 806, 0.624695, 0.780869, 826, 0.609711, 0.792624, 846, 0.595228, 0.803557, 867, 0.581238, 0.813733, 887, 0.567733, 0.823213, 909, 0.5547, 0.83205, 930, 0.542127, 0.840297, 952, 1, 0, 541, 0.998868, 0.0475651, 542, 0.995495, 0.0948091, 544, 0.989949, 0.141421, 547, 0.982339, 0.187112, 551, 0.972806, 0.231621, 557, 0.961524, 0.274721, 563, 0.948683, 0.316228, 571, 0.934488, 0.355995, 579, 0.919145, 0.393919, 589, 0.902861, 0.429934, 600, 0.885832, 0.464007, 611, 0.868243, 0.496139, 624, 0.850265, 0.526355, 637, 0.83205, 0.5547, 651, 0.813733, 0.581238, 665, 0.795432, 0.606043, 681, 0.777245, 0.629198, 697, 0.759257, 0.650791, 713, 0.741536, 0.670913, 730, 0.724138, 0.689655, 748, 0.707107, 0.707107, 766, 0.690476, 0.723356, 784, 0.674269, 0.738486, 803, 0.658505, 0.752577, 822, 0.643192, 0.765705, 842, 0.628337, 0.777941, 862, 0.613941, 0.789352, 882, 0.6, 0.8, 903, 0.58651, 0.809942, 924, 0.573462, 0.819232, 945, 0.560848, 0.827919, 966, 1, 0, 567, 0.998969, 0.0454077, 568, 0.995893, 0.0905357, 570, 0.99083, 0.135113, 572, 0.98387, 0.178885, 577, 0.975133, 0.221621, 582, 0.964764, 0.263117, 588, 0.952926, 0.303204, 595, 0.939793, 0.341743, 604, 0.925547, 0.378633, 613, 0.910366, 0.413803, 623, 0.894427, 0.447214, 634, 0.877896, 0.478852, 646, 0.860927, 0.508729, 659, 0.843661, 0.536875, 672, 0.826227, 0.563337, 687, 0.808736, 0.588172, 702, 0.791285, 0.611448, 717, 0.773957, 0.633238, 733, 0.756823, 0.65362, 750, 0.73994, 0.672673, 767, 0.723356, 0.690476, 784, 0.707107, 0.707107, 802, 0.691223, 0.722642, 821, 0.675725, 0.737154, 840, 0.660628, 0.750713, 859, 0.645942, 0.763386, 878, 0.631673, 0.775235, 898, 0.617822, 0.786318, 918, 0.604386, 0.796691, 939, 0.591364, 0.806405, 960, 0.578747, 0.815507, 980, 1, 0, 593, 0.999056, 0.0434372, 594, 0.996241, 0.0866296, 595, 0.9916, 0.129339, 598, 0.985212, 0.171341, 602, 0.977176, 0.21243, 607, 0.967617, 0.252422, 613, 0.956674, 0.291162, 620, 0.944497, 0.328521, 628, 0.931243, 0.364399, 637, 0.91707, 0.398726, 647, 0.902134, 0.431455, 657, 0.886585, 0.462566, 669, 0.870563, 0.492057, 681, 0.854199, 0.519947, 694, 0.837611, 0.546268, 708, 0.820905, 0.571064, 723, 0.804176, 0.594391, 738, 0.787505, 0.616308, 753, 0.770962, 0.636881, 769, 0.754606, 0.656179, 786, 0.738486, 0.674269, 803, 0.722642, 0.691223, 821, 0.707107, 0.707107, 839, 0.691905, 0.721988, 857, 0.677056, 0.735931, 876, 0.662574, 0.748996, 895, 0.648466, 0.761243, 915, 0.634739, 0.772726, 935, 0.621395, 0.783498, 955, 0.608432, 0.793606, 975, 0.595847, 0.803098, 996, 1, 0, 619, 0.999133, 0.0416305, 619, 0.996546, 0.0830455, 621, 0.992278, 0.124035, 624, 0.986394, 0.164399, 627, 0.97898, 0.203954, 632, 0.970142, 0.242536, 638, 0.96, 0.28, 645, 0.948683, 0.316228, 652, 0.936329, 0.351123, 661, 0.923077, 0.384615, 670, 0.909065, 0.416655, 681, 0.894427, 0.447214, 692, 0.879292, 0.476283, 704, 0.863779, 0.503871, 717, 0.847998, 0.529999, 730, 0.83205, 0.5547, 744, 0.816024, 0.578017, 758, 0.8, 0.6, 774, 0.784046, 0.620703, 789, 0.768221, 0.640184, 806, 0.752577, 0.658505, 822, 0.737154, 0.675725, 840, 0.721988, 0.691905, 857, 0.707107, 0.707107, 875, 0.692532, 0.721387, 894, 0.67828, 0.734803, 913, 0.664364, 0.747409, 932, 0.650791, 0.759257, 951, 0.637568, 0.770394, 971, 0.624695, 0.780869, 991, 0.612173, 0.790724, 1011, 1, 0, 645, 0.999201, 0.039968, 645, 0.996815, 0.0797452, 647, 0.992877, 0.119145, 649, 0.987441, 0.15799, 653, 0.980581, 0.196116, 657, 0.972387, 0.233373, 663, 0.962964, 0.26963, 669, 0.952424, 0.304776, 677, 0.940887, 0.338719, 685, 0.928477, 0.371391, 694, 0.915315, 0.402739, 704, 0.901523, 0.432731, 715, 0.887217, 0.461353, 727, 0.872506, 0.488603, 739, 0.857493, 0.514496, 752, 0.842271, 0.539054, 765, 0.826927, 0.56231, 780, 0.811534, 0.584305, 794, 0.796162, 0.605083, 810, 0.780869, 0.624695, 826, 0.765705, 0.643192, 842, 0.750713, 0.660628, 859, 0.735931, 0.677056, 876, 0.721387, 0.692532, 894, 0.707107, 0.707107, 912, 0.693109, 0.720833, 930, 0.679408, 0.733761, 949, 0.666016, 0.745938, 968, 0.65294, 0.75741, 988, 0.640184, 0.768221, 1007, 0.627752, 0.778413, 1027, 1, 0, 670, 0.999261, 0.0384331, 671, 0.997055, 0.0766965, 672, 0.993409, 0.114624, 675, 0.988372, 0.152057, 678, 0.982006, 0.188847, 683, 0.974391, 0.22486, 688, 0.965616, 0.259973, 694, 0.955779, 0.294086, 702, 0.944986, 0.327111, 710, 0.933346, 0.358979, 718, 0.920967, 0.38964, 728, 0.907959, 0.419058, 738, 0.894427, 0.447214, 750, 0.880471, 0.4741, 762, 0.866186, 0.499722, 774, 0.851658, 0.524097, 787, 0.83697, 0.547249, 801, 0.822192, 0.56921, 816, 0.807391, 0.590017, 831, 0.792624, 0.609711, 846, 0.777941, 0.628337, 862, 0.763386, 0.645942, 878, 0.748996, 0.662574, 895, 0.734803, 0.67828, 913, 0.720833, 0.693109, 930, 0.707107, 0.707107, 948, 0.693642, 0.72032, 967, 0.680451, 0.732794, 986, 0.667545, 0.744569, 1005, 0.654931, 0.755689, 1024, 0.642612, 0.766192, 1044, 1, 0, 696, 0.999315, 0.0370117, 697, 0.997268, 0.0738717, 698, 0.993884, 0.110432, 701, 0.989204, 0.146549, 704, 0.983282, 0.182089, 708, 0.976187, 0.21693, 713, 0.967997, 0.250962, 719, 0.958798, 0.284088, 726, 0.948683, 0.316228, 734, 0.937749, 0.347314, 743, 0.926092, 0.377297, 752, 0.913812, 0.406138, 762, 0.901002, 0.433816, 773, 0.887755, 0.460317, 784, 0.874157, 0.485643, 797, 0.860291, 0.509802, 809, 0.846233, 0.532813, 823, 0.83205, 0.5547, 837, 0.817806, 0.575493, 852, 0.803557, 0.595228, 867, 0.789352, 0.613941, 882, 0.775235, 0.631673, 898, 0.761243, 0.648466, 915, 0.747409, 0.664364, 932, 0.733761, 0.679408, 949, 0.72032, 0.693642, 967, 0.707107, 0.707107, 985, 0.694136, 0.719844, 1003, 0.681419, 0.731894, 1022, 0.668965, 0.743294, 1041, 0.656781, 0.754082, 1060, 1, 0, 722, 0.999363, 0.0356915, 723, 0.997459, 0.071247, 724, 0.994309, 0.106533, 726, 0.989949, 0.141421, 729, 0.984428, 0.175791, 734, 0.977802, 0.209529, 738, 0.970142, 0.242536, 744, 0.961524, 0.274721, 751, 0.952029, 0.306009, 758, 0.941742, 0.336336, 767, 0.930751, 0.365652, 776, 0.919145, 0.393919, 786, 0.907009, 0.421111, 796, 0.894427, 0.447214, 807, 0.88148, 0.472221, 819, 0.868243, 0.496139, 832, 0.854788, 0.518978, 845, 0.841179, 0.540758, 859, 0.827476, 0.561501, 873, 0.813733, 0.581238, 887, 0.8, 0.6, 903, 0.786318, 0.617822, 918, 0.772726, 0.634739, 935, 0.759257, 0.650791, 951, 0.745938, 0.666016, 968, 0.732794, 0.680451, 986, 0.719844, 0.694136, 1003, 0.707107, 0.707107, 1021, 0.694595, 0.719401, 1040, 0.682318, 0.731055, 1059, 0.670286, 0.742103, 1078, 1, 0, 748, 0.999406, 0.0344623, 748, 0.99763, 0.0688021, 750, 0.994692, 0.102899, 752, 0.990621, 0.136637, 755, 0.98546, 0.169907, 759, 0.97926, 0.202606, 764, 0.972082, 0.234641, 769, 0.963993, 0.265929, 776, 0.955064, 0.296399, 783, 0.945373, 0.325991, 791, 0.934998, 0.354654, 800, 0.924017, 0.382352, 809, 0.912509, 0.409056, 820, 0.900552, 0.434749, 831, 0.888218, 0.459423, 842, 0.875578, 0.483077, 854, 0.862698, 0.505719, 867, 0.84964, 0.527363, 880, 0.836461, 0.548026, 894, 0.823213, 0.567733, 909, 0.809942, 0.58651, 924, 0.796691, 0.604386, 939, 0.783498, 0.621395, 955, 0.770394, 0.637568, 971, 0.75741, 0.65294, 988, 0.744569, 0.667545, 1005, 0.731894, 0.681419, 1022, 0.719401, 0.694595, 1040, 0.707107, 0.707107, 1058, 0.695022, 0.718988, 1076, 0.683157, 0.730271, 1095, 1, 0, 774, 0.999445, 0.0333148, 774, 0.997785, 0.066519, 775, 0.995037, 0.0995037, 778, 0.991228, 0.132164, 781, 0.986394, 0.164399, 784, 0.980581, 0.196116, 789, 0.973841, 0.22723, 794, 0.966235, 0.257663, 801, 0.957826, 0.287348, 808, 0.948683, 0.316228, 816, 0.938876, 0.344255, 824, 0.928477, 0.371391, 833, 0.917556, 0.397607, 843, 0.906183, 0.422885, 854, 0.894427, 0.447214, 865, 0.882353, 0.470588, 877, 0.870022, 0.493013, 889, 0.857493, 0.514496, 902, 0.844819, 0.535052, 916, 0.83205, 0.5547, 930, 0.819232, 0.573462, 945, 0.806405, 0.591364, 960, 0.793606, 0.608432, 975, 0.780869, 0.624695, 991, 0.768221, 0.640184, 1007, 0.755689, 0.654931, 1024, 0.743294, 0.668965, 1041, 0.731055, 0.682318, 1059, 0.718988, 0.695022, 1076, 0.707107, 0.707107, 1094, 0.695421, 0.718602, 1113, 1, 0, 800, 0.99948, 0.0322413, 800, 0.997925, 0.0643823, 801, 0.99535, 0.0963242, 803, 0.991778, 0.127971, 806, 0.987241, 0.159232, 810, 0.98178, 0.190022, 814, 0.975441, 0.220261, 820, 0.968277, 0.249878, 826, 0.960346, 0.27881, 833, 0.951709, 0.307003, 840, 0.942428, 0.33441, 848, 0.932568, 0.360994, 857, 0.922194, 0.386727, 867, 0.911371, 0.411587, 877, 0.900159, 0.435561, 888, 0.888621, 0.458643, 900, 0.876812, 0.480833, 912, 0.864789, 0.502136, 925, 0.852601, 0.522562, 938, 0.840297, 0.542127, 952, 0.827919, 0.560848, 966, 0.815507, 0.578747, 980, 0.803098, 0.595847, 996, 0.790724, 0.612173, 1011, 0.778413, 0.627752, 1027, 0.766192, 0.642612, 1044, 0.754082, 0.656781, 1060, 0.742103, 0.670286, 1078, 0.730271, 0.683157, 1095, 0.718602, 0.695421, 1113, 0.707107, 0.707107, 1131 }; const RIPPLE_AMP g_ripple_amp[ RIPPLE_LENGTH ] = { 0, 2.96058e-06, 0.000131057, 0.00044642, 0.000945887, 0.00162576, 0.00248181, 0.00350931, 0.00470306, 0.00605736, 0.0075661, 0.00922273, 0.0110203, 0.0129515, 0.0150086, 0.0171836, 0.0194683, 0.0218541, 0.0243321, 0.0268934, 0.0295288, 0.0322288, 0.0349841, 0.0377851, 0.0406221, 0.0434855, 0.0463656, 0.0492527, 0.0521374, 0.0550101, 0.0578613, 0.060682, 0.063463, 0.0661954, 0.0688706, 0.0714802, 0.074016, 0.0764702, 0.0788353, 0.081104, 0.0832696, 0.0853256, 0.0872659, 0.0890848, 0.090777, 0.0923378, 0.0937628, 0.0950481, 0.0961901, 0.097186, 0.0980331, 0.0987295, 0.0992736, 0.0996644, 0.0999011, 0.0999838, 0.0999128, 0.0996889, 0.0993133, 0.098788, 0.098115, 0.097297, 0.0963371, 0.0952388, 0.0940059, 0.0926426, 0.0911537, 0.0895441, 0.0878191, 0.0859844, 0.0840458, 0.0820095, 0.079882, 0.07767, 0.0753804, 0.0730202, 0.0705966, 0.068117, 0.0655889, 0.0630199, 0.0604176, 0.0577896, 0.0551438, 0.0524877, 0.049829, 0.0471754, 0.0445344, 0.0419134, 0.0393198, 0.0367607, 0.0342431, 0.0317739, 0.0293597, 0.027007, 0.0247218, 0.0225101, 0.0203776, 0.0183295, 0.0163711, 0.0145069, 0.0127414, 0.0110788, 0.00952268, 0.00807647, 0.00674318, 0.00552545, 0.00442555, 0.00344538, 0.00258644, 0.00184986, 0.00123638, 0.000746374, 0.000379814, 0.00013631, 1.50917e-05, 1.50262e-05, 0.000134618, 0.000372018, 0.000725034, 0.00119114, 0.00176748, 0.00245089, 0.0032379, 0.00412476, 0.00510744, 0.00618166, 0.00734288, 0.00858635, 0.0099071, 0.0113, 0.0127596, 0.0142805, 0.015857, 0.0174835, 0.0191539, 0.0208623, 0.0226028, 0.0243693, 0.0261557, 0.0279558, 0.0297637, 0.0315731, 0.0333782, 0.035173, 0.0369516, 0.0387082, 0.0404372, 0.0421331, 0.0437906, 0.0454043, 0.0469694, 0.0484809, 0.0499343, 0.0513251, 0.0526492, 0.0539027, 0.0550818, 0.0561832, 0.0572037, 0.0581404, 0.0589908, 0.0597525, 0.0604235, 0.0610022, 0.0614871, 0.0618771, 0.0621714, 0.0623695, 0.0624712, 0.0624766, 0.062386, 0.0622002, 0.0619202, 0.0615471, 0.0610826, 0.0605284, 0.0598865, 0.0591594, 0.0583495, 0.0574597, 0.056493, 0.0554526, 0.0543418, 0.0531645, 0.0519243, 0.0506251, 0.0492712, 0.0478667, 0.046416, 0.0449235, 0.0433939, 0.0418317, 0.0402417, 0.0386285, 0.036997, 0.0353519, 0.033698, 0.0320402, 0.0303831, 0.0287315, 0.02709, 0.0254632, 0.0238557, 0.0222717, 0.0207157, 0.0191917, 0.0177039, 0.0162561, 0.014852, 0.0134953, 0.0121893, 0.0109372, 0.00974216, 0.00860689, 0.00753404, 0.006526, 0.00558498, 0.00471292, 0.00391157, 0.00318243, 0.00252676, 0.00194561, 0.00143976, 0.00100979, 0.000656015, 0.000378524, 0.000177173, 5.15851e-05, 1.15624e-06, 2.50573e-05, 0.000122239, 0.000291439, 0.000531184, 0.000839799, 0.00121541, 0.00165597, 0.00215923, 0.00272277, 0.00334404, 0.00402029, 0.00474867, 0.00552615, 0.00634963, 0.00721584, 0.00812147, 0.00906306, 0.0100371, 0.0110401, 0.0120682, 0.013118, 0.0141856, 0.0152673, 0.0163594, 0.0174581, 0.0185598, 0.0196607, 0.0207571, 0.0218454, 0.0229222, 0.0239838, 0.0250269, 0.0260481, 0.0270443, 0.0280122, 0.028949, 0.0298517, 0.0307175, 0.031544, 0.0323285, 0.0330688, 0.0337628, 0.0344084, 0.0350038, 0.0355474, 0.0360377, 0.0364734, 0.0368533, 0.0371766, 0.0374425, 0.0376504, 0.0378, 0.037891, 0.0379234, 0.0378973, 0.0378133, 0.0376716, 0.0374731, 0.0372187, 0.0369092, 0.036546, 0.0361303, 0.0356637, 0.0351478, 0.0345843, 0.0339753, 0.0333226, 0.0326286, 0.0318953, 0.0311252, 0.0303208, 0.0294845, 0.0286189, 0.0277268, 0.0268109, 0.025874, 0.0249189, 0.0239484, 0.0229654, 0.0219729, 0.0209737, 0.0199707, 0.0189668, 0.0179648, 0.0169676, 0.0159779, 0.0149986, 0.0140321, 0.0130813, 0.0121486, 0.0112364, 0.0103473, 0.00948342, 0.00864699, 0.00784011, 0.00706477, 0.00632281, 0.005616, 0.00494594, 0.00431415, 0.00372199, 0.00317068, 0.00266133, 0.00219489, 0.00177218, 0.00139387, 0.00106051, 0.000772479, 0.000530034, 0.000333281, 0.000182189, 7.65858e-05, 1.61636e-05, 4.78151e-07, 2.89528e-05, 0.000100882, 0.000215432, 0.00037165, 0.000568461, 0.000804679, 0.00107901, 0.00139004, 0.00173629, 0.00211616, 0.00252796, 0.00296993, 0.00344024, 0.00393698, 0.00445818, 0.00500181, 0.0055658, 0.00614804, 0.00674637, 0.0073586, 0.00798254, 0.00861598, 0.00925668, 0.00990242, 0.010551, 0.0112002, 0.0118478, 0.0124917, 0.0131297, 0.0137598, 0.01438, 0.0149881, 0.0155823, 0.0161608, 0.0167216, 0.0172632, 0.0177837, 0.0182817, 0.0187557, 0.0192042, 0.0196259, 0.0200197, 0.0203843, 0.0207189, 0.0210224, 0.0212941, 0.0215333, 0.0217394, 0.0219118, 0.0220503, 0.0221546, 0.0222244, 0.0222598, 0.0222607, 0.0222275, 0.0221602, 0.0220594, 0.0219254, 0.0217589, 0.0215605, 0.0213309, 0.021071, 0.0207818, 0.0204642, 0.0201194, 0.0197485, 0.0193527, 0.0189333, 0.0184918, 0.0180295, 0.0175478, 0.0170484, 0.0165327, 0.0160024, 0.0154591, 0.0149043, 0.0143398, 0.0137673, 0.0131884, 0.0126049, 0.0120184, 0.0114306, 0.0108431, 0.0102578, 0.00967603, 0.00909959, 0.00852999, 0.00796878, 0.00741746, 0.00687748, 0.00635024, 0.00583711, 0.00533938, 0.00485828, 0.00439499, 0.00395062, 0.00352621, 0.00312273, 0.00274107, 0.00238205, 0.00204643, 0.00173485, 0.00144791, 0.00118612, 0.000949877, 0.000739539, 0.000555357, 0.000397506, 0.000266077, 0.000161081, 8.24463e-05, 3.0023e-05, 3.58147e-06, 2.81518e-06, 2.73422e-05, 7.67071e-05, 0.000150383, 0.000247774, 0.000368218, 0.000510988, 0.000675297, 0.000860301, 0.0010651, 0.00128874, 0.00153023, 0.00178851, 0.00206252, 0.00235111, 0.00265315, 0.00296745, 0.00329279, 0.00362796, 0.00397169, 0.00432273, 0.00467982, 0.00504167, 0.005407, 0.00577455, 0.00614305, 0.00651124, 0.00687787, 0.00724173, 0.00760161, 0.00795633, 0.00830474, 0.00864572, 0.00897819, 0.00930111, 0.00961347, 0.0099143, 0.0102027, 0.0104778, 0.0107387, 0.0109848, 0.0112153, 0.0114295, 0.0116269, 0.0118068, 0.0119689, 0.0121127, 0.0122379, 0.0123441, 0.0124311, 0.0124988, 0.012547, 0.0125757, 0.0125849, 0.0125747, 0.0125452, 0.0124965, 0.012429, 0.012343, 0.0122387, 0.0121167, 0.0119774, 0.0118212, 0.0116488, 0.0114607, 0.0112577, 0.0110403, 0.0108093, 0.0105655, 0.0103096, 0.0100425, 0.00976502, 0.00947803, 0.00918241, 0.00887907, 0.00856894, 0.00825294, 0.00793204, 0.00760716, 0.00727926, 0.0069493, 0.00661821, 0.00628695, 0.00595645, 0.00562762, 0.00530138, 0.0049786, 0.00466017, 0.00434693, 0.0040397, 0.00373929, 0.00344644, 0.00316191, 0.0028864, 0.00262057, 0.00236505, 0.00212045, 0.00188731, 0.00166614, 0.00145742, 0.00126158, 0.001079, 0.000910015, 0.000754927, 0.000613982, 0.000487384, 0.000375289, 0.000277808, 0.000195006, 0.000126903, 7.34734e-05, 3.46461e-05, 1.03071e-05, 2.98978e-07, 4.4223e-06, 2.24364e-05, 5.40607e-05, 9.89762e-05, 0.000156826, 0.000227219, 0.000309728, 0.000403896, 0.000509231, 0.000625218, 0.000751309, 0.000886936, 0.00103151, 0.0011844, 0.001345, 0.00151264, 0.00168667, 0.0018664, 0.00205116, 0.00224025, 0.00243297, 0.00262862, 0.00282649, 0.00302589, 0.00322612, 0.00342648, 0.00362629, 0.00382486, 0.00402155, 0.00421568, 0.00440664, 0.0045938, 0.00477656, 0.00495433, 0.00512658, 0.00529275, 0.00545234, 0.00560487, 0.00574988, 0.00588694, 0.00601567, 0.00613568, 0.00624665, 0.00634827, 0.00644028, 0.00652242, 0.00659451, 0.00665636, 0.00670784, 0.00674884, 0.0067793, 0.00679918, 0.00680848, 0.00680722, 0.00679547, 0.00677333, 0.00674092, 0.0066984, 0.00664595, 0.00658379, 0.00651216, 0.00643133, 0.0063416, 0.00624329, 0.00613675, 0.00602232, 0.00590041, 0.00577142, 0.00563576, 0.00549389, 0.00534624, 0.00519329, 0.00503551, 0.00487339, 0.00470743, 0.00453813, 0.00436599, 0.00419153, 0.00401525, 0.00383768, 0.00365931, 0.00348065, 0.00330222, 0.0031245, 0.00294798, 0.00277315, 0.00260047, 0.00243041, 0.00226339, 0.00209986, 0.00194024, 0.00178491, 0.00163426, 0.00148866, 0.00134844, 0.00121392, 0.00108542, 0.000963203, 0.000847532, 0.00073864, 0.00063674, 0.000542016, 0.000454633, 0.000374729, 0.000302418, 0.000237789, 0.000180908, 0.000131815, 9.05269e-05, 5.7035e-05, 3.1308e-05, 1.32908e-05, 2.90539e-06, 5.13412e-08, 4.60627e-06, 1.64266e-05, 3.5348e-05, 6.11866e-05, 9.37392e-05, 0.000132785, 0.000178085, 0.000229384, 0.000286413, 0.000348887, 0.000416508, 0.000488966, 0.000565939, 0.000647098, 0.000732101, 0.000820601, 0.000912245, 0.00100667, 0.00110352, 0.00120242, 0.001303, 0.0014049, 0.00150775, 0.00161117, 0.00171481, 0.00181831, 0.0019213, 0.00202344, 0.00212439, 0.00222382, 0.00232139, 0.00241679, 0.00250971, 0.00259987, 0.00268698, 0.00277077, 0.00285098, 0.00292738, 0.00299974, 0.00306785, 0.00313151, 0.00319056, 0.00324481, 0.00329414, 0.00333841, 0.00337751, 0.00341135, 0.00343986, 0.00346298, 0.00348066, 0.00349289, 0.00349966, 0.00350098, 0.00349688, 0.0034874, 0.00347262, 0.0034526, 0.00342744, 0.00339724, 0.00336214, 0.00332226, 0.00327776, 0.00322879, 0.00317554, 0.00311819, 0.00305692, 0.00299196, 0.00292352, 0.00285181, 0.00277707, 0.00269954, 0.00261946, 0.00253708, 0.00245266, 0.00236644, 0.0022787, 0.00218968, 0.00209965, 0.00200888, 0.00191762, 0.00182613, 0.00173467, 0.0016435, 0.00155286, 0.00146299, 0.00137415, 0.00128656, 0.00120045, 0.00111604, 0.00103355, 0.000953173, 0.000875109, 0.000799543, 0.00072665, 0.000656597, 0.000589537, 0.000525615, 0.000464962, 0.0004077, 0.000353936, 0.000303768, 0.00025728, 0.000214544, 0.00017562, 0.000140555, 0.000109384, 8.21298e-05, 5.8802e-05, 3.9399e-05, 2.39069e-05, 1.22998e-05, 4.54041e-06, 5.8013e-07, 3.59233e-07, 3.80732e-06, 1.08437e-05, 2.13775e-05, 3.53086e-05, 5.25276e-05, 7.29164e-05, 9.63486e-05, 0.00012269, 0.0001518, 0.000183531, 0.000217728, 0.000254233, 0.000292879, 0.0003335, 0.000375922, 0.000419968, 0.000465461, 0.000512219, 0.000560061, 0.000608804, 0.000658263, 0.000708255, 0.0007586, 0.000809114, 0.00085962, 0.000909941, 0.000959903, 0.00100934, 0.00105807, 0.00110595, 0.00115282, 0.00119852, 0.00124292, 0.00128586, 0.00132721, 0.00136686, 0.00140467, 0.00144054, 0.00147437, 0.00150605, 0.00153549, 0.00156263, 0.00158738, 0.00160968, 0.00162947, 0.00164671, 0.00166137, 0.00167341, 0.00168281, 0.00168955, 0.00169365, 0.00169509, 0.0016939, 0.00169009, 0.00168369, 0.00167475, 0.0016633, 0.0016494, 0.0016331, 0.00161447, 0.00159359, 0.00157052, 0.00154536, 0.0015182, 0.00148912, 0.00145823, 0.00142564, 0.00139144, 0.00135575, 0.00131869, 0.00128037, 0.00124092, 0.00120045, 0.00115908, 0.00111695, 0.00107418, 0.00103089, 0.000987216, 0.000943273, 0.00089919, 0.000855091, 0.000811098, 0.000767331, 0.000723907, 0.000680942, 0.000638548, 0.000596835, 0.000555908, 0.00051587, 0.000476817, 0.000438844, 0.000402039, 0.000366486, 0.000332266, 0.000299451, 0.000268111, 0.000238309, 0.000210102, 0.000183544, 0.00015868, 0.00013555, 0.00011419, 9.46283e-05, 7.68873e-05, 6.09843e-05, 4.69302e-05, 3.47303e-05, 2.43841e-05, 1.58854e-05, 9.22229e-06, 4.37762e-06, 1.32876e-06, 4.78941e-08, 5.0218e-07, 2.65391e-06, 6.46068e-06, 1.18756e-05, 1.88476e-05, 2.73213e-05, 3.72378e-05, 4.85344e-05, 6.11451e-05, 7.50008e-05, 9.00297e-05, 0.000106157, 0.000123307, 0.000141399, 0.000160354, 0.000180089, 0.000200521, 0.000221567, 0.00024314, 0.000265156, 0.00028753, 0.000310176, 0.000333009, 0.000355947, 0.000378904, 0.0004018, 0.000424555, 0.000447088, 0.000469323, 0.000491186, 0.000512603, 0.000533505, 0.000553823, 0.000573494, 0.000592456, 0.000610651, 0.000628023, 0.00064452, 0.000660094, 0.000674702, 0.000688301, 0.000700855, 0.000712331, 0.000722699, 0.000731934, 0.000740014, 0.000746923, 0.000752646, 0.000757174, 0.000760502, 0.000762627, 0.000763552, 0.000763283, 0.000761829, 0.000759204, 0.000755423, 0.000750508, 0.000744482, 0.000737371, 0.000729204, 0.000720015, 0.000709839, 0.000698713, 0.000686678, 0.000673778, 0.000660055, 0.000645558, 0.000630335, 0.000614436, 0.000597912, 0.000580817, 0.000563204, 0.000545128, 0.000526645, 0.000507809, 0.000488679, 0.000469309, 0.000449756, 0.000430077, 0.000410327, 0.000390561, 0.000370834, 0.000351198, 0.000331708, 0.000312413, 0.000293365, 0.000274611, 0.000256198, 0.000238172, 0.000220576, 0.000203451, 0.000186836, 0.00017077, 0.000155286, 0.000140418, 0.000126195, 0.000112646, 9.97956e-05, 8.76672e-05, 7.6281e-05, 6.56545e-05, 5.58029e-05, 4.67387e-05, 3.84717e-05, 3.10094e-05, 2.43563e-05, 1.85146e-05, 1.3484e-05, 9.26145e-06, 5.84178e-06, 3.21724e-06, 1.37781e-06, 3.1118e-07, 2.89121e-09, 4.36352e-07, 1.59295e-06, 3.45215e-06, 5.99155e-06, 9.18704e-06, 1.30128e-05, 1.74417e-05, 2.24448e-05, 2.79921e-05, 3.40525e-05, 4.05935e-05, 4.7582e-05, 5.49838e-05, 6.2764e-05, 7.08872e-05, 7.93175e-05, 8.80185e-05, 9.69537e-05, 0.000106087, 0.00011538, 0.000124798, 0.000134304, 0.000143862, 0.000153437, 0.000162992, 0.000172495, 0.000181911, 0.000191208, 0.000200353, 0.000209317, 0.000218068, 0.000226579, 0.000234822, 0.000242771, 0.000250401, 0.00025769, 0.000264615, 0.000271156, 0.000277294, 0.000283013, 0.000288297, 0.000293131, 0.000297505, 0.000301407, 0.000304828, 0.000307762, 0.000310202, 0.000312145, 0.00031359, 0.000314535, 0.000314981, 0.000314931, 0.00031439, 0.000313362, 0.000311856, 0.000309879, 0.000307442, 0.000304556, 0.000301233, 0.000297488, 0.000293334, 0.000288788, 0.000283867, 0.000278589, 0.000272971, 0.000267034, 0.000260799, 0.000254284, 0.000247513, 0.000240507, 0.000233287, 0.000225878, 0.0002183, 0.000210579, 0.000202735, 0.000194794, 0.000186777, 0.000178708, 0.00017061, 0.000162504, 0.000154414, 0.00014636, 0.000138365, 0.000130448, 0.000122631, 0.000114933, 0.000107372, 9.99676e-05, 9.27363e-05, 8.56949e-05, 7.88593e-05, 7.22442e-05, 6.58636e-05, 5.97305e-05, 5.38569e-05, 4.82539e-05, 4.29313e-05, 3.78983e-05, 3.31626e-05, 2.87313e-05, 2.461e-05, 2.08037e-05, 1.73159e-05, 1.41495e-05, 1.13059e-05, 8.78593e-06, 6.58908e-06, 4.71401e-06, 3.15835e-06, 1.91881e-06, 9.91187e-07, 3.70365e-07, 5.03894e-08, 2.44732e-08, 2.85042e-07, 8.23771e-07, 1.63162e-06, 2.69888e-06, 4.01521e-06, 5.56969e-06, 7.35085e-06, 9.34673e-06, 1.15449e-05, 1.39326e-05, 1.64966e-05, 1.92235e-05, 2.20994e-05, 2.51106e-05, 2.82428e-05, 3.14818e-05, 3.48134e-05, 3.82233e-05, 4.1697e-05, 4.52205e-05, 4.87796e-05, 5.23604e-05, 5.5949e-05, 5.9532e-05, 6.30961e-05, 6.66284e-05, 7.01162e-05, 7.35475e-05, 7.69103e-05, 8.01933e-05, 8.33857e-05, 8.6477e-05, 8.94574e-05, 9.23176e-05, 9.50488e-05, 9.76428e-05, 0.000100092, 0.00010239, 0.000104529, 0.000106505, 0.000108312, 0.000109945, 0.000111401, 0.000112677, 0.000113771, 0.000114679, 0.000115402, 0.000115938, 0.000116287, 0.00011645, 0.000116429, 0.000116225, 0.00011584, 0.000115277, 0.000114539, 0.000113632, 0.000112558, 0.000111322, 0.000109931, 0.000108389, 0.000106703, 0.000104879, 0.000102924, 0.000100845, 9.86492e-05, 9.63442e-05, 9.39378e-05, 9.1438e-05, 8.88529e-05, 8.61909e-05, 8.34602e-05, 8.06694e-05, 7.7827e-05, 7.49413e-05, 7.2021e-05, 6.90745e-05, 6.61101e-05, 6.31363e-05, 6.01611e-05, 5.71926e-05, 5.42387e-05, 5.13072e-05, 4.84054e-05, 4.55407e-05, 4.27202e-05, 3.99504e-05, 3.72381e-05, 3.45893e-05, 3.20099e-05, 2.95054e-05, 2.70812e-05, 2.47421e-05, 2.24926e-05, 2.03368e-05, 1.82786e-05, 1.63215e-05, 1.44683e-05, 1.27219e-05, 1.10845e-05, 9.55801e-06, 8.14397e-06, 6.84351e-06, 5.65743e-06, 4.58613e-06, 3.62965e-06, 2.78769e-06, 2.05959e-06, 1.44434e-06, 9.4062e-07, 5.4678e-07, 2.60861e-07, 8.06124e-08, 3.49772e-09, 2.67124e-08, 1.47197e-07, 3.6165e-07, 6.66548e-07, 1.05815e-06, 1.53254e-06, 2.08561e-06, 2.71308e-06, 3.41055e-06, 4.17349e-06, 4.99724e-06, 5.87707e-06, 6.80817e-06, 7.78565e-06, 8.80461e-06, 9.8601e-06, 1.09472e-05, 1.20609e-05, 1.31963e-05, 1.43485e-05, 1.55128e-05, 1.66843e-05, 1.78583e-05, 1.90303e-05, 2.01958e-05, 2.13504e-05, 2.24898e-05, 2.36101e-05, 2.47072e-05, 2.57774e-05, 2.68171e-05, 2.78228e-05, 2.87913e-05, 2.97195e-05, 3.06046e-05, 3.1444e-05, 3.22352e-05, 3.29759e-05, 3.36642e-05, 3.42983e-05, 3.48765e-05, 3.53976e-05, 3.58603e-05, 3.62637e-05, 3.66071e-05, 3.689e-05, 3.71122e-05, 3.72734e-05, 3.7374e-05, 3.7414e-05, 3.73942e-05, 3.73151e-05, 3.71776e-05, 3.69829e-05, 3.67321e-05, 3.64265e-05, 3.60678e-05, 3.56575e-05, 3.51976e-05, 3.46899e-05, 3.41365e-05, 3.35395e-05, 3.29013e-05, 3.22241e-05, 3.15104e-05, 3.07627e-05, 2.99836e-05, 2.91756e-05, 2.83415e-05, 2.74839e-05, 2.66055e-05, 2.57091e-05, 2.47973e-05, 2.38729e-05, 2.29386e-05, 2.19972e-05, 2.10512e-05, 2.01032e-05, 1.91559e-05, 1.82118e-05, 1.72733e-05, 1.63428e-05, 1.54226e-05, 1.4515e-05, 1.36222e-05, 1.27461e-05, 1.18889e-05, 1.10522e-05, 1.0238e-05, 9.44777e-06, 8.6832e-06, 7.94568e-06, 7.23654e-06, 6.55698e-06, 5.9081e-06, 5.29086e-06, 4.70612e-06, 4.1546e-06, 3.63692e-06, 3.15357e-06, 2.70493e-06, 2.29125e-06, 1.91269e-06, 1.56927e-06, 1.26091e-06, 9.87428e-07, 7.48537e-07, 5.43843e-07, 3.72856e-07, 2.34993e-07, 1.2958e-07, 5.58589e-08, 1.29881e-08, 5.0138e-11, 1.60553e-08, 5.99464e-08, 1.30604e-07, 2.2685e-07, 3.47457e-07, 4.91148e-07, 6.56604e-07, 8.42471e-07, 1.04736e-06, 1.26987e-06, 1.50855e-06, 1.76196e-06, 2.02864e-06, 2.30712e-06, 2.59594e-06, 2.89363e-06, 3.19875e-06, 3.50984e-06, 3.82548e-06, 4.14428e-06, 4.46485e-06, 4.78584e-06, 5.10596e-06, 5.42391e-06, 5.73846e-06, 6.04842e-06, 6.35265e-06, 6.65003e-06, 6.93953e-06, 7.22015e-06, 7.49095e-06, 7.75105e-06, 7.99963e-06, 8.23592e-06, 8.45922e-06, 8.66889e-06, 8.86435e-06, 9.04509e-06, 9.21065e-06, 9.36065e-06, 9.49475e-06, 9.61269e-06, 9.71427e-06, 9.79934e-06, 9.86782e-06, 9.91969e-06, 9.95498e-06, 9.97378e-06, 9.97622e-06, 9.96251e-06, 9.93289e-06, 9.88764e-06, 9.82711e-06, 9.75168e-06, 9.66177e-06, 9.55785e-06, 9.44042e-06, 9.31e-06, 9.16716e-06, 9.0125e-06, 8.84663e-06, 8.6702e-06, 8.48386e-06, 8.2883e-06, 8.08421e-06, 7.8723e-06, 7.65329e-06, 7.4279e-06, 7.19686e-06, 6.9609e-06, 6.72075e-06, 6.47715e-06, 6.2308e-06, 5.98243e-06, 5.73273e-06, 5.48241e-06, 5.23214e-06, 4.98259e-06, 4.73439e-06, 4.48819e-06, 4.24457e-06, 4.00412e-06, 3.76741e-06, 3.53496e-06, 3.30729e-06, 3.08486e-06, 2.86815e-06, 2.65756e-06, 2.4535e-06, 2.25632e-06, 2.06635e-06, 1.88391e-06, 1.70926e-06, 1.54263e-06, 1.38424e-06, 1.23427e-06, 1.09285e-06, 9.60113e-07, 8.36131e-07, 7.20964e-07, 6.14635e-07, 5.17145e-07, 4.28461e-07, 3.48526e-07, 2.77258e-07, 2.14547e-07, 1.60262e-07, 1.14245e-07, 7.63215e-08, 4.62915e-08, 2.39377e-08, 9.02416e-09, 1.298e-09, 4.90465e-10, 6.31847e-09, 1.84858e-08, 3.66846e-08, 6.05965e-08, 8.9894e-08, 1.24242e-07, 1.63299e-07, 2.06718e-07, 2.54149e-07, 3.05238e-07, 3.59632e-07, 4.16976e-07, 4.76916e-07, 5.39102e-07, 6.03185e-07, 6.68823e-07, 7.35678e-07, 8.03417e-07, 8.71717e-07, 9.40263e-07, 1.00875e-06, 1.07687e-06, 1.14435e-06, 1.21091e-06, 1.27629e-06, 1.34023e-06, 1.40249e-06, 1.46286e-06, 1.52112e-06, 1.57708e-06, 1.63054e-06, 1.68134e-06, 1.72934e-06, 1.77438e-06, 1.81634e-06, 1.85512e-06, 1.89062e-06, 1.92275e-06, 1.95146e-06, 1.97669e-06, 1.99839e-06, 2.01656e-06, 2.03117e-06, 2.04223e-06, 2.04976e-06, 2.05377e-06, 2.05431e-06, 2.05144e-06, 2.0452e-06, 2.03567e-06, 2.02293e-06, 2.00707e-06, 1.98819e-06, 1.96639e-06, 1.94179e-06, 1.91451e-06, 1.88467e-06, 1.85241e-06, 1.81786e-06, 1.78116e-06, 1.74246e-06, 1.70191e-06, 1.65964e-06, 1.61583e-06, 1.57061e-06, 1.52414e-06, 1.47658e-06, 1.42808e-06, 1.37879e-06, 1.32886e-06, 1.27844e-06, 1.22767e-06, 1.17671e-06, 1.12569e-06, 1.07474e-06, 1.024e-06, 9.73608e-07, 9.23672e-07, 8.74318e-07, 8.25657e-07, 7.778e-07, 7.30847e-07, 6.84895e-07, 6.40036e-07, 5.96353e-07, 5.53925e-07, 5.12824e-07, 4.73115e-07, 4.34857e-07, 3.98103e-07, 3.629e-07, 3.29287e-07, 2.97298e-07, 2.6696e-07, 2.38295e-07, 2.11317e-07, 1.86037e-07, 1.62457e-07, 1.40577e-07, 1.20388e-07, 1.01878e-07, 8.50293e-08, 6.982e-08, 5.62231e-08, 4.42074e-08, 3.37378e-08, 2.47753e-08, 1.72773e-08, 1.11979e-08, 6.48828e-09, 3.09676e-09, 9.69195e-10, 4.92116e-11, 2.78468e-10, 1.59693e-09, 3.94312e-09, 7.25439e-09, 1.14672e-08, 1.65173e-08, 2.234e-08, 2.88705e-08, 3.6044e-08, 4.3796e-08, 5.20624e-08, 6.07799e-08, 6.98859e-08, 7.93191e-08, 8.90194e-08, 9.8928e-08, 1.08988e-07, 1.19143e-07, 1.29341e-07, 1.39529e-07, 1.49658e-07, 1.5968e-07, 1.69552e-07, 1.79229e-07, 1.88671e-07, 1.97842e-07, 2.06705e-07, 2.15227e-07, 2.2338e-07, 2.31134e-07, 2.38465e-07, 2.45351e-07, 2.51773e-07, 2.57712e-07, 2.63154e-07, 2.68087e-07, 2.72501e-07, 2.76388e-07, 2.79745e-07, 2.82567e-07, 2.84855e-07, 2.86609e-07, 2.87833e-07, 2.88533e-07, 2.88716e-07, 2.88391e-07, 2.87568e-07, 2.8626e-07, 2.8448e-07, 2.82243e-07, 2.79566e-07, 2.76465e-07, 2.7296e-07, 2.69069e-07, 2.64812e-07, 2.60211e-07, 2.55285e-07, 2.50058e-07, 2.44552e-07, 2.38789e-07, 2.32791e-07, 2.26582e-07, 2.20184e-07, 2.1362e-07, 2.06913e-07, 2.00086e-07, 1.93159e-07, 1.86156e-07, 1.79096e-07, 1.72002e-07, 1.64893e-07, 1.57789e-07, 1.50708e-07, 1.43669e-07, 1.36689e-07, 1.29786e-07, 1.22974e-07, 1.16268e-07, 1.09683e-07, 1.03232e-07, 9.69275e-08, 9.07801e-08, 8.48006e-08, 7.89983e-08, 7.3382e-08, 6.7959e-08, 6.27362e-08, 5.77192e-08, 5.2913e-08, 4.83215e-08, 4.39478e-08, 3.97942e-08, 3.58622e-08, 3.21523e-08, 2.86646e-08, 2.53981e-08, 2.23514e-08, 1.95221e-08, 1.69076e-08, 1.45042e-08, 1.23081e-08, 1.03146e-08, 8.51882e-09, 6.91521e-09, 5.4979e-09, 4.26064e-09, 3.19684e-09, 2.2996e-09, 1.56177e-09, 9.7599e-10, 5.34692e-10, 2.30167e-10, 5.45889e-11, 4.89629e-14, 5.85888e-11, 2.22232e-10, 4.83014e-10, 8.33012e-10, 1.26437e-09, 1.76934e-09, 2.34026e-09, 2.96966e-09, 3.65019e-09, 4.37472e-09, 5.13629e-09, 5.9282e-09, 6.74394e-09, 7.5773e-09, 8.42229e-09, 9.27322e-09, 1.01247e-08, 1.09715e-08, 1.18089e-08, 1.26323e-08, 1.34376e-08, 1.42207e-08, 1.49781e-08, 1.57065e-08, 1.64028e-08, 1.70644e-08, 1.76889e-08, 1.82741e-08, 1.88183e-08, 1.93198e-08, 1.97775e-08, 2.01904e-08, 2.05576e-08, 2.08787e-08, 2.11535e-08, 2.13818e-08, 2.15639e-08, 2.17002e-08, 2.17911e-08, 2.18376e-08, 2.18404e-08, 2.18006e-08, 2.17195e-08, 2.15984e-08, 2.14388e-08, 2.12422e-08, 2.10104e-08, 2.07449e-08, 2.04477e-08, 2.01206e-08, 1.97656e-08, 1.93846e-08, 1.89796e-08, 1.85525e-08, 1.81055e-08, 1.76404e-08, 1.71594e-08, 1.66643e-08, 1.61572e-08, 1.564e-08, 1.51144e-08, 1.45825e-08, 1.40459e-08, 1.35064e-08, 1.29656e-08, 1.24251e-08, 1.18866e-08, 1.13513e-08, 1.08208e-08, 1.02962e-08, 9.77892e-09, 9.26998e-09, 8.77047e-09, 8.28137e-09, 7.80358e-09, 7.33791e-09, 6.88508e-09, 6.44576e-09, 6.02051e-09, 5.60983e-09, 5.21414e-09, 4.83377e-09, 4.469e-09, 4.12003e-09, 3.78699e-09, 3.46996e-09, 3.16895e-09, 2.8839e-09, 2.61471e-09, 2.36123e-09, 2.12325e-09, 1.90053e-09, 1.69277e-09, 1.49965e-09, 1.3208e-09, 1.15582e-09, 1.00429e-09, 8.65767e-10, 7.39773e-10, 6.25821e-10, 5.23405e-10, 4.32007e-10, 3.511e-10, 2.80149e-10, 2.18613e-10, 1.65952e-10, 1.21625e-10, 8.50922e-11, 5.5821e-11, 3.32841e-11, 1.6963e-11, 6.34935e-12, 9.46782e-13, 2.71967e-13, 3.85609e-12, 1.12459e-11, 2.20048e-11, 3.57136e-11, 5.19713e-11, 7.03957e-11, 9.0624e-11, 1.12313e-10, 1.35139e-10, 1.58799e-10, 1.8301e-10, 2.07509e-10, 2.32052e-10, 2.56417e-10, 2.80399e-10, 3.03813e-10, 3.26492e-10, 3.4829e-10, 3.69074e-10, 3.88731e-10, 4.07163e-10, 4.24288e-10, 4.4004e-10, 4.54365e-10, 4.67223e-10, 4.78588e-10, 4.88444e-10, 4.96787e-10, 5.03623e-10, 5.08968e-10, 5.12845e-10, 5.15287e-10, 5.16331e-10, 5.16024e-10, 5.14415e-10, 5.11561e-10, 5.07522e-10, 5.02361e-10, 4.96143e-10, 4.88938e-10, 4.80815e-10, 4.71846e-10, 4.62103e-10, 4.51659e-10, 4.40584e-10, 4.2895e-10, 4.16827e-10, 4.04284e-10, 3.91389e-10, 3.78205e-10, 3.64796e-10, 3.51222e-10, 3.3754e-10, 3.23807e-10, 3.10072e-10, 2.96386e-10, 2.82794e-10, 2.69339e-10, 2.5606e-10, 2.42994e-10, 2.30173e-10, 2.17627e-10, 2.05383e-10, 1.93464e-10, 1.81892e-10, 1.70684e-10, 1.59855e-10, 1.49418e-10, 1.39381e-10, 1.29753e-10, 1.20538e-10, 1.11739e-10, 1.03357e-10, 9.53904e-11, 8.78362e-11, 8.069e-11, 7.39455e-11, 6.75954e-11, 6.16309e-11, 5.60424e-11, 5.08191e-11, 4.59496e-11, 4.14215e-11, 3.72222e-11, 3.33383e-11, 2.97563e-11, 2.64622e-11, 2.3442e-11, 2.06815e-11, 1.81667e-11, 1.58835e-11, 1.3818e-11, 1.19565e-11, 1.02855e-11, 8.79205e-12, 7.46329e-12, 6.28691e-12, 5.251e-12, 4.34412e-12, 3.55531e-12, 2.87411e-12, 2.29058e-12, 1.79531e-12, 1.37941e-12, 1.03454e-12, 7.52856e-13, 5.27071e-13, 3.50401e-13, 2.16567e-13, 1.19782e-13, 5.47381e-14, 1.65876e-14, 9.24666e-16, 3.76703e-15, 2.15353e-14, 5.10319e-14, 8.94199e-14, 1.34201e-13, 1.83192e-13, 2.34507e-13, 2.8653e-13, 3.37899e-13, 3.8748e-13, 4.34349e-13, 4.77775e-13, 5.17193e-13, 5.52196e-13, 5.82509e-13, 6.07977e-13, 6.28548e-13, 6.44259e-13, 6.55223e-13, 6.61616e-13, 6.63664e-13, 6.61634e-13, 6.55826e-13, 6.46562e-13, 6.34176e-13, 6.19013e-13, 6.01419e-13, 5.81737e-13, 5.60303e-13, 5.37438e-13, 5.13453e-13, 4.88639e-13, 4.63269e-13, 4.37595e-13, 4.11847e-13, 3.86236e-13, 3.60947e-13, 3.36146e-13, 3.11974e-13, 2.88555e-13, 2.6599e-13, 2.44363e-13, 2.23738e-13, 2.04163e-13, 1.85672e-13, 1.68283e-13, 1.52004e-13, 1.36828e-13, 1.22741e-13, 1.09719e-13, 9.7732e-14, 8.67427e-14, 7.67093e-14, 6.75861e-14, 5.93243e-14, 5.18732e-14, 4.51812e-14, 3.91957e-14, 3.38647e-14, 2.91368e-14, 2.49619e-14, 2.12915e-14, 1.8079e-14, 1.528e-14, 1.28527e-14, 1.07578e-14, 8.95862e-15, 7.42112e-15, 6.11404e-15, 5.00877e-15, 4.07929e-15, 3.30208e-15, 2.65602e-15, 2.12226e-15, 1.68408e-15, 1.32674e-15, 1.03734e-15, 8.04652e-16, 6.18969e-16, 4.71969e-16, 3.5656e-16, 2.66746e-16, 1.97497e-16, 1.44625e-16, 1.04675e-16, 7.4821e-17, 5.27728e-17, 3.66933e-17, 2.5124e-17, 1.69196e-17, 1.1192e-17, 7.26045e-18, 4.61105e-18, 2.86115e-18, 1.73051e-18, 1.01748e-18, 5.79726e-19, 3.18885e-19, 1.68584e-19, 8.51974e-20, 4.08877e-20, 1.84824e-20, 7.78812e-21, 3.01885e-21, 1.05773e-21, 3.27143e-22, 8.63936e-23, 1.85547e-23, 3.00511e-24, 3.23412e-25, 1.8245e-26, 3.16799e-28, 3.0961e-31, 0 }; #endif
17.448518
87
0.652898
[ "vector" ]
543e66a7c26bc3767bed37d8b0b2998967df55d6
4,603
h
C
ClassLibrary1/Ktex.h
Akarinnnnn/KTEXlib.NET
ed6ffea75b1eac989d6fa71409b98916f1028307
[ "WTFPL" ]
null
null
null
ClassLibrary1/Ktex.h
Akarinnnnn/KTEXlib.NET
ed6ffea75b1eac989d6fa71409b98916f1028307
[ "WTFPL" ]
null
null
null
ClassLibrary1/Ktex.h
Akarinnnnn/KTEXlib.NET
ed6ffea75b1eac989d6fa71409b98916f1028307
[ "WTFPL" ]
null
null
null
#pragma once #pragma unmanaged #include <TEXFileOperation.h> #pragma managed namespace ktexlib { namespace NET { //native KTEX exception will not caught by .NET framework ///<summary>异常类</summary> public ref class KTEXException : System::Exception { public: KTEXException(ktexlib::KTEXFileOperation::ktex_exception e); ///<summary>异常信息</summary> property System::String^ Message { System::String^ get() override; } property unsigned int KtexErrorID { unsigned int get(); } private: ktexlib::KTEXFileOperation::ktex_exception& native; }; ///<summary>空类,保留</summary> public ref struct RgbaImage { }; ///<summary>材质对应平台</summary> public enum class Platform//platform { ///<summary>OpenGL, mainly PC</summary> opengl = 12, ///<summary>Xbox 360</summary> xb360 = 11, ///<summary>PlayStation 3</summary> ps3 = 10, ///<summary>不应使用</summary> unk = 0 }; ///<summary>格式</summary> public enum class PixelFromat //pixel form { ///<summary>ARGB</summary> ARGB = 4, ///<summary>bc1</summary> DXT1 = 0, ///<summary>bc2</summary> DXT3 = 1, ///<summary>bc3,default</summary> DXT5 = 2, ///<summary>不应使用</summary> unk = 7 }; ///<summary>材质类型</summary> public enum class TextureType { ///<summary>1d</summary> d1 = 1, ///<summary>2d,默认</summary> d2 = 2, ///<summary>3d</summary> d3 = 3, ///<summary>cube mapped</summary> cube = 4 }; ///<summary>ktex信息</summary> public ref struct KtexInfo { PixelFromat PixelFormat; Platform PlatForm; TextureType TextureType; unsigned short MipMapCount; unsigned char Flags; KtexInfo(); KtexInfo(int pixfmt, int platfrm, int _textyp, unsigned short mips, unsigned char f); ///<summary>将该实例的信息转换为string</summary> virtual System::String^ ToString() override; }; ///<summary>ktex处理类</summary> public ref class Ktex : System::Collections::Generic::IEnumerable<System::Windows::Media::Imaging::BitmapSource^> { public: ///<summary>默认构造函数,可用于生成ktex</summary> Ktex(); ///<summary>加载指定的ktex文件,用于读取</summary> Ktex(System::String^ KTEXPath); ~Ktex(); ///<summary>加载ktex</summary> ///<param name="KTEXpath">文件路径</param> void Load(System::String^ KTEXpath); ///<summary>添加一张mipmap</summary> ///<param name="Image">WPF图像</param> void Append(System::Windows::Media::Imaging::BitmapSource ^ Image); ///<summary>添加一张指定了pitch值的mipmap</summary> ///<param name="Image">WPF图像</param> ///<param name="pitch">指定的pitch</param> void AddAt(System::Windows::Media::Imaging::BitmapSource ^ Image, System::UInt16 pitch); ///<summary>获取主mipmap</summary> System::Windows::Media::Imaging::BitmapSource^ MainMipmap(); ///<summary>根据已有的rgba图像数据转换为ktex</summary> void Convert(); ///<summary>索引器</summary> property System::Windows::Media::Imaging::BitmapSource^ indexer[unsigned short] { System::Windows::Media::Imaging::BitmapSource ^ get(unsigned short); }; ///<summary>获取和设置ktex信息</summary> property KtexInfo^ Info { KtexInfo^ get(); void set(KtexInfo^ value); } ///<summary>获取和设置转换产生的ktex路径</summary> property System::String^ OutPut {System::String^ get(); void set(System::String^); }; ///<summary>遍历器</summary> ref class KtexEnumerator : System::Collections::Generic::IEnumerator<System::Windows::Media::Imaging::BitmapSource^> { public: ///<summary>构造遍历器</summary> KtexEnumerator(Ktex^ parent); ~KtexEnumerator(); ///<summary>将当前值移动到下一个值</summary> virtual bool MoveNext(); ///<summary>重置遍历器</summary> virtual void Reset(); ///<summary>当前值,不可通过赋值修改</summary> property virtual System::Windows::Media::Imaging::BitmapSource^ Current { virtual System::Windows::Media::Imaging::BitmapSource^ get(); }; ///<summary>System.Collection.IEnumerable的Current属性</summary> property virtual System::Object^ cur_nongeneric { virtual System::Object^ get() = System::Collections::IEnumerator::Current::get; }; private: Ktex^ parent; unsigned int i = 0; }; ///<summary>获取遍历器</summary> virtual System::Collections::Generic::IEnumerator<System::Windows::Media::Imaging::BitmapSource^>^ GetEnumerator(); ///<summary>获取非泛型版本的遍历器</summary> virtual System::Collections::IEnumerator^ _begin() = System::Collections::IEnumerable::GetEnumerator; ///<summary>可获取ktex信息和当前输出路径</summary> virtual System::String^ ToString() override; private: ktexlib::KTEXFileOperation::KTEX* native; }; } }
25.430939
119
0.662829
[ "object", "3d" ]
544196534c60d73d1a7c07706a5bb503cef4f520
2,993
h
C
UdeskSDK/UDChatMessage/UDIM/Models/Manager/UdeskMessageManager.h
iStarEternal/UdeskSDK-iOS
a48ab2dc662bb236250b81518db3b67d3d272fb6
[ "MIT" ]
61
2016-03-08T05:26:51.000Z
2022-03-18T10:04:28.000Z
UdeskSDK/UDChatMessage/UDIM/Models/Manager/UdeskMessageManager.h
iStarEternal/UdeskSDK-iOS
a48ab2dc662bb236250b81518db3b67d3d272fb6
[ "MIT" ]
57
2016-05-25T02:52:23.000Z
2022-03-29T07:53:19.000Z
UdeskSDK/UDChatMessage/UDIM/Models/Manager/UdeskMessageManager.h
iStarEternal/UdeskSDK-iOS
a48ab2dc662bb236250b81518db3b67d3d272fb6
[ "MIT" ]
39
2016-02-01T07:24:20.000Z
2022-03-03T01:19:09.000Z
// // UdeskMessageManager.h // UdeskSDK // // Created by xuchen on 2019/1/18. // Copyright © 2019 Udesk. All rights reserved. // #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> @class UdeskSetting; @class UdeskAgent; @class UdeskMessage; @class UdeskLocationModel; @class UdeskGoodsModel; @interface UdeskMessageManager : NSObject /** 更新消息 */ @property (nonatomic, copy) void(^didUpdateMessagesBlock)(NSArray *messages); /** 更新更多消息 */ @property (nonatomic, copy) void(^didUpdateMoreMessagesBlock)(NSArray *messages); /** 更新单个消息 */ @property (nonatomic, copy) void(^didUpdateMessageAtIndexPathBlock)(NSIndexPath *indexPath); /** 更新客服信息 */ @property (nonatomic, copy) void(^updateAgentInfo)(UdeskMessage *message); /** 是否需要显示下拉加载 */ @property (nonatomic, assign) BOOL isShowRefresh; /** 客服信息 */ @property (nonatomic, strong) UdeskAgent *agentModel; /** sdk配置项 */ @property (nonatomic, strong) UdeskSetting *sdkSetting; /** 消息数据 */ @property (nonatomic, strong, readonly) NSArray *messagesArray; /** 机器人会话 */ @property (nonatomic, assign) BOOL isRobotSession; - (instancetype)initWithSetting:(UdeskSetting *)setting; //获取db消息 - (void)fetchMessages; //加载更多DB消息 - (void)fetchNextPageMessages; //获取servers消息 - (void)fetchServersMessages; //添加直接留言文案 - (void)addLeaveGuideMessageToArray; //更新排队事件 - (void)updateQueueMessageWithContent:(NSString *)contentText; //移除排队事件 - (void)removeQueueInArray; //添加消息到数组 - (void)addMessageToArray:(NSArray *)messageArray; //收到撤回消息 - (void)receiveRollbackWithMessage:(UdeskMessage *)message; //会话已关闭 - (void)sessionClosed; /* 发送消息 */ - (void)sendRobotMessage:(UdeskMessage *)message completion:(void(^)(UdeskMessage *message))completion; //发送文本消息 - (void)sendTextMessage:(NSString *)text completion:(void(^)(UdeskMessage *message))completion; //发送图片消息 - (void)sendImageMessage:(UIImage *)image progress:(void(^)(NSString *key,float percent))progress completion:(void(^)(UdeskMessage *message))completion; //发送gif图片消息 - (void)sendGIFImageMessage:(NSData *)gifData progress:(void(^)(NSString *key,float percent))progress completion:(void(^)(UdeskMessage *message))completion; //发送视频消息 - (void)sendVideoMessage:(NSData *)videoData progress:(void(^)(NSString *key,float percent))progress completion:(void(^)(UdeskMessage *message))completion ; //发送语音消息 - (void)sendVoiceMessage:(NSString *)voicePath voiceDuration:(NSString *)voiceDuration completion:(void (^)(UdeskMessage *message))completion; //发送地理位置消息 - (void)sendLocationMessage:(UdeskLocationModel *)model completion:(void(^)(UdeskMessage *message))completion; //发送商品消息 - (void)sendGoodsMessage:(UdeskGoodsModel *)model completion:(void(^)(UdeskMessage *message))completion; //获取GIF Message - (UdeskMessage *)gifMessageWithData:(NSData *)gifData; - (UdeskMessage *)videoMessageWithVideoData:(NSData *)videoData; - (UdeskMessage *)voiceMessageWithPath:(NSString *)voicePath duration:(NSString *)duration; - (UdeskMessage *)locationMessageWithModel:(UdeskLocationModel *)locationModel; @end
35.211765
156
0.763114
[ "model" ]
54465e9d0b0621ee58fe5a15f51634e204ae9f13
9,279
c
C
backup/CEED/BP1/massSolveHex3D.c
noelchalmers/benchparanumal
96c22154a13348c3f34df7483c6977abb5aaa718
[ "MIT" ]
null
null
null
backup/CEED/BP1/massSolveHex3D.c
noelchalmers/benchparanumal
96c22154a13348c3f34df7483c6977abb5aaa718
[ "MIT" ]
null
null
null
backup/CEED/BP1/massSolveHex3D.c
noelchalmers/benchparanumal
96c22154a13348c3f34df7483c6977abb5aaa718
[ "MIT" ]
1
2019-11-24T17:23:29.000Z
2019-11-24T17:23:29.000Z
/* The MIT License (MIT) Copyright (c) 2017 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "massHex3D.h" void massOperator3D(solver_t *solver, dfloat lambda, occa::memory &o_q, occa::memory &o_Aq, const char *options){ mesh_t *mesh = solver->mesh; // occaTimerTic(mesh->device,"AxKernel"); dfloat *sendBuffer = solver->sendBuffer; dfloat *recvBuffer = solver->recvBuffer; // compute local element operations and store result in o_Aq if(strstr(options, "CONTINUOUS")){ ogs_t *nonHalo = solver->nonHalo; ogs_t *halo = solver->halo; // Ax for C0 halo elements (on default stream - otherwise local Ax swamps) mesh->device.setStream(solver->dataStream); mesh->device.finish(); mesh->device.setStream(solver->defaultStream); mesh->device.finish(); dfloat zero = 0; solver->o_pAp.copyFrom(&zero); { if(solver->NglobalGatherElements){ solver->partialAxKernel(solver->NglobalGatherElements, solver->o_globalGatherElementList, solver->o_gjGeo, solver->o_gjI, o_q, o_Aq, solver->o_grad, solver->o_Aw); } if(halo->Ngather){ mesh->gatherKernel(halo->Ngather, halo->o_gatherOffsets, halo->o_gatherLocalIds, o_Aq, halo->o_gatherTmp); } if(halo->Ngather){ halo->o_gatherTmp.copyTo(halo->gatherTmp); } // Ax for C0 internal elements if(solver->NlocalGatherElements){ solver->partialAxKernel(solver->NlocalGatherElements, solver->o_localGatherElementList, solver->o_gjGeo, solver->o_gjI, o_q, o_Aq, solver->o_grad, solver->o_Aw); } } // C0 halo gather-scatter (on data stream) if(halo->Ngather){ occa::streamTag tag; // MPI based gather scatter using libgs gsParallelGatherScatter(halo->gatherGsh, halo->gatherTmp, dfloatString, "add"); // copy totally gather halo data back from HOST to DEVICE halo->o_gatherTmp.copyFrom(halo->gatherTmp); // wait for async copy tag = mesh->device.tagStream(); mesh->device.waitFor(tag); // do scatter back to local nodes mesh->scatterKernel(halo->Ngather, halo->o_gatherOffsets, halo->o_gatherLocalIds, halo->o_gatherTmp, o_Aq); // make sure the scatter has finished on the data stream tag = mesh->device.tagStream(); mesh->device.waitFor(tag); } // finalize gather using local and global contributions mesh->device.setStream(solver->defaultStream); #if 0 if(nonHalo->Ngather) mesh->gatherScatterKernel(nonHalo->Ngather, nonHalo->o_gatherOffsets, nonHalo->o_gatherLocalIds, o_Aq); #endif } else{ } // occaTimerToc(mesh->device,"AxKernel"); } dfloat massScaledAdd(solver_t *solver, dfloat alpha, occa::memory &o_a, dfloat beta, occa::memory &o_b){ mesh_t *mesh = solver->mesh; int Ntotal = mesh->Nelements*mesh->Np; occaTimerTic(mesh->device,"scaledAddKernel"); // b[n] = alpha*a[n] + beta*b[n] n\in [0,Ntotal) mesh->scaledAddKernel(Ntotal, alpha, o_a, beta, o_b); occaTimerToc(mesh->device,"scaledAddKernel"); } dfloat massWeightedInnerProduct(solver_t *solver, occa::memory &o_w, occa::memory &o_a, occa::memory &o_b, const char *options){ mesh_t *mesh = solver->mesh; dfloat *tmp = solver->tmp; int Nblock = solver->Nblock; int Ntotal = mesh->Nelements*mesh->Np; occa::memory &o_tmp = solver->o_tmp; occaTimerTic(mesh->device,"weighted inner product2"); // printf("Nblock = %d, Ntotal = %d, ratio = %lf\n", Nblock, Ntotal, ((double)Ntotal)/Nblock); if(strstr(options,"CONTINUOUS")||strstr(options, "PROJECT")) mesh->weightedInnerProduct2Kernel(Ntotal, o_w, o_a, o_b, o_tmp); else mesh->innerProductKernel(Ntotal, o_a, o_b, o_tmp); occaTimerToc(mesh->device,"weighted inner product2"); o_tmp.copyTo(tmp); dfloat wab = 0; for(int n=0;n<Nblock;++n){ wab += tmp[n]; } dfloat globalwab = 0; MPI_Allreduce(&wab, &globalwab, 1, MPI_DFLOAT, MPI_SUM, MPI_COMM_WORLD); return globalwab; } void massPreconditioner3D(solver_t *solver, occa::memory &o_r, occa::memory &o_zP, occa::memory &o_z, const char *options){ mesh_t *mesh = solver->mesh; precon_t *precon = solver->precon; ogs_t *ogs = solver->ogs; // C0 Gather ScatterTri info dfloat *sendBuffer = solver->sendBuffer; dfloat *recvBuffer = solver->recvBuffer; if(strstr(options, "JACOBI")){ int Ntotal = mesh->Np*mesh->Nelements; // Jacobi preconditioner occaTimerTic(mesh->device,"dotDivideKernel"); mesh->dotDivideKernel(Ntotal, o_r, precon->o_diagA, o_z); occaTimerToc(mesh->device,"dotDivideKernel"); } else // turn off preconditioner o_z.copyFrom(o_r); } int massSolveHex3D(solver_t *solver, dfloat lambda, occa::memory &o_r, occa::memory &o_x, const int maxIterations, const char *options){ mesh_t *mesh = solver->mesh; int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); // convergence tolerance (currently absolute) const dfloat tol = 1e-10; occa::memory &o_p = solver->o_p; occa::memory &o_z = solver->o_z; occa::memory &o_zP = solver->o_zP; occa::memory &o_Ap = solver->o_Ap; occa::memory &o_Ax = solver->o_Ax; occa::streamTag startTag = mesh->device.tagStream(); occaTimerTic(mesh->device,"PCG"); mesh->device.setStream(solver->defaultStream); // gather-scatter if(strstr(options,"CONTINUOUS")||strstr(options, "PROJECT")) massParallelGatherScatter(mesh, solver->ogs, o_r, o_r, dfloatString, "add"); // compute A*x massOperator3D(solver, lambda, o_x, o_Ax, options); // subtract r = b - A*x massScaledAdd(solver, -1.f, o_Ax, 1.f, o_r); occaTimerTic(mesh->device,"Preconditioner"); if(strstr(options,"PCG")){ // Precon^{-1} (b-A*x) massPreconditioner3D(solver, o_r, o_zP, o_z, options); // r => rP => zP => z // p = z o_p.copyFrom(o_z); // PCG } else{ // p = r o_p.copyFrom(o_r); // CG } occaTimerToc(mesh->device,"Preconditioner"); // dot(r,r) dfloat rdotr0 = massWeightedInnerProduct(solver, solver->o_invDegree, o_r, o_r, options); dfloat rdotz0 = massWeightedInnerProduct(solver, solver->o_invDegree, o_r, o_z, options); dfloat rdotr1 = 0; dfloat rdotz1 = 0; int Niter = 0; dfloat alpha, beta, pAp; while(Niter<maxIterations && rdotr0>(tol*tol)){ // A*p massOperator3D(solver, lambda, o_p, o_Ap, options); // dot(p,A*p) pAp = massWeightedInnerProduct(solver, solver->o_invDegree, o_p, o_Ap, options); if(strstr(options,"PCG")) // alpha = dot(r,z)/dot(p,A*p) alpha = rdotz0/pAp; else // alpha = dot(r,r)/dot(p,A*p) alpha = rdotr0/pAp; // x <= x + alpha*p massScaledAdd(solver, alpha, o_p, 1.f, o_x); // r <= r - alpha*A*p massScaledAdd(solver, -alpha, o_Ap, 1.f, o_r); // dot(r,r) rdotr1 = massWeightedInnerProduct(solver, solver->o_invDegree, o_r, o_r, options); occaTimerTic(mesh->device,"Preconditioner"); if(strstr(options,"PCG")){ // z = Precon^{-1} r massPreconditioner3D(solver, o_r, o_zP, o_z, options); // dot(r,z) rdotz1 = massWeightedInnerProduct(solver, solver->o_invDegree, o_r, o_z, options); // flexible pcg beta = (z.(-alpha*Ap))/zdotz0 if(strstr(options,"FLEXIBLE")){ dfloat zdotAp = massWeightedInnerProduct(solver, solver->o_invDegree, o_z, o_Ap, options); beta = -alpha*zdotAp/rdotz0; } else{ beta = rdotz1/rdotz0; } // p = z + beta*p massScaledAdd(solver, 1.f, o_z, beta, o_p); // switch rdotz0 <= rdotz1 rdotz0 = rdotz1; } else{ beta = rdotr1/rdotr0; // p = r + beta*p massScaledAdd(solver, 1.f, o_r, beta, o_p); } occaTimerToc(mesh->device,"Preconditioner"); // switch rdotr0 <= rdotr1 rdotr0 = rdotr1; #if 0 if(rank==0) printf("iter=%05d pAp = %g norm(r) = %g\n", Niter, pAp, sqrt(rdotr0)); #endif ++Niter; }; occaTimerToc(mesh->device,"PCG"); occa::streamTag stopTag = mesh->device.tagStream(); double elapsed = mesh->device.timeBetween(startTag, stopTag); double gElapsed; MPI_Allreduce(&elapsed, &gElapsed, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); occa::printTimer(); return Niter; }
28.81677
136
0.671516
[ "mesh" ]
5453a4ad1a783fc6f4146b29cab7ac9dd7c71960
827
h
C
src/equation.h
Kingsford-Group/catfish
acef05cfb1077d613e0f742a31b58e196ce3db29
[ "BSD-3-Clause" ]
3
2016-11-16T19:08:35.000Z
2018-02-04T22:08:26.000Z
src/equation.h
Kingsford-Group/catfish
acef05cfb1077d613e0f742a31b58e196ce3db29
[ "BSD-3-Clause" ]
null
null
null
src/equation.h
Kingsford-Group/catfish
acef05cfb1077d613e0f742a31b58e196ce3db29
[ "BSD-3-Clause" ]
2
2017-12-08T23:42:34.000Z
2018-06-05T21:42:48.000Z
/* Part of Catfish (c) 2017 by Mingfu Shao, Carl Kingsford, and Carnegie Mellon University. See LICENSE for licensing. */ #ifndef __EQUATION_H__ #define __EQUATION_H__ #include <vector> using namespace std; class equation { public: equation(); equation(double); equation(const vector<int> &, const vector<int> &); equation(const vector<int> &, const vector<int> &, double); public: int print(int index); public: vector<int> s; // subs vector<int> t; // subt double e; // erro int f; // 3: resolve vertex 2: fully, 1: partly, 0: none int a; // # adjacent merges int d; // # distant merges int w; // weight }; bool equation_cmp1(const equation &x, const equation &y); bool equation_cmp2(const equation &x, const equation &y); bool equation_cmp3(const equation &x, const equation &y); #endif
20.170732
73
0.688029
[ "vector" ]
2d0c1e277fc9a7c14e4376ed3b4f7b769c2e6a22
885
h
C
capaffine.h
mteg/capoc
35d33e1fb9b5354e96bcf771492d861592f75eb6
[ "Apache-2.0" ]
2
2021-08-01T14:17:38.000Z
2021-12-27T13:52:18.000Z
capaffine.h
mteg/capoc
35d33e1fb9b5354e96bcf771492d861592f75eb6
[ "Apache-2.0" ]
null
null
null
capaffine.h
mteg/capoc
35d33e1fb9b5354e96bcf771492d861592f75eb6
[ "Apache-2.0" ]
2
2019-05-13T12:10:14.000Z
2019-11-18T11:26:52.000Z
// // Created by mteg on 5/6/18. // #ifndef CAPOC2_CAPAFFINE_H #define CAPOC2_CAPAFFINE_H #include <vector> #include "captypes.h" class capAffineMatrix { public: capAffineMatrix(capAffineMatrix *c); float m[16]; capAffineMatrix(); void setUnit(); void setScale(float s); void setZero(); void setTranslation(float, float, float); void setRotation(float, int); void compose(capAffineMatrix*); void dumpWith(void *ptr, int (*print)(void *, const char *, ...)); void dump(); void transform(float *v); void transformVector(float *v); float getScale(); static float det33(float a[3][3]); int invert(); void transpose(); void setFrom(const capAffineMatrix *pMatrix); static capAffineMatrix *findBetween(std::vector<capGenericPoint> ca, std::vector<capGenericPoint> cb); }; #endif //CAPOC2_CAPAFFINE_H
19.23913
106
0.671186
[ "vector", "transform" ]
2d0ebbf4273219678b0c7d5c8c7c674583c79efb
1,566
h
C
CAOS-win-32bit-mingw-freeglut-eclipse/src/Scene.class.h
nils91/caos
779917b5cd1d990e41470eceda7bbcbfef8ac468
[ "MIT" ]
null
null
null
CAOS-win-32bit-mingw-freeglut-eclipse/src/Scene.class.h
nils91/caos
779917b5cd1d990e41470eceda7bbcbfef8ac468
[ "MIT" ]
null
null
null
CAOS-win-32bit-mingw-freeglut-eclipse/src/Scene.class.h
nils91/caos
779917b5cd1d990e41470eceda7bbcbfef8ac468
[ "MIT" ]
null
null
null
/* * Scene..class.h * * Created on: 11.12.2017 * Author: Nils */ #ifndef SCENE_CLASS_H_ #define SCENE_CLASS_H_ //Includes for OpenGL #include <windows.h> #include <GL/glut.h> #include <GL/gl.h> #include <GL/glu.h> //c++ includes #include <vector> //own includes #include "Scene.class.h" #include "GameComponent.class.h" namespace caos { class Scene { private: protected: std::vector<GameComponent *> game_components; virtual void init_components(void)=0; virtual void init(void)=0; virtual void update(float dtime)=0; virtual void draw(float dtime)=0; virtual void on_reshape(GLsizei w, GLsizei h); virtual void on_keyboard(unsigned char key, int x, int y); virtual void on_mouse(int button, int state, int x, int y); virtual void on_mousemove(int x, int y); virtual void on_timer(int value); virtual void on_idle(void); virtual void on_mousewindowtransition(int state); void add_game_component(GameComponent * game_component); void delete_game_component(GameComponent * game_component); public: Scene(); virtual ~Scene(); void pre_init(void); void pre_update(float dtime); void pre_draw(float dtime); void pre_on_reshape(GLsizei w, GLsizei h); void pre_on_keyboard(unsigned char key, int x, int y); void pre_on_mouse(int button, int state, int x, int y); void pre_on_mousemove(int x, int y); void pre_on_timer(int value); void pre_on_idle(void); void pre_on_mousewindowtransition(int state); }; } /* namespace caos */ #endif /* SCENE_CLASS_H_ */
22.695652
61
0.703704
[ "vector" ]
2d1d5a3eb5825352714412aa611fca99a75ea32d
5,092
h
C
LibCarla/source/carla/streaming/low_level/tcp/ServerSession.h
nsubiron/libcarla
4d7a47757c9d05f4a7192592e367e0d4ff08131d
[ "MIT" ]
6
2018-06-26T09:58:17.000Z
2021-09-08T13:44:30.000Z
LibCarla/source/carla/streaming/low_level/tcp/ServerSession.h
nsubiron/libcarla
4d7a47757c9d05f4a7192592e367e0d4ff08131d
[ "MIT" ]
null
null
null
LibCarla/source/carla/streaming/low_level/tcp/ServerSession.h
nsubiron/libcarla
4d7a47757c9d05f4a7192592e367e0d4ff08131d
[ "MIT" ]
1
2019-06-22T18:17:07.000Z
2019-06-22T18:17:07.000Z
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma // de Barcelona (UAB). // // This work is licensed under the terms of the MIT license. // For a copy, see <https://opensource.org/licenses/MIT>. #pragma once #include "carla/Debug.h" #include "carla/Logging.h" #include "carla/streaming/Message.h" #include "carla/streaming/low_level/Types.h" #include "carla/streaming/low_level/tcp/Timeout.h" #include <boost/asio/deadline_timer.hpp> #include <boost/asio/io_service.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/read.hpp> #include <boost/asio/strand.hpp> #include <boost/asio/write.hpp> #include <array> #include <memory> namespace carla { namespace streaming { namespace low_level { namespace tcp { namespace detail { static std::atomic_size_t SESSION_COUNTER{0u}; } // namespace detail /// A TCP server session. When a session opens, it reads from the socket a /// stream id object and passes itself to the callback functor. The session /// closes itself after @a timeout of inactivity is met. class ServerSession : public std::enable_shared_from_this<ServerSession>, private boost::noncopyable { public: using socket_type = boost::asio::ip::tcp::socket; using duration_type = timeout_type; explicit ServerSession(boost::asio::io_service &io_service, duration_type timeout) : _session_id(detail::SESSION_COUNTER++), _socket(io_service), _timeout(timeout), _deadline(io_service), _strand(io_service) {} ~ServerSession() { _deadline.cancel(); } /// Starts the session and calls @a callback after successfully reading the /// stream id. /// /// @pre Callback function signature: /// `void(std::shared_ptr<ServerSession>)`. template <typename Functor> void Open(Functor callback) { StartTimer(); auto self = shared_from_this(); // To keep myself alive. _strand.post([=]() { auto handle_query = [this, self, callback]( const boost::system::error_code &ec, size_t DEBUG_ONLY(bytes_received)) { DEBUG_ASSERT_EQ(bytes_received, sizeof(_stream_id)); if (!ec) { log_debug("session", _session_id, "for stream", _stream_id, " started"); _socket.get_io_service().post([=]() { callback(self); }); } else { log_error("session", _session_id, ": error retrieving stream id :", ec.message()); Close(); } }; // Read the stream id. _deadline.expires_from_now(_timeout); boost::asio::async_read( _socket, boost::asio::buffer(&_stream_id, sizeof(_stream_id)), _strand.wrap(handle_query)); }); } stream_id_type get_stream_id() const { // Note that the stream id isn't synchronized. This function should only be // called from the @a callback function, and after that point the stream_id // can't change. return _stream_id; } /// Writes some data to the socket. void Write(std::shared_ptr<const Message> message) { auto self = shared_from_this(); _strand.post([=]() { /// @todo has to be a better way of doing this... if (_is_writing) { // Repost and return; Write(std::move(message)); return; } _is_writing = true; auto handle_sent = [this, self, message](const boost::system::error_code &ec, size_t DEBUG_ONLY(bytes)) { _is_writing = false; if (ec) { log_error("session", _session_id, ": error sending data :", ec.message()); } else { DEBUG_ONLY(log_debug("session", _session_id, ": successfully sent", bytes, "bytes")); DEBUG_ASSERT_EQ(bytes, sizeof(message_size_type) + message->size()); } }; log_debug("session", _session_id, ": sending message of", message->size(), "bytes"); _deadline.expires_from_now(_timeout); boost::asio::async_write( _socket, message->encode(), _strand.wrap(handle_sent)); }); } void Close() { _strand.post([this, self = shared_from_this()]() { if (_socket.is_open()) { _socket.close(); } log_debug("session", _session_id, "closed"); }); } private: void StartTimer() { if (_deadline.expires_at() <= boost::asio::deadline_timer::traits_type::now()) { log_debug("session", _session_id, "timed out"); Close(); } else { _deadline.async_wait([self = shared_from_this()](boost::system::error_code) { self->StartTimer(); }); } } friend class Server; const size_t _session_id; stream_id_type _stream_id = 0u; socket_type _socket; duration_type _timeout; boost::asio::deadline_timer _deadline; boost::asio::io_service::strand _strand; bool _is_writing = false; }; } // namespace tcp } // namespace low_level } // namespace streaming } // namespace carla
29.264368
113
0.621563
[ "object" ]
2d28d25902239a89dca6bad0c59df302b91cb49d
1,020
h
C
KoopaTroopa.h
zacharytay1994/NotSoSuperMario
e0828f4cb2231f2e5993a71a492a25892744e129
[ "CC-BY-3.0" ]
2
2019-11-22T06:04:43.000Z
2019-12-05T13:29:17.000Z
KoopaTroopa.h
zacharytay1994/NotSoSuperMario
e0828f4cb2231f2e5993a71a492a25892744e129
[ "CC-BY-3.0" ]
null
null
null
KoopaTroopa.h
zacharytay1994/NotSoSuperMario
e0828f4cb2231f2e5993a71a492a25892744e129
[ "CC-BY-3.0" ]
null
null
null
#pragma once #include "GameObject.h" #include "Vec2.h" #include <cstdlib> class Graphics; class Input; class ColliderManager; class PhysicsComponent; class KoopaTroopa : public GameObject { private: int random; //range 1 to 10 float timer; bool shellState = false; Sprite* walking_sprite_; Sprite* shellmoving_sprite_; Sprite* shellidle_sprite_; bool looking_left_ = false; PhysicsComponent* phy_; Vec2<float> direction_ = { -1.0f, 0.0f }; float speed_ = 25.0f; float shellSpeed_ = 150.0f; bool shellMoving = false; // goomba death animation container std::vector<Sprite> goomba_sprites_; float drop_speed_ = 100.0f; Graphics* gfx_; public: KoopaTroopa(ColliderManager& cm, const Vec2<float>& position); ~KoopaTroopa(); void Update(const float& frametime) override; void Render() override; void ChildInitialize(Graphics& gfx) override; bool GetShellState(); bool GetShellMovingState(); void AddGoombaSprite(); void UpdateGoombaSprites(const float& frametime); void DrawGoombaSprites(); };
24.878049
63
0.755882
[ "render", "vector" ]
2d325bacd5900e8ab74f377b2a7a1c82a491aab1
8,922
h
C
cpputil/MathUtil.h
kryozahiro/cpputil
8fa26b4f9e7d13844be58d44271784fc578449ba
[ "BSL-1.0" ]
null
null
null
cpputil/MathUtil.h
kryozahiro/cpputil
8fa26b4f9e7d13844be58d44271784fc578449ba
[ "BSL-1.0" ]
null
null
null
cpputil/MathUtil.h
kryozahiro/cpputil
8fa26b4f9e7d13844be58d44271784fc578449ba
[ "BSL-1.0" ]
null
null
null
/* * MathUtil.h * * Created on: 2013/12/02 * Author: kryozahiro */ #ifndef MATHUTIL_H_ #define MATHUTIL_H_ #include <cmath> #include <complex> #include <boost/math/constants/constants.hpp> #include <boost/operators.hpp> namespace cpputil { //---------------------------------------- // 定数 //---------------------------------------- using namespace boost::math::constants; //---------------------------------------- // スケーリング //---------------------------------------- /// 線形変換 template <class T> T scale(T value, T ratio, T bias) { return ratio * value + bias; } /// 範囲の線形変換 template <class T> T scale(T value, std::pair<T, T> from_range, std::pair<T, T> to_range) { T ratio = (to_range.second - to_range.first) / (from_range.second - from_range.first); T bias = to_range.first - from_range.first * ratio; return scale(value, ratio, bias); } /// 全体の平均を保って最大値を平均のscaling倍にするような線形変換 /** f(mean) = a * mean + b = average * f(max) = a * max + b = scale * average */ template <class T> T scale(T value, T mean, T max, T scaling) { T ratio = mean * (scaling - 1.0) / (max - mean); T bias = mean * (1.0 - ratio); return scale(value, ratio, bias); } //---------------------------------------- // 角度 //---------------------------------------- /// 度数からラジアンへ変換 template <class T> T toRadian(T deg) { return deg * pi<T>() / 180.0; } /// ラジアンから度数へ変換 template <class T> T toDegree(T rad) { return rad * 180.0 / pi<T>(); } /// -PI < rad <= PIに正規化 template <class T> T normalize(T rad) { rad = std::remainder(rad, 2.0 * pi<T>()); if (rad <= -pi<T>()) { rad += 2.0 * pi<T>(); } return rad; } /// 正規化つきの回転 template <class T> T rotate(T baseRad, T relativeRad) { return normalize(baseRad + relativeRad); } //---------------------------------------- // 複素数 // テンプレート引数は実数のみ使用可能 //---------------------------------------- /// ペアから複素数へ変換 template <class T, class U, class V> std::complex<T> toComplex(std::pair<U, V> p) { return std::complex<T>(p.first, p.second); } /// 複素数からペアへ変換 template <class T, class U, class V> std::pair<T, U> toPair(std::complex<V> z) { return std::make_pair<T, U>(z.real(), z.imag()); } /// 単位長への正規化 template <class T> std::complex<T> normalize(std::complex<T> z) { return z / std::abs(z); } //---------------------------------------- // ノルムと距離 //---------------------------------------- /// 実数版Lp-ノルム template <class T> T lpNorm(std::complex<T> z, T p) { return std::pow(std::pow(std::fabs(z.real()), p) + std::pow(std::fabs(z.imag()), p), 1.0 / p); } /// 実数版Lp-ノルムによる距離 template <class T> T lpDistance(std::complex<T> z0, std::complex<T> z1, T p) { return lpNorm<T>(z1 - z0, p); } /// 整数版Lp-ノルムの実装の詳細 namespace detail { template <class T, int p> struct lpNormHelper { static T lpNorm(std::complex<T> z); }; template <class T, int p> T lpNormHelper<T, p>::lpNorm(std::complex<T> z) { return cpputil::lpNorm(z, static_cast<T>(p)); } template <class T> struct lpNormHelper<T, 1> { static T lpNorm(std::complex<T> z); }; template <class T> T lpNormHelper<T, 1>::lpNorm(std::complex<T> z) { return std::fabs(z.real()) + std::fabs(z.imag()); } template <class T> struct lpNormHelper<T, 2> { static T lpNorm(std::complex<T> z); }; template <class T> T lpNormHelper<T, 2>::lpNorm(std::complex<T> z) { return std::abs(z); } template <class T> struct lpNormHelper<T, INT_MAX> { static T lpNorm(std::complex<T> z); }; template <class T> T lpNormHelper<T, INT_MAX>::lpNorm(std::complex<T> z) { return std::max(std::fabs(z.real()), std::fabs(z.imag())); } } /// 整数版Lp-ノルム template <class T, int p> T lpNorm(std::complex<T> z) { return detail::lpNormHelper<T, p>::lpNorm(z); } /// 整数版Lp-ノルムによる距離 template <class T, int p> T lpDistance(std::complex<T> z0, std::complex<T> z1) { return lpNorm<T, p>(z1 - z0); } /// マンハッタンノルム template <class T> T manhattanNorm(std::complex<T> z) { return lpNorm<T, 1>(z); } /// マンハッタン距離 template <class T> T manhattanDistance(std::complex<T> z0, std::complex<T> z1) { return manhattanNorm(z1 - z0); } /// ユークリッドノルム template <class T> T euclideanNorm(std::complex<T> z) { return lpNorm<T, 2>(z); } /// ユークリッド距離 template <class T> T euclideanDistance(std::complex<T> z0, std::complex<T> z1) { return euclideanNorm(z1 - z0); } /// チェス盤ノルム template <class T> T chessboardNorm(std::complex<T> z) { return lpNorm<T, INT_MAX>(z); } /// チェス盤距離 template <class T> T chessboardDistance(std::complex<T> z0, std::complex<T> z1) { return chessboardNorm(z1 - z0); } //---------------------------------------- // アフィン変換 //---------------------------------------- /// 平行移動 template <class T> std::complex<T> translate(std::complex<T> z, std::complex<T> translation) { return z + translation; } /// 回転 template <class T> std::complex<T> rotate(std::complex<T> z, double rad) { return z * std::polar(1.0, rad); } /// 拡縮 template <class T> std::complex<T> scale(std::complex<T> z, std::complex<T> scaling) { return std::complex<T>(z.real() * scaling.real(), z.imag() * scaling.imag()); } /// 変換 template <class T> std::complex<T> transform(std::complex<T> z, std::complex<T> translation, double rotation, std::complex<T> scaling = std::complex<T>(1, 1)) { return translate(rotate(scale(z, scaling), rotation), translation); } /// 変換オブジェクト template <class T> class Transformation : private boost::equality_comparable<Transformation<T>, Transformation<T>> { public: Transformation() = default; Transformation(std::complex<T> translation, T rotation, std::complex<T> scaling); //@{ ///アクセサ std::complex<T> translation() const; void translation(std::complex<T> t); T rotation() const; void rotation(T rad); std::complex<T> scaling() const; void scaling(std::complex<T> s); //@} /// 位置を変換する std::complex<T> operator*(std::complex<T> z); /// 逆変換の取得 Transformation<T> inverse(); /// 変換オブジェクトを姿勢と解釈して変換させる /** local == trueなら姿勢を中心とする座標系での相対変換 * local == falseなら姿勢を表現する座標系での絶対変換 */ void translate(std::complex<T> t, bool local = true); void rotate(double rad, bool local = true); void scale(std::complex<T> s, bool local = true); void transform(const Transformation<T>& t, bool local = true); Transformation<T>& operator*=(const Transformation<T>& t); /// 変換の比較 template <class X> friend bool operator==(const Transformation<X>& lhs, const Transformation<X>& rhs); private: /// 平行移動 std::complex<T> translation_ = {0, 0}; /// 回転 T rotation_ = 0; /// 拡縮 std::complex<T> scaling_ = {1, 1}; }; template <class T> Transformation<T>::Transformation(std::complex<T> translation, T rotation, std::complex<T> scaling) : translation_(translation), rotation_(rotation), scaling_(scaling) { } template <class T> std::complex<T> Transformation<T>::translation() const { return translation_; } template <class T> void Transformation<T>::translation(std::complex<T> t) { translation_ = t; } template <class T> T Transformation<T>::rotation() const { return rotation_; } template <class T> void Transformation<T>::rotation(T rad) { rotation_ = rad; } template <class T> std::complex<T> Transformation<T>::scaling() const { return scaling_; } template <class T> void Transformation<T>::scaling(std::complex<T> s) { scaling_ = s; } template <class T> std::complex<T> Transformation<T>::operator*(std::complex<T> z) { return cpputil::transform(z, translation_, rotation_, scaling_); } template <class T> Transformation<T> Transformation<T>::inverse() { return Transformation<T>( -cpputil::rotate(cpputil::scale(translation_, 1.0 / scaling_), -rotation_), -rotation_, 1.0 / scaling_ ); } template <class T> void Transformation<T>::translate(std::complex<T> t, bool local) { if (local) { translation_ = cpputil::transform(t, translation_, rotation_, scaling_); } else { translation_ = cpputil::translate(translation_, t); } } template <class T> void Transformation<T>::rotate(double rad, bool local) { rotation_ = cpputil::rotate(rotation_, rad); if (!local) { translation_ = cpputil::rotate(translation_, rad); } } template <class T> void Transformation<T>::scale(std::complex<T> s, bool local) { if (local) { scaling_ = cpputil::scale(scaling_, s); } else { translation_ = cpputil::scale(translation_, s); } } template <class T> void Transformation<T>::transform(const Transformation<T>& t, bool local) { scale(t.scaling_, local); rotate(t.rotation_, local); translate(t.translation_, local); } template <class T> Transformation<T>& Transformation<T>::operator*=(const Transformation<T>& t) { transform(t); return *this; } //変換の合成 template <class T> Transformation<T> operator*(const Transformation<T>& lhs, const Transformation<T>& rhs) { Transformation<T> ret = lhs; ret *= rhs; return ret; } //変換の比較 template <class T> bool operator==(const Transformation<T>& lhs, const Transformation<T>& rhs) { return lhs.translation_ == rhs.translation_ and lhs.rotation_ == rhs.rotation_ and lhs.scaling_ == rhs.scaling_; } } #endif /* MATHUTIL_H_ */
22.64467
141
0.633826
[ "transform" ]
2d3863bea266b9e89ab48fb37ac9c25fad5b3d7f
2,543
h
C
external/blend2d/src/blend2d/blarray_p.h
osom8979/tbag
c31e2d884907d946df0836a70d8d5d69c4bf3c27
[ "MIT" ]
21
2016-04-05T06:08:41.000Z
2022-03-28T10:20:22.000Z
external/blend2d/src/blend2d/blarray_p.h
osom8979/tbag
c31e2d884907d946df0836a70d8d5d69c4bf3c27
[ "MIT" ]
null
null
null
external/blend2d/src/blend2d/blarray_p.h
osom8979/tbag
c31e2d884907d946df0836a70d8d5d69c4bf3c27
[ "MIT" ]
2
2019-07-16T00:37:21.000Z
2021-11-10T06:14:09.000Z
// [Blend2D] // 2D Vector Graphics Powered by a JIT Compiler. // // [License] // Zlib - See LICENSE.md file in the package. #ifndef BLEND2D_BLARRAY_P_H #define BLEND2D_BLARRAY_P_H #include "./blapi-internal_p.h" #include "./blarray.h" #include "./blsupport_p.h" //! \cond INTERNAL //! \addtogroup blend2d_internal //! \{ // ============================================================================ // [BLArray - Internal] // ============================================================================ BL_HIDDEN BLResult blArrayImplDelete(BLArrayImpl* impl) noexcept; static BL_INLINE BLResult blArrayImplRelease(BLArrayImpl* impl) noexcept { if (blImplDecRefAndTest(impl)) return blArrayImplDelete(impl); return BL_SUCCESS; } // ============================================================================ // [BLArray - Utilities] // ============================================================================ namespace { constexpr size_t blContainerSizeOf(size_t baseSize, size_t itemSize, size_t n) noexcept { return baseSize + n * itemSize; } constexpr size_t blContainerCapacityOf(size_t baseSize, size_t itemSize, size_t implSize) noexcept { return (implSize - baseSize) / itemSize; } //! Calculates the maximum theoretical capacity of items a container can hold. //! This is really a theoretical capacity that will never be reached in practice //! is it would mean that all addressable memory will be used by the data and //! mapped into a single continuous region, which is impossible. constexpr size_t blContainerMaximumCapacity(size_t baseSize, size_t itemSize) noexcept { return blContainerCapacityOf(baseSize, itemSize, SIZE_MAX); } BL_INLINE size_t blContainerFittingCapacity(size_t baseSize, size_t itemSize, size_t n) noexcept { size_t nInBytes = blAlignUp(baseSize + n * itemSize, 32); size_t capacity = (nInBytes - baseSize) / itemSize; BL_ASSERT(capacity >= n); return capacity; } BL_INLINE size_t blContainerGrowingCapacity(size_t baseSize, size_t itemSize, size_t n, size_t minSizeInBytes) noexcept { size_t nInBytes = baseSize + n * itemSize; size_t optInBytes; if (nInBytes < BL_ALLOC_GROW_LIMIT) { optInBytes = blMax<size_t>(minSizeInBytes, blAlignUpPowerOf2(nInBytes + (nInBytes >> 1))); } else { optInBytes = blMax<size_t>(nInBytes, blAlignUp(nInBytes, BL_ALLOC_GROW_LIMIT)); } size_t capacity = (optInBytes - baseSize) / itemSize; BL_ASSERT(capacity >= n); return capacity; } } // {anonymous} //! \} //! \endcond #endif // BLEND2D_BLARRAY_P_H
30.638554
121
0.653166
[ "vector" ]
2d3d6370e82e6315452a00627f9fdf445f1cb55f
4,262
h
C
cling/lib/Interpreter/IncrementalParser.h
paulwratt/cin-5.34.00
036a8202f11a4a0e29ccb10d3c02f304584cda95
[ "MIT" ]
10
2018-03-26T07:41:44.000Z
2021-11-06T08:33:24.000Z
cling/lib/Interpreter/IncrementalParser.h
paulwratt/cin-5.34.00
036a8202f11a4a0e29ccb10d3c02f304584cda95
[ "MIT" ]
null
null
null
cling/lib/Interpreter/IncrementalParser.h
paulwratt/cin-5.34.00
036a8202f11a4a0e29ccb10d3c02f304584cda95
[ "MIT" ]
1
2020-11-17T03:17:00.000Z
2020-11-17T03:17:00.000Z
//--------------------------------------------------------------------*- C++ -*- // CLING - the C++ LLVM-based InterpreterG :) // version: $Id$ // author: Axel Naumann <axel@cern.ch> //------------------------------------------------------------------------------ #ifndef CLING_INCREMENTAL_PARSER_H #define CLING_INCREMENTAL_PARSER_H #include "ChainedConsumer.h" #include "cling/Interpreter/CompilationOptions.h" #include "clang/AST/DeclBase.h" #include "clang/AST/DeclGroup.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" #include <vector> namespace llvm { struct GenericValue; class MemoryBuffer; } namespace clang { class ASTConsumer; class CodeGenerator; class CompilerInstance; class Decl; class FileID; class FunctionDecl; class Parser; class Sema; class SourceLocation; } namespace cling { class ChainedConsumer; class CIFactory; class ExecutionContext; class Interpreter; class IncrementalParser { public: ///\brief Contains information about the last input struct Transaction { private: clang::Decl* m_BeforeFirst; clang::Decl* m_LastDecl; void setBeforeFirstDecl(clang::DeclContext* DC) { class DeclContextExt : public clang::DeclContext { public: static clang::Decl* getLastDecl(DeclContext* DC) { return ((DeclContextExt*)DC)->LastDecl; } }; m_BeforeFirst = DeclContextExt::getLastDecl(DC); } public: clang::Decl* getFirstDecl() const { return m_BeforeFirst->getNextDeclInContext(); } clang::Decl* getLastDeclSlow() const { clang::Decl* Result = getFirstDecl(); while (Result->getNextDeclInContext()) Result = Result->getNextDeclInContext(); return Result; } friend class IncrementalParser; }; enum EParseResult { kSuccess, kSuccessWithWarnings, kFailed }; IncrementalParser(Interpreter* interp, int argc, const char* const *argv, const char* llvmdir); ~IncrementalParser(); void Initialize(); clang::CompilerInstance* getCI() const { return m_CI.get(); } clang::Parser* getParser() const { return m_Parser.get(); } ///\brief Compiles the given input with the given compilation options. /// EParseResult Compile(llvm::StringRef input, const CompilationOptions& Opts); void Parse(llvm::StringRef input, llvm::SmallVector<clang::DeclGroupRef, 4>& DGRs); llvm::MemoryBuffer* getCurBuffer() const { return m_MemoryBuffer.back(); } void enablePrintAST(bool print /*=true*/) { m_Consumer->getCompilationOpts().Debug = print; } void enableDynamicLookup(bool value = true); bool isDynamicLookupEnabled() const { return m_DynamicLookupEnabled; } bool isSyntaxOnly() const { return m_SyntaxOnly; } clang::Decl* getFirstTopLevelDecl() const { return m_FirstTopLevelDecl; } clang::Decl* getLastTopLevelDecl() const { return m_LastTopLevelDecl; } Transaction& getLastTransaction() { return m_LastTransaction; } clang::CodeGenerator* GetCodeGenerator() const; private: void CreateSLocOffsetGenerator(); EParseResult Compile(llvm::StringRef input); EParseResult Parse(llvm::StringRef input); Interpreter* m_Interpreter; // our interpreter context llvm::OwningPtr<clang::CompilerInstance> m_CI; // compiler instance. llvm::OwningPtr<clang::Parser> m_Parser; // parser (incremental) bool m_DynamicLookupEnabled; // enable/disable dynamic scope std::vector<llvm::MemoryBuffer*> m_MemoryBuffer; // One buffer for each command line, owner by the source file manager clang::FileID m_VirtualFileID; // file ID of the memory buffer ChainedConsumer* m_Consumer; // CI owns it clang::Decl* m_FirstTopLevelDecl; // first top level decl clang::Decl* m_LastTopLevelDecl; // last top level decl after most recent call to parse() Transaction m_LastTransaction; // Holds information for the last transaction bool m_SyntaxOnly; // whether to run codegen; cannot be flipped during lifetime of *this }; } #endif // CLING_INCREMENTAL_PARSER_H
33.296875
122
0.664477
[ "vector" ]
2d3e4ee03fce6871c952ba709fd7c5e1f7c8887d
27,626
h
C
inc/dg/multistep_tableau.h
RaulGerru/FELTOR_FINAL
dd5af5e61d1607eb3b0415b756c1a6cf56b63a2c
[ "MIT" ]
null
null
null
inc/dg/multistep_tableau.h
RaulGerru/FELTOR_FINAL
dd5af5e61d1607eb3b0415b756c1a6cf56b63a2c
[ "MIT" ]
null
null
null
inc/dg/multistep_tableau.h
RaulGerru/FELTOR_FINAL
dd5af5e61d1607eb3b0415b756c1a6cf56b63a2c
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <string> #include <unordered_map> namespace dg{ /** * @brief Manage coefficients of Multistep methods * * The general s-step multistep method has the form * \f[ y^{n+1} = \sum_{i=0}^{s-1} a_i y^{n-i} + h \sum_{i=0}^{s-1} b_i E( t_{n-i}, y_{n-i}) + h \sum_{i=0}^s c_i I( t_{n+1-i}, y^{n+1-i}) * \f] * where E is the explicit and I is implicit part. A purely implicit method is * one where all \f$ b_i\f$ are zero, while an explicit one is one where all * \f$ c_i\f$ are zero. * A tableau thus consists of the three arrays a, b and c the number of steps * and the order of the method. * Currently available methods are: * * ImEx methods * @copydoc hide_imex_multistep_tableaus * @note ImEx multistep tableaus can be used in ExplicitMultistep, ImplicitMultistep and ImExMultistep * * Explicit methods * @copydoc hide_explicit_multistep_tableaus * * @tparam real_type type of the coefficients * @sa ExplicitMultistep, ImplicitMultistep, ImExMultistep * @ingroup time_utils */ template<class real_type> struct MultistepTableau { using value_type = real_type; ///No memory allocation MultistepTableau(){} /*! @brief Construct a tableau * * @param steps number of stages * @param order (global) order of the resulting method * @param a_v s real numbers * @param b_v s real numbers (can be empty, which then sets them all to 0 constructing an implicit method) * @param c_v s+1 real numbers (can be empty, which constructs an explicit method by assigning all c_i 0) */ MultistepTableau( unsigned steps, unsigned order, const std::vector<real_type>& a_v, const std::vector<real_type>& b_v, const std::vector<real_type>& c_v): m_steps(steps), m_order(order), m_a(a_v), m_b(b_v), m_c(c_v){ if( m_c.empty()) m_c.assign( steps+1, 0); if( m_b.empty()) m_b.assign( steps, 0); } /** * @brief Read the a_i coefficients * @param i idx number 0<=i<s, i>=s results in undefined behaviour * @return a_i */ real_type a( unsigned i){ return m_a[i];} /** * @brief Read the explicit (b_i) coefficients * @param i idx number 0<=i<s, i>=s results in undefined behaviour * @return b_i */ real_type ex( unsigned i){ return m_b[i];} /** * @brief Read the implicit (c_i) coefficients * @param i idx number 0<=i<s+1, i>=s+1 results in undefined behaviour * @return c_i */ real_type im( unsigned i){ return m_c[i];} ///The number of stages s unsigned steps() const { return m_steps; } ///global order of accuracy for the method unsigned order() const { return m_order; } ///True if any of the explicit coefficients b_i are non-zero bool isExplicit() const{ for( unsigned i=0; i<m_steps; i++) if( m_b[i]!=0) return true; return false; } ///True if any of the implicit coefficients c_i are non-zero bool isImplicit() const{ for( unsigned i=0; i<m_steps+1; i++) if( m_c[i]!=0) return true; return false; } private: unsigned m_steps, m_order; std::vector<real_type> m_a, m_b, m_c; }; ///@cond namespace tableau { template<class real_type> MultistepTableau<real_type> imex_euler_1_1() { unsigned steps = 1, order = 1; std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); a[0] = b[0] = c[0] = 1; return MultistepTableau<real_type>( steps, order, a, b, c); } template<class real_type> MultistepTableau<real_type> imex_adams_2_2() { // 2nd order AB method extended to ImEx // C = 4/9 ~ 0.444 D = 0.33 unsigned steps = 2, order = 2; std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); a[0] = 1.; b[0] = 3./2.; b[1] = -1./2.; c[0] = 9./16.; c[1] = 3./8.; c[2] = 1./16.; return MultistepTableau<real_type>( steps, order, a, b, c); } template<class real_type> MultistepTableau<real_type> imex_adams_3_3() { // 3rd order AB method extended to ImEx // C ~ 0.16, D = 0.67 unsigned steps = 3, order = 3; std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); a[0] = 1.; b[0] = 23./12.; b[1] = -4./3.; b[2] = 5./12.; c[0] = 4661./10000.; c[1] = 15551./30000.; c[2] = 1949/30000; c[3] = -1483./30000.; return MultistepTableau<real_type>( steps, order, a, b, c); } template<class real_type> MultistepTableau<real_type> imex_koto_2_2() { // stabilized 2nd order method unsigned steps = 2, order = 2; std::vector<real_type> am(steps,0), bm(steps, 0), cm(steps+1,0); std::vector<real_type> ap(steps+1,0), bp(steps+1, 0), cp(steps+1,0); //real_type a = 1.5, b = 1.5; real_type a = 20., b = 20.; ap[0] = a; ap[1] = 1-2.*a; ap[2] = a-1; cp[0] = b; cp[1] = 0.5+a-2*b; cp[2] = 0.5-a+b; bp[1] = 0.5+a; bp[2] = 0.5-a; am[0] = -ap[1]/a, am[1] = -ap[2]/a; bm[0] = bp[1]/a, bm[1] = bp[2]/a; cm[0] = cp[0]/a, cm[1] = cp[1]/a, cm[2] = cp[2]/a; return MultistepTableau<real_type>( steps, order, am, bm, cm); } template<class real_type> MultistepTableau<real_type> imex_bdf(unsigned steps) { unsigned order = steps; std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); switch( steps) { case( 2): // C = 5/8 ~ 0.625 D = 0 a[0] = 4./3.; b[0] = 4./3.; a[1] = -1./3.; b[1] = -2./3.; c[0] = 2./3.; break; case(3): //The Karniadakis method // C = 7/18 ~ 0.39 D = 0 a[0] = 18./11.; b[0] = 18./11.; a[1] = -9./11.; b[1] = -18./11.; a[2] = 2./11.; b[2] = 6./11.; c[0] = 6./11.; break; case(4): // C = 7/32 ~ 0.22 , D = 0 a[0] = 48./25.; b[0] = 48./25.; a[1] = -36./25.; b[1] = -72./25.; a[2] = 16./25.; b[2] = 48./25.; a[3] = - 3./25.; b[3] = -12./25.; c[0] = 12./25.; break; case(5): // C = 0.0867 , D = 0 a[0] = 300./137.; b[0] = 300./137.; a[1] = -300./137.; b[1] = -600./137.; a[2] = 200./137.; b[2] = 600./137.; a[3] = -75./137.; b[3] = -300./137.; a[4] = 12./137.; b[4] = 60./137.; c[0] = 60./137.; break; case (6): a = {360./147.,-450./147.,400./147.,-225./147.,72./147.,-10./147.}; b = {360./147.,-900./147.,1200./147.,-900./147.,360./147.,-60./147.}; c[0] = 60./147.; break; } return MultistepTableau<real_type>( steps, order, a, b, c); } template<class real_type> MultistepTableau<real_type> imex_tvb(unsigned steps) { unsigned order = steps; std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); switch( steps) { case(3): // C = 0.536 D = 0.639 a[0] = 3909./2048.; b[0] = 18463./12288.; a[1] = -1367./1024.; b[1] = -1271./768.; a[2] = 873./2048.; b[2] = 8233./12288.; c[0] = 1089./2048.; c[1] = -1139./12288.; c[2] = -367./6144.; c[3] = 1699./12288.; break; case(4): // C = 0.458 , D = 0.685 a[0] = 21531./8192.; b[0] = 13261./8192.; a[1] = -22753./8192.; b[1] = -75029./24576.; a[2] = 12245./8192.; b[2] = 54799./24576.; a[3] = -2831./8192. ; b[3] = -15245./24576.; c[0] = 4207./8192.; c[1] = -3567./8192.; c[2] = 697./24576.; c[3] = 4315./24576.; c[4] = -41./384.; break; case(5): // C = 0.376 , D = 0.709 a[0] = 13553./4096.; b[0] = 10306951./5898240.; a[1] = -38121./8192.; b[1] = -13656497./2949120.; a[2] = 7315./2048.; b[2] = 1249949./245760.; a[3] = -6161/4096. ; b[3] = -7937687./2949120.; a[4] = 2269./8192.; b[4] = 3387361./5898240.; c[0] = 4007./8192.; c[1] = -4118249./5898240.; c[2] = 768703./2949120.; c[3] = 47849./245760.; c[4] = -725087./2949120.; c[5] = 502321./5898240.; break; } return MultistepTableau<real_type>( steps, order, a, b, c); } template<class real_type> MultistepTableau<real_type> ab(unsigned order) { unsigned steps = order; std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); a[0]= 1.; switch (order){ case 1: b = {1}; break; case 2: b = {1.5, -0.5}; break; case 3: b = { 23./12., -4./3., 5./12.}; break; case 4: b = {55./24., -59./24., 37./24., -3./8.}; break; case 5: b = { 1901./720., -1387./360., 109./30., -637./360., 251./720.}; break; default: throw dg::Error(dg::Message()<<"Order "<<order<<" not implemented in AdamsBashforth!"); } return MultistepTableau<real_type>( steps, order, a, b, c); } template<class real_type> MultistepTableau<real_type> tvb(unsigned steps) { unsigned order = steps; std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); switch (steps){ case 1: a = {1.}; b = {1.}; break; case 2: a = {4./3., -1./3.}; b = {4./3., -2./3.}; break; //CLM = 0.5 case 3: //CLM = 0.54... a[0] = 1.908535476882378; b[0] = 1.502575553858997; a[1] = -1.334951446162515; b[1] = -1.654746338401493; a[2] = 0.426415969280137; b[2] = 0.670051276940255; break; case 4: //CLM = 0.45... a[0] = 2.628241000683208; b[0] = 1.618795874276609; a[1] = -2.777506277494861; b[1] = -3.052866947601049; a[2] = 1.494730011212510; b[2] = 2.229909318681302; a[3] = -0.345464734400857; b[3] = -0.620278703629274; break; case 5: //CLM = 0.37... a[0] = 3.308891758551210; b[0] = 1.747442076919292; a[1] = -4.653490937946655; b[1] = -4.630745565661800; a[2] = 3.571762873789854; b[2] = 5.086056171401077; a[3] = -1.504199914126327; b[3] = -2.691494591660196; a[4] = 0.277036219731918; b[4] = 0.574321855183372; break; case 6: //CLM = 0.32... a[0] = 4.113382628475685; b[0] = 1.825457674048542; a[1] = -7.345730559324184; b[1] = -6.414174588309508; a[2] = 7.393648314992094; b[2] = 9.591671249204753; a[3] = -4.455158576186636; b[3] = -7.583521888026967; a[4] = 1.523638279938299; b[4] = 3.147082225022105; a[5] = -0.229780087895259; b[5] = -0.544771649561925; break; default: throw dg::Error(dg::Message()<<"Order "<<steps<<" not implemented in TVB scheme!"); } return MultistepTableau<real_type>( steps, order, a, b, c); } template<class real_type> MultistepTableau<real_type> ssp(unsigned steps) { std::vector<real_type> a(steps,0), b(steps, 0), c(steps+1,0); unsigned order = 0; switch (steps){ case 1: order = 1; a = {1.}; b = {1.}; break; case 2: order = 2; a = {4./5., 1./5.}; b = {8./5., -2./5.}; break; //CLM = 0.5 ... ,order 2 case 3: order = 2; a = { 3./4., 0., 1./4.}; b = { 3./2., 0., 0. }; break; //CLM = 0.5..., order 2 case 4: order = 2; a = {8./9., 0., 0., 1./9.}; b = {4./3., 0., 0., 0.}; break; //CLM = 0.66..., order 2 case 5: order = 3; a = {25./32., 0., 0., 0., 7./32.}; b = {25./16.,0.,0.,0.,5./16.}; break; //CLM 0.5, order 3 case 6: order = 3; a = {108./125.,0.,0.,0.,0.,17./125.}; b = {36./25.,0.,0.,0.,0.,6./25.}; break; //CLM 0.567, order 3 default: throw dg::Error(dg::Message()<<"Stage "<<steps<<" not implemented in SSP scheme!"); } return MultistepTableau<real_type>( steps, order, a, b, c); } }//namespace tableau ///@endcond /** * @brief Identifiers for Multistep Tableaus * * We follow the naming convention * as NAME_S_Q * - NAME is the author or name of the method * - S is the number of steps in the method * - Q is the global order of the method * * @ingroup time_utils * @sa ExplicitMultistep, ImplicitMultistep, ImExMultistep */ enum multistep_identifier{ //IMEX methods IMEX_EULER_1_1, IMEX_ADAMS_2_2, IMEX_ADAMS_3_3, IMEX_KOTO_2_2, IMEX_BDF_2_2, IMEX_BDF_3_3, IMEX_BDF_4_4, IMEX_BDF_5_5, IMEX_BDF_6_6, IMEX_TVB_3_3, IMEX_TVB_4_4, IMEX_TVB_5_5, // Explicit methods AB_1_1, AB_2_2, AB_3_3, AB_4_4, AB_5_5, eBDF_1_1, eBDF_2_2, eBDF_3_3, eBDF_4_4, eBDF_5_5, eBDF_6_6, TVB_1_1, TVB_2_2, TVB_3_3, TVB_4_4, TVB_5_5, TVB_6_6, SSP_1_1, SSP_2_2, SSP_3_2, SSP_4_2, SSP_5_3, SSP_6_3, // implicit methods BDF_1_1, BDF_2_2, BDF_3_3, BDF_4_4, BDF_5_5, BDF_6_6, }; ///@cond namespace create{ static std::unordered_map<std::string, enum multistep_identifier> str2lmsid{ //Implicit-Explicit methods {"Euler", IMEX_EULER_1_1}, {"Euler-1-1", IMEX_EULER_1_1}, {"ImEx-Adams-2-2", IMEX_ADAMS_2_2}, {"ImEx-Adams-3-3", IMEX_ADAMS_3_3}, {"ImEx-Koto-2-2", IMEX_KOTO_2_2}, {"ImEx-BDF-2-2", IMEX_BDF_2_2}, {"ImEx-BDF-3-3", IMEX_BDF_3_3}, {"Karniadakis", IMEX_BDF_3_3}, {"ImEx-BDF-4-4", IMEX_BDF_4_4}, {"ImEx-BDF-5-5", IMEX_BDF_5_5}, {"ImEx-BDF-6-6", IMEX_BDF_6_6}, {"ImEx-TVB-3-3", IMEX_TVB_3_3}, {"ImEx-TVB-4-4", IMEX_TVB_4_4}, {"ImEx-TVB-5-5", IMEX_TVB_5_5}, //Explicit methods {"AB-1-1", AB_1_1}, {"AB-2-2", AB_2_2}, {"AB-3-3", AB_3_3}, {"AB-4-4", AB_4_4}, {"AB-5-5", AB_5_5}, {"eBDF-1-1", eBDF_1_1}, {"eBDF-2-2", eBDF_2_2}, {"eBDF-3-3", eBDF_3_3}, {"eBDF-4-4", eBDF_4_4}, {"eBDF-5-5", eBDF_5_5}, {"eBDF-6-6", eBDF_6_6}, {"TVB-1-1", TVB_1_1}, {"TVB-2-2", TVB_2_2}, {"TVB-3-3", TVB_3_3}, {"TVB-4-4", TVB_4_4}, {"TVB-5-5", TVB_5_5}, {"TVB-6-6", TVB_6_6}, {"SSP-1-1", SSP_1_1}, {"SSP-2-2", SSP_2_2}, {"SSP-3-2", SSP_3_2}, {"SSP-4-2", SSP_4_2}, {"SSP-5-3", SSP_5_3}, {"SSP-6-3", SSP_6_3}, // implicit methods {"BDF-1-1", BDF_1_1}, {"BDF-2-2", BDF_2_2}, {"BDF-3-3", BDF_3_3}, {"BDF-4-4", BDF_4_4}, {"BDF-5-5", BDF_5_5}, {"BDF-6-6", BDF_6_6}, }; static inline enum multistep_identifier str2lmstableau( std::string name) { if( str2lmsid.find(name) == str2lmsid.end()) throw dg::Error(dg::Message(_ping_)<<"Multistep coefficients for "<<name<<" not found!"); else return str2lmsid[name]; } static inline std::string lmstableau2str( enum multistep_identifier id) { for( auto name: str2lmsid) { if( name.second == id) return name.first; } throw dg::Error(dg::Message(_ping_)<<"Tableau conversion failed!"); } template<class real_type> MultistepTableau<real_type> lmstableau( enum multistep_identifier id) { switch(id){ case IMEX_EULER_1_1: return dg::tableau::imex_euler_1_1<real_type>(); case IMEX_ADAMS_2_2: return dg::tableau::imex_adams_2_2<real_type>(); case IMEX_ADAMS_3_3: return dg::tableau::imex_adams_3_3<real_type>(); case IMEX_KOTO_2_2: return dg::tableau::imex_koto_2_2<real_type>(); case IMEX_BDF_2_2: return dg::tableau::imex_bdf<real_type>(2); case IMEX_BDF_3_3: return dg::tableau::imex_bdf<real_type>(3); case IMEX_BDF_4_4: return dg::tableau::imex_bdf<real_type>(4); case IMEX_BDF_5_5: return dg::tableau::imex_bdf<real_type>(5); case IMEX_BDF_6_6: return dg::tableau::imex_bdf<real_type>(6); case IMEX_TVB_3_3: return dg::tableau::imex_tvb<real_type>(3); case IMEX_TVB_4_4: return dg::tableau::imex_tvb<real_type>(4); case IMEX_TVB_5_5: return dg::tableau::imex_tvb<real_type>(5); case AB_1_1: return dg::tableau::ab<real_type>(1); case AB_2_2: return dg::tableau::ab<real_type>(2); case AB_3_3: return dg::tableau::ab<real_type>(3); case AB_4_4: return dg::tableau::ab<real_type>(4); case AB_5_5: return dg::tableau::ab<real_type>(5); case eBDF_1_1: return dg::tableau::imex_euler_1_1<real_type>(); case eBDF_2_2: return dg::tableau::imex_bdf<real_type>(2); case eBDF_3_3: return dg::tableau::imex_bdf<real_type>(3); case eBDF_4_4: return dg::tableau::imex_bdf<real_type>(4); case eBDF_5_5: return dg::tableau::imex_bdf<real_type>(5); case eBDF_6_6: return dg::tableau::imex_bdf<real_type>(6); case TVB_1_1: return dg::tableau::imex_euler_1_1<real_type>(); case TVB_2_2: return dg::tableau::tvb<real_type>(2); case TVB_3_3: return dg::tableau::tvb<real_type>(3); case TVB_4_4: return dg::tableau::tvb<real_type>(4); case TVB_5_5: return dg::tableau::tvb<real_type>(5); case TVB_6_6: return dg::tableau::tvb<real_type>(6); case SSP_1_1: return dg::tableau::ssp<real_type>(1); case SSP_2_2: return dg::tableau::ssp<real_type>(2); case SSP_3_2: return dg::tableau::ssp<real_type>(3); case SSP_4_2: return dg::tableau::ssp<real_type>(4); case SSP_5_3: return dg::tableau::ssp<real_type>(5); case SSP_6_3: return dg::tableau::ssp<real_type>(6); case BDF_1_1: return dg::tableau::imex_euler_1_1<real_type>(); case BDF_2_2: return dg::tableau::imex_bdf<real_type>(2); case BDF_3_3: return dg::tableau::imex_bdf<real_type>(3); case BDF_4_4: return dg::tableau::imex_bdf<real_type>(4); case BDF_5_5: return dg::tableau::imex_bdf<real_type>(5); case BDF_6_6: return dg::tableau::imex_bdf<real_type>(6); } return MultistepTableau<real_type>(); //avoid compiler warning } template<class real_type> MultistepTableau<real_type> lmstableau( std::string name) { return lmstableau<real_type>( str2lmstableau(name)); } }//namespace create ///@endcond /*! @class hide_imex_multistep_tableaus * * Name | Identifier | Description * -------|------------| ----------- * ImEx-Euler-1-1 | dg::IMEX_EULER_1_1 | Explicit Euler combined with Implicit Euler * Euler | dg::IMEX_EULER_1_1 | For convenience ImEx-Koto-2-2 | dg::IMEX_KOTO_2_2 | <a href="https://dx.doi.org/10.1007/s11464-009-0005-9">Koto T. Front. Math. China 2009, 4(1): 113-129</a> A stabilized 2nd order scheme with a large region of stability ImEx-Adams-X-X | dg::IMEX_ADAMS_X_X | <a href="https://dx.doi.org/10.1016/j.jcp.2007.03.003">Hundsdorfer and Ruuth, Journal of Computational Physics 225 (2007)</a> @note **Possible values for X: 2 (C=0.44), 3 (C=0.16)** ImEx-BDF-X-X | dg::IMEX_BDF_X_X | The family of schems described in <a href="https://dx.doi.org/10.1016/j.jcp.2007.03.003">Hundsdorfer and Ruuth, Journal of Computational Physics 225 (2007)</a> <br>The implicit part is a normal BDF scheme https://en.wikipedia.org/wiki/Backward_differentiation_formula while the explicit part equals the Minimal Projecting method by <a href = "https://www.ams.org/journals/mcom/1979-33-148/S0025-5718-1979-0537965-0/S0025-5718-1979-0537965-0.pdf"> Alfeld, P., Math. Comput. 33.148 1195-1212 (1979)</a> or **extrapolated BDF** in <a href = "https://doi.org/10.1137/S0036142902406326"> Hundsdorfer, W., Ruuth, S. J., & Spiteri, R. J. (2003). Monotonicity-preserving linear multistep methods. SIAM Journal on Numerical Analysis, 41(2), 605-623 </a> <br> @note Possible values for **X: 1 (C=1.00), 2 (C=0.63), 3 (C=0.39), 4 (C=0.22), 5 (C=0.09), 6** <br> Note that X=3 is identical to the "Karniadakis" scheme * Karniadakis | dg::IMEX_BDF_3_3 | The ImEx-BDF-3-3 scheme is identical to the widely used "Karniadakis" scheme <a href = "https://dx.doi.org/10.1016/0021-9991(91)90007-8"> Karniadakis, et al. J. Comput. Phys. 97 (1991)</a> ImEx-TVB-X-X | dg::IMEX_TVB_X_X | The family of schems described in < <a href="https://dx.doi.org/10.1016/j.jcp.2007.03.003">Hundsdorfer and Ruuth, Journal of Computational Physics 225 (2007)</a> <br> The explicit part is a TVB scheme while the implicit part is optimized to maximize damping of high wavelength <br> @note Possible values for **X: 3 (C=0.54), 4 (C=0.46), 5 (C=0.38)** * @note the CFL coefficient C is given relative to the forward Euler method: \f$ \Delta t < C \Delta t_{FE}\f$. @attention The coefficient C is the one that ensures the TVD property of the scheme and is **not** directly related to the stability region of the scheme */ /*! @class hide_explicit_multistep_tableaus * Name | Identifier | Description * -------|------------| ----------- * AB-X-X | dg::AB_X_X | The family of schemes described in <a href = "https://en.wikipedia.org/wiki/Linear_multistep_method"> Linear multistep methods </a> as **Adams-Bashforth** \f[ u^{n+1} = u^n + \Delta t\sum_{j=0}^{s-1} b_j f\left(t^n - j \Delta t, u^{n-j}\right) \f] @note **Possible stages are X: 1, 2,..., 5**, the order of the method is the same as its stages @note The Adams-Bashforth schemes implemented here need less storage but may have **a smaller region of absolute stability** than for example an extrapolated BDF method of the same order. * eBDF-X-X | dg::eBDF_X_X | The family of schemes described in <a href = "https://doi.org/10.1137/S0036142902406326"> Hundsdorfer, W., Ruuth, S. J., & Spiteri, R. J. (2003). Monotonicity-preserving linear multistep methods. SIAM Journal on Numerical Analysis, 41(2), 605-623 </a> as **extrapolated BDF** where it is found to be TVB (**total variation bound**). The schemes also appear as **Minimal Projecting** scheme described in <a href = "https://www.ams.org/journals/mcom/1979-33-148/S0025-5718-1979-0537965-0/S0025-5718-1979-0537965-0.pdf"> Alfeld, P., Math. Comput. 33.148 1195-1212 (1979)</a> <br> @note **Possible stages are X: 1 (C=1), 2 (C=0.63), 3 (C=0.39), 4 (C=0.22), 5 (C=0.09), 6** with the order the same as the number of stages * TVB-X-X | dg::TVB_X_X | The family of schemes described in <a href="https://doi.org/10.1016/j.jcp.2005.02.029">S.J. Ruuth and W. Hundsdorfer, High-order linear multistep methods with general monotonicity and boundedness properties, Journal of Computational Physics, Volume 209, Issue 1, 2005 </a> as Total variation Bound. These schemes have larger allowable step sizes than the eBDF family, <br> @note **Possible values for X are 1 (C=1), 2 (C=0.5), 3 (C=0.54), 4 (C=0.46), 5 (C=0.38) 6 (C=0.33)**. We highlight that TVB-3-3 has 38% larger allowable stepsize than eBDF-3-3 and TVB-4-4 has 109% larger stepsize than eBDF-4-4 (to ensure the TVB property, not stability). * SSP-X-Y | dg::SSP_X_Y | The family of schemes described in <a href="https://doi.org/10.1007/BF02728985">Gottlieb, S. On high order strong stability preserving runge-kutta and multi step time discretizations. J Sci Comput 25, 105–128 (2005)</a> as Strong Stability preserving. We implement the lowest order schemes for each stage and disregard the remaining schemes in the paper since their CFL conditions are worse than the TVB scheme of the same order. @note **Possible values for X-Y : 1-1 (C=1), 2-2 (C=0.5), 3-2 (C=0.5), 4-2 (C=0.66), 5-3 (C=0.5), 6-3 (C=0.567)**.@note These schemes are noteworthy because the coefficients b_i are all positive except for the 2-2 method and **the "4-2" and "6-3" methods allow slightly larger allowable stepsize but increased storage requirements than TVB** of same order (2 and 3). *@note Total variation bound (TVB) means \f$ || v^n|| \leq M ||v^0||\f$ where the norm signifies the total variation semi-norm. Total variation diminishing (TVD) means M=1, and strong stability preserving (SSP) is the same as TVD, TVB schemes converge to the correct entropy solutions of hyperbolic conservation laws @note the CFL coefficient C is given relative to the forward Euler method: \f$ \Delta t < C \Delta t_{FE}\f$. @attention The coefficient C is the one that ensures the TVD property of the scheme and is **not** directly related to the stability region of the scheme */ /*! @class hide_implicit_multistep_tableaus * * Name | Identifier | Description * -------|------------| ----------- * BDF-X-X | dg::BDF_X_X | The coefficients for backward differences can be found at https://en.wikipedia.org/wiki/Backward_differentiation_formula <br> @note **Possible values for X: 1, 2, 3, 4, 5, 6** @note A BDF scheme is simply constructed by discretizing the time derivative with a n-th order backward difference formula and evaluating the right hand side at the new timestep. @note Methods with s>6 are not zero-stable so they cannot be used * */ /*! @brief Convert identifiers to their corresponding \c dg::MultistepTableau * * This is a helper class to simplify the interfaces of our timestepper functions and classes. * The sole purpose is to implicitly convert either a MultistepTableau or one of * the following identifiers to an instance of a MultistepTableau. * * Explicit methods * @copydoc hide_explicit_multistep_tableaus * Implicit methods * @copydoc hide_implicit_multistep_tableaus * Implicit-Explicit methods * @copydoc hide_imex_multistep_tableaus * @param real_type The type of the coefficients in the MultistepTableau * @ingroup time_utils */ template<class real_type> struct ConvertsToMultistepTableau { using value_type = real_type; ///Of course a MultistepTableau converts to a MultistepTableau ///Useful if you constructed your very own coefficients ConvertsToMultistepTableau( MultistepTableau<real_type> tableau): m_t(tableau){} /*! @brief Create MultistepTableau from \c dg::tableau_identifier * * The use of this constructor might be a bit awkward because you'll have to write all caps. * @param id the identifier, for example \c dg::eBDF_3_3 */ ConvertsToMultistepTableau( enum tableau_identifier id):m_t( dg::create::lmstableau<real_type>(id)){} /*! @brief Create MultistepTableau from its name (very useful) * * Explicit methods * @copydoc hide_explicit_multistep_tableaus * Implicit methods * @copydoc hide_implicit_multistep_tableaus * Implicit-Explicit methods * @copydoc hide_imex_multistep_tableaus * @param name The name of the tableau as stated in the Name column above, as a string, for example "eBDF-3-3" */ ConvertsToMultistepTableau( std::string name):m_t( dg::create::lmstableau<real_type>(name)){} ///@copydoc ConvertsToMultistepTableau(std::string) ConvertsToMultistepTableau( const char* name):m_t( dg::create::lmstableau<real_type>(std::string(name))){} ///Convert to MultistepTableau /// ///which means an object can be directly assigned to a MultistepTableau operator MultistepTableau<real_type>( )const{ return m_t; } private: MultistepTableau<real_type> m_t; }; }//namespace dg
41.110119
942
0.595707
[ "object", "vector" ]
2d42808e415157ee0a7986d66e60f2c4245213c4
8,109
c
C
neon/kyber/speed_ntt.c
GMUCERG/PQC_NEON
eac920400c21925b146e3e0d0c45e85f2334a92d
[ "Apache-2.0" ]
5
2021-06-25T17:33:39.000Z
2021-10-19T19:29:00.000Z
neon/kyber/speed_ntt.c
GMUCERG/PQC_NEON
eac920400c21925b146e3e0d0c45e85f2334a92d
[ "Apache-2.0" ]
null
null
null
neon/kyber/speed_ntt.c
GMUCERG/PQC_NEON
eac920400c21925b146e3e0d0c45e85f2334a92d
[ "Apache-2.0" ]
2
2021-06-03T14:10:26.000Z
2021-10-02T06:16:28.000Z
#include <stdio.h> #include <arm_neon.h> #include <sys/random.h> #include <string.h> #include <assert.h> #include "polyvec.h" #include "params.h" #include "neon_ntt.h" #include "reduce.h" #include "print.h" #include <time.h> // clang ntt.c reduce.c neon_ntt.c speed_ntt.c -o neon_ntt -O3 -g3 -Wall -Werror -Wextra -Wpedantic -lpapi // gcc ntt.c reduce.c neon_ntt.c speed_ntt.c -o neon_ntt -O3 -g3 -Wall -Werror -Wextra -Wpedantic -lpapi const int16_t zetas[128] = { -1044, -758, -359, -1517, 1493, 1422, 287, 202, -171, 622, 1577, 182, 962, -1202, -1474, 1468, 573, -1325, 264, 383, -829, 1458, -1602, -130, -681, 1017, 732, 608, -1542, 411, -205, -1571, 1223, 652, -552, 1015, -1293, 1491, -282, -1544, 516, -8, -320, -666, -1618, -1162, 126, 1469, -853, -90, -271, 830, 107, -1421, -247, -951, -398, 961, -1508, -725, 448, -1065, 677, -1275, -1103, 430, 555, 843, -1251, 871, 1550, 105, 422, 587, 177, -235, -291, -460, 1574, 1653, -246, 778, 1159, -147, -777, 1483, -602, 1119, -1590, 644, -872, 349, 418, 329, -156, -75, 817, 1097, 603, 610, 1322, -1285, -1465, 384, -1215, -136, 1218, -1335, -874, 220, -1187, -1659, -1185, -1530, -1278, 794, -1510, -854, -870, 478, -108, -308, 996, 991, 958, -1460, 1522, 1628}; /************************************************* * Name: fqmul * * Description: Multiplication followed by Montgomery reduction * * Arguments: - int16_t a: first factor * - int16_t b: second factor * * Returns 16-bit integer congruent to a*b*R^{-1} mod q **************************************************/ static int16_t fqmul(int16_t a, int16_t b) { return montgomery_reduce((int32_t)a*b); } /************************************************* * Name: ntt * * Description: Inplace number-theoretic transform (NTT) in Rq. * input is in standard order, output is in bitreversed order * * Arguments: - int16_t r[256]: pointer to input/output vector of elements of Zq **************************************************/ static void ntt(int16_t r[256]) { unsigned int len, start, j, k; int16_t t, zeta; k = 1; for(len = 128; len >= 2; len >>= 1) { for(start = 0; start < 256; start = j + len) { zeta = zetas[k++]; for(j = start; j < start + len; j++) { t = fqmul(zeta, r[j + len]); r[j + len] = r[j] - t; r[j] = r[j] + t; } } } } /************************************************* * Name: invntt_tomont * * Description: Inplace inverse number-theoretic transform in Rq and * multiplication by Montgomery factor 2^16. * Input is in bitreversed order, output is in standard order * * Arguments: - int16_t r[256]: pointer to input/output vector of elements of Zq **************************************************/ static void invntt(int16_t r[256]) { unsigned int start, len, j, k; int16_t t, zeta; const int16_t f = 1441; // mont^2/128 // int32_t overflow; k = 127; for(len = 2; len <= 128; len <<= 1) { for(start = 0; start < 256; start = j + len) { zeta = zetas[k--]; for(j = start; j < start + len; j++) { t = r[j]; /* overflow = (int32_t) t + r[j + len]; if (overflow > INT16_MAX) { printf("%d: [%d] overflow: %d\n", len, j ,overflow); } else if (overflow < INT16_MIN) { printf("%d: [%d] overflow: %d\n", len, j, overflow); } if (len > 4) { } else{ r[j] = (t + r[j + len]); } */ r[j] = barrett_reduce(t + r[j + len]); r[j + len] = r[j + len] - t; r[j + len] = fqmul(zeta, r[j + len]); } } } for(j = 0; j < 256; j++) r[j] = fqmul(r[j], f); } /* static int compare_strict(int16_t *a, int16_t *b, int length, const char *string) { int i, j, count = 0; int16_t aa, bb; for (i = 0; i < length; i += 8) { for (j = i; j < i + 8; j++) { aa = a[j]; bb = b[j]; if (aa != bb) { printf("%d: %d != %d\n", j, aa, bb); count += 1; } if (count > 8) { printf("%s Incorrect!!\n", string); return 1; } } } if (count) { printf("%s Incorrect!!\n", string); return 1; } printf("OK: %s\n", string); return 0; } */ static int compare(int16_t *a, int16_t *b, int length, const char *string) { int i, j, count = 0; int16_t aa, bb; for (i = 0; i < length; i += 8) { for (j = i; j < i + 8; j++) { aa = a[j]; //% KYBER_Q; bb = b[j]; //% KYBER_Q; if (aa != bb) { if ((aa + KYBER_Q == bb) || (aa - KYBER_Q == bb)) { printf("%d: %d != %d: %d != %d ", j, a[j], b[j], aa, bb); printf(": OK\n"); } else { printf("%d: %d != %d: %d != %d: Error\n", j, a[j], b[j], aa, bb); count++; } } if (count > 16) { printf("%s Incorrect!!\n", string); return 1; } } } if (count) { printf("%s Incorrect!!\n", string); return 1; } return 0; } static void poly_reduce(poly *r) { unsigned int i; for (i = 0; i < KYBER_N; i++) r->coeffs[i] = barrett_reduce(r->coeffs[i]); } static void poly_ntt(poly *r) { ntt(r->coeffs); poly_reduce(r); } static void poly_neon_ntt(poly *r) { neon_ntt(r->coeffs); poly_reduce(r); } static void print_array(const int16_t *buf, int buflen, const char *string) { printf("%s: [", string); for (int i = 0; i < buflen; i++) { printf("%d, ", buf[i]); } printf("]\n"); } static void reduce(int16_t r[256]) { for (int i = 0; i < 256; i++) { r[i] = barrett_reduce(r[i]); } } #define TEST1 1000000 #define TEST2 0 int main(void) { int16_t r_gold[256], r1[256], r2[256]; int retval; int comp = 0; clock_t start, end; getrandom(r_gold, sizeof(r_gold), 0); for (int i = 0; i < 256; i++) { r_gold[i] = barrett_reduce(r_gold[i]); assert(r_gold[i] < INT16_MAX); assert(INT16_MIN < r_gold[i]); } memcpy(r1, r_gold, sizeof(r_gold)); memcpy(r2, r_gold, sizeof(r_gold)); // Test NTT // retval = PAPI_hl_region_begin("c_ntt"); start = clock(); for (int j = 0; j < TEST1; j++) { ntt(r_gold); } end = clock() - start; print("ntt:", ((double) end)/CLOCKS_PER_SEC); // retval = PAPI_hl_region_end("c_ntt"); // retval = PAPI_hl_region_begin("neon_ntt"); start = clock(); for (int j = 0; j < TEST1; j++) { neon_ntt(r1); } end = clock() - start; print("neon_ntt:", ((double) end)/CLOCKS_PER_SEC); // retval = PAPI_hl_region_end("neon_ntt"); comp = compare(r_gold, r1, 256, "c_ntt vs neon_ntt"); if (comp) return 1; reduce(r_gold); reduce(r1); // Test INTT // retval = PAPI_hl_region_begin("c_invntt"); start = clock(); for (int j = 0; j < TEST1; j++) { invntt(r_gold); } end = clock() - start; print("invntt:", ((double) end)/CLOCKS_PER_SEC); // retval = PAPI_hl_region_end("c_invntt"); // retval = PAPI_hl_region_begin("neon_invntt"); start = clock(); for (int j = 0; j < TEST1; j++) { neon_invntt(r1); } end = clock() - start; print("neon_invntt:", ((double) end)/CLOCKS_PER_SEC); // retval = PAPI_hl_region_end("neon_invntt"); comp = compare(r_gold, r1, 256, "c_invntt vs neon_invntt"); if (comp) return 1; if (retval) return 1; polyvec rvec_gold; polyvec rvec_test; for (int k = 0; k < TEST2; k++) { for (int j = 0; j < KYBER_K; j++) { getrandom(rvec_gold.vec[j].coeffs, 256, 0); for (int i = 0; i < 256; i++) { rvec_gold.vec[j].coeffs[i] %= KYBER_Q; } memcpy(rvec_test.vec[j].coeffs, rvec_gold.vec[j].coeffs, sizeof(r_gold)); poly_ntt(&rvec_gold.vec[j]); poly_neon_ntt(&rvec_test.vec[j]); comp |= compare(rvec_gold.vec[j].coeffs, rvec_test.vec[j].coeffs, 256, "rvec_gold vs rvec_test"); if (comp) { printf("ERROR poly_ntt\n"); return 1; } } } return 0; }
23.641399
106
0.513997
[ "vector", "transform" ]
2d4439bf0d31ac805e7039bc026182101ed46046
1,427
h
C
rsyn/src/rsyn/qt/graphics/view/layout/layer/Floorplan.h
RsynTeam/rsyn-x
3855afbf6d25347f7d91f86aba8d1b1664373563
[ "Apache-2.0" ]
58
2018-08-28T18:39:15.000Z
2021-12-21T09:06:15.000Z
rsyn/src/rsyn/qt/graphics/view/layout/layer/Floorplan.h
zrpstc/rsyn-x
3855afbf6d25347f7d91f86aba8d1b1664373563
[ "Apache-2.0" ]
15
2018-08-31T11:44:37.000Z
2021-12-30T07:21:38.000Z
rsyn/src/rsyn/qt/graphics/view/layout/layer/Floorplan.h
zrpstc/rsyn-x
3855afbf6d25347f7d91f86aba8d1b1664373563
[ "Apache-2.0" ]
37
2018-09-14T07:59:03.000Z
2022-03-28T06:30:22.000Z
/* Copyright 2014-2018 Rsyn * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef RSYN_FLOORPLAN_GRAPHICS_LAYER_H #define RSYN_FLOORPLAN_GRAPHICS_LAYER_H #include "rsyn/qt/graphics/view/layout/LayoutGraphicsLayer.h" #include <QRect> namespace Rsyn { class LayoutGraphicsScene; class FloorplanLayoutGraphicsLayer : public LayoutGraphicsLayer { private: QRect clsCoreBounds; public: FloorplanLayoutGraphicsLayer(); ~FloorplanLayoutGraphicsLayer(); virtual bool init(LayoutGraphicsScene *scene, std::vector<GraphicsLayerDescriptor> &visibilityItems) override; virtual void render(QPainter *painter, const float lod, const QRectF &exposedRect) override; private: void renderCoreBounds(QPainter * painter); void renderPhysicalRows(QPainter * painter); void renderPhysicalSites(QPainter * painter); void renderLayoutRegions(QPainter * painter); }; // end class } // end namespace #endif
27.442308
111
0.774352
[ "render", "vector" ]
2d5cc1d6fd3c0888e7c2e11366bc1a3517e7cf0e
7,624
h
C
MathTL/numerics/corner_singularity.h
kedingagnumerikunimarburg/Marburg_Software_Library
fe53c3ae9db23fc3cb260a735b13a1c6d2329c17
[ "MIT" ]
3
2018-05-20T15:25:58.000Z
2021-01-19T18:46:48.000Z
MathTL/numerics/corner_singularity.h
agnumerikunimarburg/Marburg_Software_Library
fe53c3ae9db23fc3cb260a735b13a1c6d2329c17
[ "MIT" ]
null
null
null
MathTL/numerics/corner_singularity.h
agnumerikunimarburg/Marburg_Software_Library
fe53c3ae9db23fc3cb260a735b13a1c6d2329c17
[ "MIT" ]
2
2019-04-24T18:23:26.000Z
2020-09-17T10:00:27.000Z
// -*- c++ -*- // +--------------------------------------------------------------------+ // | This file is part of MathTL - the Mathematical Template Library | // | | // | Copyright (c) 2002-2009 | // | Thorsten Raasch, Manuel Werner | // +--------------------------------------------------------------------+ #ifndef _MATHTL_CORNER_SINGULARITY_H #define _MATHTL_CORNER_SINGULARITY_H #include <geometry/point.h> #include <utils/function.h> namespace MathTL { /*! Corner singularity function w.r.t. a reentrant corner at x0 in a polygonal domain in R^2. In polar coordinates w.r.t. the corner, the function looks like s(r,theta) = zeta(r)*r^{pi/omega}*sin((pi/omega)*theta), where zeta:[0,infty)->R is the smooth cutoff function zeta(r) = w(r1-r)/(w(r-r0)+w(r1-r)) w(t) = exp(-1/t^2) for t>0 and 0 elsewhere This yields exactly the function S_{l,1} from [D]. References: [D] Dahlke, Besov regularity for elliptic boundary value problems on polygonal domains, Appl. Math. Lett. 12(1999), 31-36 */ class CornerSingularity : public Function<2> { public: /*! constructor from a corner x0, a starting angle theta0 (times pi, against positive x-axis) and an inner angle omega (times pi); */ CornerSingularity(const Point<2>& x0, const double theta0, const double omega, const double r0 = 0.01, const double r1 = 0.99); //! destructor virtual ~CornerSingularity() {} //! point value at x double value(const Point<2>& x, const unsigned int component = 0) const; //! vector-valued value at x (for compatibility with Function) void vector_value(const Point<2>& p, Vector<double>& values) const; protected: //! corner Point<2> x0; //! starting angle double theta0; //! inner angle double omega; //! cutoff parameters double r0, r1; //! the cutoff function double zeta(const double r) const; }; /*! This class models -\Delta s(x), where s(x) is the corner singularity function from above. */ class CornerSingularityRHS : public Function<2> { public: /*! constructor from a corner x0, a starting angle theta0 (times pi, against positive x-axis) and an inner angle omega (times pi); */ CornerSingularityRHS(const Point<2>& x0, const double theta0, const double omega, const double r0 = 0.01, const double r1 = 0.99); //! destructor virtual ~CornerSingularityRHS() {} //! point value at x double value(const Point<2>& x, const unsigned int component = 0) const; //! vector-valued value at x (for compatibility with Function) void vector_value(const Point<2>& p, Vector<double>& values) const; protected: //! corner Point<2> x0; //! starting angle double theta0; //! inner angle double omega; //! cutoff parameters double r0, r1; //! the cutoff function double zeta(const double r) const; //! first derivative of the cutoff function double zeta_prime(const double r) const; //! second derivative of the cutoff function double zeta_primeprime(const double r) const; }; /*! This class models \nabla s(x), where s(x) is the corner singularity function from above. */ class CornerSingularityGradient : public Function<2> { public: /*! constructor from a corner x0, a starting angle theta0 (times pi, against positive x-axis) and an inner angle omega (times pi); */ CornerSingularityGradient(const Point<2>& x0, const double theta0, const double omega, const double r0 = 0.01, const double r1 = 0.99); //! destructor virtual ~CornerSingularityGradient() {} //! point value at x double value(const Point<2>& x, const unsigned int component = 0) const; //! vector-valued value at x (for compatibility with Function) void vector_value(const Point<2>& p, Vector<double>& values) const; protected: //! corner Point<2> x0; //! starting angle double theta0; //! inner angle double omega; //! cutoff parameters double r0, r1; //! the cutoff function double zeta(const double r) const; //! first derivative of the cutoff function double zeta_prime(const double r) const; }; /*! A time--dependent corner singularity function w.r.t. to the reentrant corner at x0 in a polygonal domain in R^2. In polar coordinates w.r.t. the corner, the function looks like s(r,theta) = t^{3/4}*r^{pi/omega}*sin((pi/omega)*theta)*(1-x^2)*(1-y^2) with x=r*cos(theta0+theta), y=r*sin(theta0+theta). This function was used in [GSS+] as a test function for the heat equation on the L--shaped domain in R^2. References: [GSS+] */ class CornerTimeSingularity : public Function<2> { public: /*! constructor from a corner x0, a starting angle theta0 (times pi, against positive x-axis) and an inner angle omega (times pi); */ CornerTimeSingularity(const Point<2>& x0, const double theta0, const double omega); //! destructor virtual ~CornerTimeSingularity() {} //! point value at x double value(const Point<2>& x, const unsigned int component = 0) const; //! vector-valued value at x (for compatibility with Function) void vector_value(const Point<2>& p, Vector<double>& values) const; protected: //! corner Point<2> x0; //! starting angle double theta0; //! inner angle double omega; }; /*! u'(t,x,y)-Delta u(t,x,y) of CornerTimeSingularity */ class CornerTimeSingularityRHS : public Function<2> { public: /*! constructor from a corner x0, a starting angle theta0 (times pi, against positive x-axis) and an inner angle omega (times pi); */ CornerTimeSingularityRHS(const Point<2>& x0, const double theta0, const double omega); //! destructor virtual ~CornerTimeSingularityRHS() {} //! point value at x double value(const Point<2>& x, const unsigned int component = 0) const; //! vector-valued value at x (for compatibility with Function) void vector_value(const Point<2>& p, Vector<double>& values) const; protected: //! corner Point<2> x0; //! starting angle double theta0; //! inner angle double omega; }; /*! temporal derivative of CornerTimeSingularityRHS */ class CornerTimeSingularityRHSt : public Function<2> { public: /*! constructor from a corner x0, a starting angle theta0 (times pi, against positive x-axis) and an inner angle omega (times pi); */ CornerTimeSingularityRHSt(const Point<2>& x0, const double theta0, const double omega); //! destructor virtual ~CornerTimeSingularityRHSt() {} //! point value at x double value(const Point<2>& x, const unsigned int component = 0) const; //! vector-valued value at x (for compatibility with Function) void vector_value(const Point<2>& p, Vector<double>& values) const; protected: //! corner Point<2> x0; //! starting angle double theta0; //! inner angle double omega; }; } // implementations of inline functions #include "numerics/corner_singularity.cpp" #endif
24.996721
91
0.608211
[ "geometry", "vector" ]
2d5f4647290459b3c6810e305532dfbfa7517a2d
1,842
h
C
Code/branches/Pre-Prospectus/cpp/FissionSource/HistSource.h
jlconlin/PhDThesis
8e704613721a800ce1c59576e94f40fa6f7cd986
[ "MIT" ]
null
null
null
Code/branches/Pre-Prospectus/cpp/FissionSource/HistSource.h
jlconlin/PhDThesis
8e704613721a800ce1c59576e94f40fa6f7cd986
[ "MIT" ]
null
null
null
Code/branches/Pre-Prospectus/cpp/FissionSource/HistSource.h
jlconlin/PhDThesis
8e704613721a800ce1c59576e94f40fa6f7cd986
[ "MIT" ]
null
null
null
/*HistSource.h $Author: jlconlin $ $Id: HistSource.h 239 2008-01-07 17:47:47Z jlconlin $ $Revision: 239 $ $Date: 2008-01-07 10:47:47 -0700 (Mon, 07 Jan 2008) $ This file contains header information for the HistSource class. A HistSource object will be the default FissionSource object for Arnoldi's method. */ #ifndef HISTSOURCE_H #define HISTSOURCE_H #include <vector> #include <numeric> #include <cmath> #include "Field.hh" #include "OneDCartMesh.hh" #include "FissionSource.h" #include "Particle.h" using std::vector; using std::accumulate; typedef Field<Zone, double> Field_Zd; // For simplicity class HistSource : public Field_Zd, FissionSource { public: // Constructor required for Markov class HistSource( const HistSource& source) : Field_Zd(source.mMesh, 0.0), FissionSource(source.seed()), _CDF(mData.size(), 0.0) { makeDF(); } // No need to create DFs because they will be zero /*seed: Random number generator seed M: Mesh describing geometry of source Probs: Probability of picking from each zone in Mesh*/ HistSource(const std::vector<unsigned long>& seed, Mesh& M, std::vector<double> Probs) : Field_Zd(M, Probs), FissionSource(seed), _CDF(mData.size(), 0.0) { makeDF(); } /*seed: Random number generator seed F: Field_Zd describing sampling probabilities*/ HistSource(const std::vector<unsigned long>& seed, Field_Zd F) : Field_Zd(F), FissionSource(seed), _CDF(mData.size(), 0.0) { makeDF(); } ~HistSource() { } void sample( Particle& P ); int size() const; void makeDF(); // Make PDF and CDF private: vector<double> _CDF; HistSource& operator=( const HistSource& ); }; #endif
27.909091
78
0.640065
[ "mesh", "geometry", "object", "vector" ]
2d628ee4e8b600608c4cc5e4edab2ad7d6116d01
10,278
c
C
src/json.c
mark4th/uCurses
7ad3a64e13cb9d602618c28999cef3bf5f1f5828
[ "MIT" ]
4
2021-03-08T23:55:45.000Z
2021-06-29T01:06:10.000Z
src/json.c
mark4th/uCurses
7ad3a64e13cb9d602618c28999cef3bf5f1f5828
[ "MIT" ]
null
null
null
src/json.c
mark4th/uCurses
7ad3a64e13cb9d602618c28999cef3bf5f1f5828
[ "MIT" ]
2
2021-03-13T22:28:29.000Z
2021-05-01T08:53:38.000Z
// uCurses json parsing for user interface layout // ----------------------------------------------------------------------- #include <fcntl.h> #include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #include "h/uCurses.h" // ----------------------------------------------------------------------- // memory map flags #define MAP_FLAGS PROT_READ | PROT_WRITE // ----------------------------------------------------------------------- // There are 5 states in this state machine as follows // // STATE_L_BRACE // STATE_KEY // STATE_VALUE // STATE_R_BRACE // STATE_DONE // // The initial state is STATE_L_BRACE which expects the next token parsed // to be the left brace '{' char. If it is then the state is set to // STATE_KEY. // // The handler for STATE_KEY expect to see one of several known tokens // which will either be a 'key' token or an 'object' token. When parsing // tokens no C string compare routines are used, all tokens are recognized // by their 32 bit fnv-1a hash value. // // If the parsed token is recognized as a key // // That specifc key is handled (see below) and the next state is set // to STATE_VALUE where we extract the value to be stored in the // specified key. // // If the parsed token is one of the recognized objects // // The state is set once again to STATE_L_BRACE. // // Almost every STATE_L_BRACE indicates that a new object and thereby an // associated C structure is being created. // // For every object and every key the machine will transition into a new // state. If the previous state was an object that object state is // pushed onto a state stack. Key states simply replace the previous key // state, they are never pushed onto the state stack. // // Any time a new object or key token is parsed in we check to see if // there is a comma on it. If there is no comma the next state will // instead be STATE_R_BRACE. This state pops the previous state off the // stack. // // As key values are parsed we immediately set the specified item in // their parents C structure. When an object is completed we store // the associated C structure within its parents C structure. The // structure types of both specify how and where. // // When all states have been popped off the stack we transition into // STATE_DONE and the state machine terminates. // // This code also knows what keys may go inside what objects and what // objects may go inside what objects. Any time you try to do something // such as define a screen inside a window this code will abort with an // error message indicating the offending json line. // // As stated above, some object states do not have an associated C // structure. Any keys specified within these psudo object will be // assigned instead to the psudo objects parent C structure. I.E. the // keys grandparent. // ----------------------------------------------------------------------- char *json_data; // pointer to json data to be parsed size_t json_len; // total size of json data int32_t json_index; // parse index into data (current line) char line_buff[MAX_LINE_LEN]; int16_t line_no; int16_t line_index; // line parse location int16_t line_left; // number of chars left to parse in line // space delimited token extracted from data - +1 for the null char json_token[TOKEN_LEN + 1]; int32_t json_hash; list_t j_stack; fp_finder_t fp_finder; int16_t console_width; int16_t console_height; // ----------------------------------------------------------------------- // the current state j_state_t *j_state; // ----------------------------------------------------------------------- // fnv-1a hash values for various json syntax chars const int32_t json_syntax[] = // { 0x050c5d25, // : 0x050c5d64, // { 0x050c5d62, // } }; // ----------------------------------------------------------------------- // push current state onto end of state stack static void j_push(j_state_t *j) { list_append_node(&j_stack, j_state); j_state = j; } // ----------------------------------------------------------------------- // deallocate current state structure but not the C structure associated // with it. then pop previous state off stack void j_pop(void) { free(j_state); j_state = list_pop(&j_stack); } // ----------------------------------------------------------------------- __attribute__((noreturn)) void json_error(const char *s) { char msg[128]; sprintf(msg, "%d:%d %s\n", line_no, line_index, s); xabort(msg); } // ----------------------------------------------------------------------- void *j_alloc(uint32_t size) { void *v = calloc(1, size); if(v != NULL) { return v; } json_error("Out of Memory!"); } // ----------------------------------------------------------------------- // json files and individual objects must start with a { static void json_state_l_brace(void) { if(json_hash == json_syntax[JSON_L_BRACE]) { j_state->state = STATE_KEY; return; } json_error("Opening brace missing"); } // ----------------------------------------------------------------------- // every object and every key gets its own state structure allocation. // the current object state level is always in the j_state variable. // previous object states are pushed onto the json parse stack. key value // states are never pushed onto the state stack void json_new_state_struct(size_t struct_size, int32_t struct_type) { j_state_t *j; void *structure; // allocate a structure for the new state j = j_alloc(sizeof(*j)); // if there is one allocate buffer for C structure for subseqeuent // keys to populate structure = // (struct_size != 0) // ? j_alloc(struct_size) : NULL; j->parent = j_state; j->structure = structure; j->struct_type = struct_type; // push previous state and make new state the current state j_push(j); } // ----------------------------------------------------------------------- static INLINE uint16_t check_comma(void) { int16_t rv = 0; int16_t end = strlen(json_token) - 1; if(json_token[end] == ',') { json_token[end] = '\0'; json_hash = fnv_hash(json_token); rv = 1; } return rv; } // ----------------------------------------------------------------------- void json_state_r_brace(void) { int16_t has_comma; has_comma = check_comma(); if(json_hash != json_syntax[JSON_R_BRACE]) { json_error("Closing brace missing"); } // thanks username234 for helping me find this!!! // if the current structures parent is null then the current structure // is the screen that has no parent so dont try to populate the non // existant parent with the screen structure! the real question here is // how the hell did this code work when compiled with clang? :) if(j_state->struct_type != STRUCT_SCREEN) { // a right brace terminates a json object. we need to add // the current object to its parents structure (or in some cases // to its grandparent as its dirce parent is a dummy object) populate_parent(); } j_state->state = STATE_DONE; if(j_stack.count != 0) { if(j_state->struct_type != STRUCT_SCREEN) { j_pop(); if(j_state != NULL) { j_state->state = // (has_comma != 0) // ? STATE_KEY : STATE_R_BRACE; } } } } // ----------------------------------------------------------------------- static const switch_t states[] = // { { STATE_L_BRACE, json_state_l_brace }, { STATE_KEY, json_state_key }, { STATE_VALUE, json_state_value }, { STATE_R_BRACE, json_state_r_brace }, }; // ----------------------------------------------------------------------- static INLINE void json_state_machine(void) { int f; j_state = j_alloc(sizeof(*j_state)); j_state->struct_type = -1; j_state->state = JSON_L_BRACE; j_stack.count = 0; json_index = 0; do { token(); json_hash = fnv_hash(json_token); // the token does not define what the state is // the state defines what the token must be f = re_switch(states, NUM_STATES, j_state->state); if(f == -1) { json_error("Unknown or out of place token"); } } while(j_state->state != STATE_DONE); j_pop(); free(j_state); } // ----------------------------------------------------------------------- // when the state machine parses in the structues that define the app // menus it will need to add function pointers to every menu item to be // executed when that menu item is selected. this library can not // determine the address of any functions in the application code it is // linked against. said application will need to supply this library // with a pointer to a function that will return a pointer to a menu // function based off of a string. The HOW of this needs better // documentation than im prepared to put in source file comments :) void json_create_ui(char *path, fp_finder_t fp) { int result; struct winsize w; ioctl(0, TIOCGWINSZ, &w); console_width = w.ws_col; console_height = w.ws_row; struct stat st; fp_finder = fp; int fd = open(path, O_RDONLY); if(fd < 0) { json_error("Cannot open JSON file"); } result = fstat(fd, &st); if(result != 0) { json_error("Cannot stat JSON file"); } json_len = st.st_size; json_data = mmap(NULL, json_len, MAP_FLAGS, MAP_PRIVATE, fd, 0); close(fd); if(json_data == MAP_FAILED) { json_error("Unable to map JSON file"); } json_de_tab(json_data, json_len); line_no = 1; json_state_machine(); munmap(json_data, json_len); if(active_screen != NULL) { json_build_ui(); } } // =======================================================================
27.703504
75
0.571512
[ "object" ]
2d77ab68cab99ab3f204011d6792135fc803553a
1,358
h
C
Projects/AsteroidGame/BulletNode.h
TywyllSoftware/TywRenderer
2da2ea2076d4311488b8ddb39c2fec896c98378a
[ "Unlicense" ]
11
2016-11-15T20:06:19.000Z
2021-03-31T01:04:01.000Z
Projects/AsteroidGame/BulletNode.h
TywyllSoftware/TywRenderer
2da2ea2076d4311488b8ddb39c2fec896c98378a
[ "Unlicense" ]
1
2016-11-06T23:53:05.000Z
2016-11-07T08:06:07.000Z
Projects/AsteroidGame/BulletNode.h
TywyllSoftware/TywRenderer
2da2ea2076d4311488b8ddb39c2fec896c98378a
[ "Unlicense" ]
2
2017-09-03T11:18:46.000Z
2019-03-10T06:27:49.000Z
#pragma once #include "SceneNode.h" //forward declaration struct Actor; class IEventData; /* BulletNode is the root node for asteroid. It will keep a list of all asteroid actors and will keep information that is needed to render bullet. Bullet node could be made as particle node . With lifespan and other fancy particle things. Something like this maybe ? ISceneNode->SceneNode->ParticleSystem->BulletNode (... hmmm... nope. nope ... nope) Too many VTable's and everything would get messier. Maybe this? (Use composion and aggregation) ISceneNode->SceneNode->BulletNode { struct Bullet { ParticleDetails ? } } */ class BulletNode final : public SceneNode { public: BulletNode(void *pTexture); ~BulletNode(); void VUpdate(long timestamp) override; void VRender() override; //Reserve bullets size void ReserveBullets(int size) { m_itActors.resize(size); } //Clear Actors void DeletActors() { m_itActors.clear(); } //Needed for bullet location (from where bullets will be fired ) void AddBulletLocationOrigin(Actor* pActor) { m_pOrigin = pActor; } //During fire event void OnFireEvent(); //Check collision against current character bool CheckCollision(const Actor& pActor); private: std::vector<Actor> m_itActors; void * m_pTexture; Actor* m_pOrigin; // bullet firing state int m_nextFiredBulletIndex; int m_rapidFireTimer; };
22.633333
91
0.756259
[ "render", "vector" ]
2d77bc3f89b94335267ce16e34d06e478438ed8f
1,160
h
C
Data.h
peddrinn/supervisao_condensador
1f5af062b45b028cf47aa231ee382f9a3914ee29
[ "MIT" ]
null
null
null
Data.h
peddrinn/supervisao_condensador
1f5af062b45b028cf47aa231ee382f9a3914ee29
[ "MIT" ]
null
null
null
Data.h
peddrinn/supervisao_condensador
1f5af062b45b028cf47aa231ee382f9a3914ee29
[ "MIT" ]
1
2018-06-11T12:34:05.000Z
2018-06-11T12:34:05.000Z
#ifndef DATA_H #define DATA_H #include <iostream> #include <vector> #include <string> #include "Formato.h" // OBS TODOS CONSTRUTORES CHAMAM validaData(); //e uma exceão using namespace std; class Data { int dia; int mes; int ano; int hora; int minuto; int segundo; int diaSemana; // de 0 a 6 que representa os dias da semana long int ticks; // Número de segundos desde 01/01/1970 //Formato formato; // pt-br ou en-us Data ticksToDate(); long int dateToTicks(); public: int getDia(); int getMes(); int getAno(); int getHora(); int getMin(); int getSeg(); int getFormat(); // por default é pt-br int getDiaSemana(); void validaData(); // NO TP3 DIZ PARA SER DO TIPO BOOL - VERIFICAR Data now(); void printData(); //imprime a data na tela conforme o formato. Verificar o formato string getData(); // Retorna a data formatada como string bool operator>(Data &other); bool operator<(Data &other); bool operator==(Data &other); Data operator-(Data &other);//Para subtrair dias void operator=(Data &other); Data operator+(Data &other); // Para somar dias Data(); Data(string s); ~Data(); }; #endif // DATA_H
22.745098
84
0.680172
[ "vector" ]
2d7a5eb95d107a8487dc4dbf6a43de57ec5a669c
60,525
c
C
multimedia/directx/dxg/dd/ddraw/main/ddpal.c
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
multimedia/directx/dxg/dd/ddraw/main/ddpal.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
multimedia/directx/dxg/dd/ddraw/main/ddpal.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*========================================================================== * * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved. * * File: ddpal.c * Content: DirectDraw palette functions * History: * Date By Reason * ==== == ====== * 27-jan-95 craige initial implementation * 11-mar-95 craige more HAL fns, filled out CreatePalette * 19-mar-95 craige use HRESULTs, process termination cleanup fixes * 26-mar-95 craige filled out remaining fns * 28-mar-95 craige switched to PALETTEENTRY from RGBQUAD * 31-mar-95 craige use critical sections with palettes * 01-apr-95 craige happy fun joy updated header file * 04-apr-95 craige use driver directly in exclusive mode * 07-apr-95 craige bug 14 - check GUID ptr in QI * 10-apr-95 craige mods to process list stuff * bug 3,16 - palette issues: use driver in excl. mode * 12-apr-95 craige don't use GETCURRPID all the time; proper csect ordering * 06-may-95 craige use driver-level csects only * 12-may-95 craige check for real guids in QI * 02-jun-95 craige extra parm in AddToActiveProcessList * 12-jun-95 craige new process list stuff * 20-jun-95 kylej moved palette emulation code into ddhel * 21-jun-95 craige couple of internal inteface cleanup issues * 25-jun-95 craige one ddraw mutex * 26-jun-95 craige reorganized surface structure * 28-jun-95 craige ENTER_DDRAW at very start of fns * 02-jul-95 craige implemented GetCaps; added SEH for parm. validation * 04-jul-95 craige YEEHAW: new driver struct * 05-jul-95 craige added Initialize * 08-jul-95 kylej Surface and DirectDraw Palette calls require * exclusive mode. Removed ResetSysPalette. Make a * SetPalette call to the HAL/HEL to detach a palette. * 11-jul-95 craige fail aggregation calls * 13-jul-95 craige bug 94 - flag validation fixes * 20-jul-95 craige stop palette code from running non-palettized * 31-jul-95 toddla unselect palette in InternalPaletteRelease * 31-jul-95 craige validate flags * 21-aug-95 craige mode X support * 27-aug-95 craige bug 735: added SetPaletteAlways * bug 742: use ALLOW256 * 14-oct-95 colinmc add support for attaching palettes to offscreen and * texture map surfaces * 07-nov-95 colinmc support for 1, 2 and 4-bit palettes and palette * sharing added * 09-dec-95 colinmc added execute buffer support * 02-jan-96 kylej handle new interface structs * 09-feb-96 colinmc surface lost flag moved from global to local object * 03-mar-96 colinmc fixed problem with QueryInterface returning local * object rather than interface. * 13-mar-96 colinmc added IID validation to QueryInterface * 16-mar-96 colinmc fixed problem with palettes being released too many * times * 19-mar-96 colinmc Bug 12129: Bogus lpColorTable causes CreatePalette * to bomb * 19-apr-96 colinmc Bug 17473: CreatePalette faults on bogus palette * pointer * 02-may-96 kylej Bug 20066: GetPalette doesn't NULL pointer on failure * 23-sep-96 ketand Added TIMING routines * 24-mar-97 jeffno Optimized Surfaces * 26-nov-97 t-craigs Added IDirectDrawPalette2 stuff * ***************************************************************************/ #include "ddrawpr.h" #define SIZE_DDPCAPS (DDPCAPS_1BIT | DDPCAPS_2BIT | DDPCAPS_4BIT | DDPCAPS_8BIT) #define PE_FLAGS (PC_NOCOLLAPSE |PC_RESERVED) #define BITS_PER_BITFIELD_ENTRY (sizeof(DWORD)*8) /* * Generate a palette handle. We keep a bitfiled in the ddraw local that * tells us if we can recycle a handle. Note that handles are 1-based, * and these routines deal with that */ DWORD GeneratePaletteHandle(LPDDRAWI_DIRECTDRAW_LCL lpDD_lcl) { DWORD cbits,*pdw; /* * Check for an unused entry in the palette-handle-used bitfield. We check */ for (cbits=0; cbits< lpDD_lcl->cbitsPaletteBitfieldBitCount; cbits++ ) { if ( 0 == (lpDD_lcl->pPaletteHandleUsedBitfield[cbits/BITS_PER_BITFIELD_ENTRY] & (1<<(cbits % BITS_PER_BITFIELD_ENTRY))) ) { /* * Found a recycled handle */ lpDD_lcl->pPaletteHandleUsedBitfield[cbits/BITS_PER_BITFIELD_ENTRY] |= (1<<(cbits % BITS_PER_BITFIELD_ENTRY)); return cbits+1; //plus one since 0 is error return } } /* * Didn't find a recycled entry. Get a new handle */ DDASSERT( cbits == lpDD_lcl->cbitsPaletteBitfieldBitCount ); if ( (cbits% BITS_PER_BITFIELD_ENTRY) == 0) { /* * Have to grow the table since the current table fits exactly in a number of DWORDs */ pdw = MemAlloc( ((cbits / BITS_PER_BITFIELD_ENTRY) +1)*sizeof(DWORD) ); if (pdw) { /* * Couldn't convince myself the MemRealloc both worked and would zero remaining space. */ memcpy(pdw, lpDD_lcl->pPaletteHandleUsedBitfield, (cbits / BITS_PER_BITFIELD_ENTRY) * sizeof(DWORD) ); MemFree(lpDD_lcl->pPaletteHandleUsedBitfield); lpDD_lcl->pPaletteHandleUsedBitfield = pdw; } else { return 0; } } /* * Table is big enough. Grab the entry and mark it. */ cbits = lpDD_lcl->cbitsPaletteBitfieldBitCount++; lpDD_lcl->pPaletteHandleUsedBitfield[cbits/BITS_PER_BITFIELD_ENTRY] |= (1<<(cbits % BITS_PER_BITFIELD_ENTRY)); return cbits+1; //+1 since zero is an error return, and it helps out drivers to know 0 is invalid } void FreePaletteHandle(LPDDRAWI_DIRECTDRAW_LCL lpDD_lcl, DWORD dwHandle) { DDASSERT( dwHandle <= lpDD_lcl->cbitsPaletteBitfieldBitCount ); if (dwHandle == 0) return; dwHandle -=1; //since handles are 1-based lpDD_lcl->pPaletteHandleUsedBitfield[dwHandle/BITS_PER_BITFIELD_ENTRY] &= ~(1<<(dwHandle % BITS_PER_BITFIELD_ENTRY)); } /* * newPaletteInterface * * Construct a new palette interface which points to an existing local object. */ static LPVOID newPaletteInterface( LPDDRAWI_DDRAWPALETTE_LCL this_lcl, LPVOID lpvtbl ) { LPDDRAWI_DDRAWPALETTE_INT pnew_int; LPDDRAWI_DIRECTDRAW_GBL pdrv; pnew_int = MemAlloc( sizeof( DDRAWI_DDRAWPALETTE_INT )); if( NULL == pnew_int ) { return NULL; } /* * set up data */ pnew_int->lpVtbl = lpvtbl; pnew_int->lpLcl = this_lcl; pnew_int->dwIntRefCnt = 0; /* * link this into the global list of palettes */ pdrv = this_lcl->lpDD_lcl->lpGbl; pnew_int->lpLink = pdrv->palList; pdrv->palList = pnew_int; return pnew_int; } /* newPaletteInterface */ #undef DPF_MODNAME #define DPF_MODNAME "Palette::QueryInterface" /* * DD_Palette_QueryInterface */ HRESULT DDAPI DD_Palette_QueryInterface( LPDIRECTDRAWPALETTE lpDDPalette, REFIID riid, LPVOID FAR * ppvObj ) { LPDDRAWI_DDRAWPALETTE_GBL this; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_INT this_int; ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_Palette_QueryInterface"); TRY { this_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( !VALID_DIRECTDRAWPALETTE_PTR( this_int ) ) { DPF_ERR( "Invalid palette pointer" ); LEAVE_DDRAW(); return (DWORD) DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; if( !VALID_PTR_PTR( ppvObj ) ) { DPF( 1, "Invalid palette pointer" ); LEAVE_DDRAW(); return (DWORD) DDERR_INVALIDPARAMS; } if( !VALIDEX_IID_PTR( riid ) ) { DPF_ERR( "Invalid IID pointer" ); LEAVE_DDRAW(); return (DWORD) DDERR_INVALIDPARAMS; } this = this_lcl->lpGbl; } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return (DWORD) DDERR_INVALIDPARAMS; } if( IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectDrawPalette) ) { if( this_int->lpVtbl == (LPVOID) &ddPaletteCallbacks ) *ppvObj = (LPVOID) this_int; else *ppvObj = (LPVOID) newPaletteInterface( this_lcl, (LPVOID)&ddPaletteCallbacks ); if( NULL == *ppvObj ) { LEAVE_DDRAW(); return E_NOINTERFACE; } else { DD_Palette_AddRef( *ppvObj ); LEAVE_DDRAW(); return DD_OK; } } #ifdef POSTPONED if (IsEqualIID(riid, &IID_IPersist)) { /* * if this is already an IID_IPersist interface, just * addref and return */ if( this_int->lpVtbl == (LPVOID) &ddPalettePersistCallbacks ) *ppvObj = (LPVOID) this_int; else *ppvObj = (LPVOID) newPaletteInterface( this_lcl, (LPVOID)&ddPalettePersistCallbacks ); if( NULL == *ppvObj ) { LEAVE_DDRAW(); return E_NOINTERFACE; } else { DD_Palette_AddRef( *ppvObj ); LEAVE_DDRAW(); return DD_OK; } } if (IsEqualIID(riid, &IID_IPersistStream)) { /* * if this is already an IID_IPersistStream interface, just * addref and return */ if( this_int->lpVtbl == (LPVOID) &ddPalettePersistStreamCallbacks ) *ppvObj = (LPVOID) this_int; else *ppvObj = (LPVOID) newPaletteInterface( this_lcl, (LPVOID)&ddPalettePersistStreamCallbacks ); if( NULL == *ppvObj ) { LEAVE_DDRAW(); return E_NOINTERFACE; } else { DD_Palette_AddRef( *ppvObj ); LEAVE_DDRAW(); return DD_OK; } } if (IsEqualIID(riid, &IID_IDirectDrawPalette2)) { /* * if this is already an IID_IDirectDrawPalette2 interface, just * addref and return */ if( this_int->lpVtbl == (LPVOID) &ddPalette2Callbacks ) *ppvObj = (LPVOID) this_int; else *ppvObj = (LPVOID) newPaletteInterface( this_lcl, (LPVOID)&ddPalette2Callbacks ); if( NULL == *ppvObj ) { LEAVE_DDRAW(); return E_NOINTERFACE; } else { DD_Palette_AddRef( *ppvObj ); LEAVE_DDRAW(); return DD_OK; } } #endif //POSTPONED LEAVE_DDRAW(); return (DWORD) DDERR_GENERIC; } /* DD_Palette_QueryInterface */ #undef DPF_MODNAME #define DPF_MODNAME "Palette::AddRef" /* * DD_Palette_AddRef */ DWORD DDAPI DD_Palette_AddRef( LPDIRECTDRAWPALETTE lpDDPalette ) { LPDDRAWI_DDRAWPALETTE_GBL this; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_INT this_int; DWORD rcnt; ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_Palette_AddRef"); TRY { this_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( !VALID_DIRECTDRAWPALETTE_PTR( this_int ) ) { LEAVE_DDRAW(); return 0; } this_lcl = this_int->lpLcl; this = this_lcl->lpGbl; /* * update palette reference count */ this->dwRefCnt++; this_lcl->dwLocalRefCnt++; this_int->dwIntRefCnt++; rcnt = this_lcl->dwLocalRefCnt & ~OBJECT_ISROOT; DPF( 5, "Palette %08lx addrefed, refcnt = %ld,%ld,%ld", this_lcl, this->dwRefCnt, rcnt, this_int->dwIntRefCnt ); } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return 0; } LEAVE_DDRAW(); return this_int->dwIntRefCnt; } /* DD_Palette_AddRef */ #undef DPF_MODNAME #define DPF_MODNAME "Palette::Release" /* * InternalPaletteRelease * * Done with a palette. if no one else is using it, then we can free it. * Also called by ProcessPaletteCleanup */ ULONG DDAPI InternalPaletteRelease( LPDDRAWI_DDRAWPALETTE_INT this_int ) { DWORD intrefcnt; DWORD lclrefcnt; DWORD gblrefcnt; BOOL root_object_deleted; BOOL do_free; ULONG rc; DDHAL_DESTROYPALETTEDATA dpd; LPDDRAWI_DDRAWPALETTE_GBL this; LPDDRAWI_DDRAWPALETTE_INT curr_int; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_INT last_int; LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl; LPDDRAWI_DIRECTDRAW_GBL pdrv; IUnknown * pOwner = NULL; this_lcl = this_int->lpLcl; this = this_lcl->lpGbl; pdrv_lcl = this->lpDD_lcl; pdrv = pdrv_lcl->lpGbl; /* * decrement reference count to this palette. If it hits zero, * cleanup */ this->dwRefCnt--; this_lcl->dwLocalRefCnt--; this_int->dwIntRefCnt--; intrefcnt = this_int->dwIntRefCnt; lclrefcnt = this_lcl->dwLocalRefCnt & ~OBJECT_ISROOT; gblrefcnt = this->dwRefCnt; DPF( 5, "Palette %08lx released, refcnt = %ld,%ld,%ld", this_int, gblrefcnt, lclrefcnt, intrefcnt ); /* * local object gone? */ root_object_deleted = FALSE; if( lclrefcnt == 0 ) { /* * Remove private data */ FreeAllPrivateData( &this_lcl->pPrivateDataHead ); /* * If the ddraw interface which created this palette caused the surface to addref the ddraw * object, then we need to release that addref now. */ pOwner = this_lcl->pAddrefedThisOwner; /* * see if we are deleting the root object */ if( this_lcl->dwLocalRefCnt & OBJECT_ISROOT ) { root_object_deleted = TRUE; } } /* * did the object get globally deleted? */ do_free = FALSE; if( gblrefcnt == 0 ) { LPDDHALPALCB_DESTROYPALETTE dphalfn; LPDDHALPALCB_DESTROYPALETTE dpfn; BOOL emulation; do_free = TRUE; /* * if this palette is selected into the primary, unselect it! */ if (pdrv_lcl && pdrv_lcl->lpPrimary && pdrv_lcl->lpPrimary->lpLcl->lpDDPalette == this_int) { SetPaletteAlways(pdrv_lcl->lpPrimary, NULL); } FreePaletteHandle( pdrv_lcl, this->dwHandle ); /* * destroy the hardware */ if( ( pdrv_lcl->lpDDCB->HALDDPalette.DestroyPalette == NULL ) || ( this->dwFlags & DDRAWIPAL_INHEL ) ) { // use HEL dpfn = pdrv_lcl->lpDDCB->HELDDPalette.DestroyPalette; dphalfn = dpfn; emulation = TRUE; } else { // use HAL dpfn = pdrv_lcl->lpDDCB->HALDDPalette.DestroyPalette; dphalfn = pdrv_lcl->lpDDCB->cbDDPaletteCallbacks.DestroyPalette; emulation = FALSE; } if( dphalfn != NULL ) { dpd.DestroyPalette = dphalfn; dpd.lpDD = pdrv_lcl->lpGbl; dpd.lpDDPalette = this; DOHALCALL( DestroyPalette, dpfn, dpd, rc, emulation ); if( rc == DDHAL_DRIVER_HANDLED ) { if( dpd.ddRVal != DD_OK ) { DPF_ERR( "HAL call failed" ); /* * If the palette took a ref count on the ddraw object that created it, * release that ref now as the very last thing * We don't want to do this on ddhelp's thread cuz it really mucks up the * process cleanup stuff. */ if (pOwner && (dwHelperPid != GetCurrentProcessId()) ) { pOwner->lpVtbl->Release(pOwner); } /* GEE: What do we do here since we no longer return * error codes from Release. */ return (DWORD) dpd.ddRVal; } } /* * Moved here from ddhel.c. Non-display drivers mean that the hel isn't called for palette * destroy, so we were leaking palette tables. It's called exactly here to most closely * duplicate the old behaviour, but reduce any risk of drivers using the color table or whatever. */ if (this->lpColorTable) { MemFree(this->lpColorTable); this->lpColorTable = NULL; } } else { /* * We can't do this; we've already committed to releasing at * this point! */ // couldn't handle it // return (ULONG)DDERR_UNSUPPORTED; } /* * if this was the final delete, but this wasn't the root object, * then we need to delete the dangling root object */ if( !root_object_deleted ) { LPVOID root_lcl; root_lcl = (LPVOID) (((LPBYTE) this) - sizeof( DDRAWI_DDRAWPALETTE_LCL ) ); MemFree( root_lcl ); } } else if( lclrefcnt == 0 ) { /* * only remove the object if it wasn't the root. if it * was the root, we must leave it dangling until the last * object referencing it goes away. */ if( !root_object_deleted ) { do_free = TRUE; } } /* * free the object if needed */ if( do_free ) { /* * just in case someone comes back in with this pointer, set * an invalid vtbl & data ptr. */ this_lcl->lpGbl = NULL; MemFree( this_lcl ); } /* * need to delete the interface? */ if( intrefcnt == 0 ) { /* * remove palette from list of all palettes */ curr_int = pdrv->palList; last_int = NULL; while( curr_int != this_int ) { last_int = curr_int; curr_int = curr_int->lpLink; if( curr_int == NULL ) { return 0; } } if( last_int == NULL ) { pdrv->palList = pdrv->palList->lpLink; } else { last_int->lpLink = curr_int->lpLink; } /* * Invalidate the interface */ this_int->lpVtbl = NULL; this_int->lpLcl = NULL; MemFree( this_int ); } /* * If the palette took a ref count on the ddraw object that created it, * release that ref now as the very last thing * We don't want to do this on ddhelp's thread cuz it really mucks up the * process cleanup stuff. */ if (pOwner && (dwHelperPid != GetCurrentProcessId()) ) { pOwner->lpVtbl->Release(pOwner); } return intrefcnt; } /* InternalPaletteRelease */ /* * DD_Palette_Release * * Done with a palette. if no one else is using it, then we can free it. */ ULONG DDAPI DD_Palette_Release( LPDIRECTDRAWPALETTE lpDDPalette ) { LPDDRAWI_DDRAWPALETTE_GBL this; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_INT this_int; ULONG rc; ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_Palette_Release"); TRY { this_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( !VALIDEX_DIRECTDRAWPALETTE_PTR( this_int ) ) { LEAVE_DDRAW(); return 0; } this_lcl = this_int->lpLcl; this = this_lcl->lpGbl; rc = InternalPaletteRelease( this_int ); } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return 0; } LEAVE_DDRAW(); return rc; } /* DD_Palette_Release */ #undef DPF_MODNAME #define DPF_MODNAME "GetCaps" /* * DD_Palette_GetCaps */ HRESULT DDAPI DD_Palette_GetCaps( LPDIRECTDRAWPALETTE lpDDPalette, LPDWORD lpdwCaps ) { LPDDRAWI_DDRAWPALETTE_GBL this; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_INT this_int; LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl; DWORD caps; ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_Palette_GetCaps"); TRY { this_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( !VALID_DIRECTDRAWPALETTE_PTR( this_int ) ) { LEAVE_DDRAW(); return DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; if( !VALID_DWORD_PTR( lpdwCaps ) ) { DPF_ERR( "invalid caps pointer" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } *lpdwCaps = 0; this = this_lcl->lpGbl; } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } /* * basic palette size caps. */ caps = SIZE_FLAGS_TO_PCAPS( this->dwFlags ); /* * is this palette attached to the primary? */ pdrv_lcl = this->lpDD_lcl; if (pdrv_lcl && pdrv_lcl->lpPrimary && pdrv_lcl->lpPrimary->lpLcl->lpDDPalette && (pdrv_lcl->lpPrimary->lpLcl->lpDDPalette == this_int)) caps |= DDPCAPS_PRIMARYSURFACE; /* * an allow256 palette? */ if( this->dwFlags & DDRAWIPAL_ALLOW256 ) { caps |= DDPCAPS_ALLOW256; } /* * does this palette store indices into an 8-bit destination * palette. */ if( this->dwFlags & DDRAWIPAL_STORED_8INDEX ) { caps |= DDPCAPS_8BITENTRIES; } *lpdwCaps = caps; LEAVE_DDRAW(); return DD_OK; } /* DD_Palette_GetCaps */ #undef DPF_MODNAME #define DPF_MODNAME "Initialize" /* * DD_Palette_Initialize */ HRESULT DDAPI DD_Palette_Initialize( LPDIRECTDRAWPALETTE lpDDPalette, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable ) { DPF_ERR( "DirectDrawPalette: DD_Palette_Initialize"); DPF(2,A,"ENTERAPI: "); return DDERR_ALREADYINITIALIZED; } /* DD_Palette_Initialize */ #undef DPF_MODNAME #define DPF_MODNAME "SetEntries" /* * DD_Palette_SetEntries */ HRESULT DDAPI DD_Palette_SetEntries( LPDIRECTDRAWPALETTE lpDDPalette, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries ) { LPDDRAWI_DDRAWPALETTE_INT this_int; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_GBL this; DWORD rc; DDHAL_SETENTRIESDATA sed; LPDDRAWI_DIRECTDRAW_GBL pdrv; LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl; LPDDHALPALCB_SETENTRIES sehalfn; LPDDHALPALCB_SETENTRIES sefn; DWORD size; BOOL emulation; DWORD entry_size; ENTER_BOTH(); DPF(2,A,"ENTERAPI: DD_Palette_SetEntries"); TRY { this_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( !VALID_DIRECTDRAWPALETTE_PTR( this_int ) ) { LEAVE_BOTH(); return DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; if( dwFlags ) { DPF_ERR( "Invalid flags" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } this = this_lcl->lpGbl; /* * check number of entries */ size = FLAGS_TO_SIZE( this->dwFlags ); if( dwNumEntries < 1 || dwNumEntries > size ) { DPF_ERR( "Invalid number of entries" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } if( dwBase >= size ) { DPF_ERR( "Invalid base palette index" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } if( dwNumEntries+dwBase > size ) { DPF_ERR( "palette indices requested would go past the end of the palette" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } if( this->dwFlags & DDRAWIPAL_STORED_8INDEX ) { entry_size = sizeof( BYTE ); if( !VALID_BYTE_ARRAY( lpEntries, dwNumEntries ) ) { DPF_ERR( "Invalid 8-bit palette index array" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } } else { entry_size = sizeof( PALETTEENTRY ); if( !VALID_PALETTEENTRY_ARRAY( lpEntries, dwNumEntries ) ) { DPF_ERR( "Invalid PALETTEENTRY array" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } } pdrv_lcl = this->lpDD_lcl; pdrv = pdrv_lcl->lpGbl; /* * copy the entries */ memcpy( ((LPBYTE)this->lpColorTable) + (entry_size * dwBase), lpEntries, dwNumEntries * entry_size ); } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } if( ( pdrv_lcl->lpDDCB->HALDDPalette.SetEntries == NULL ) || ( this->dwFlags & DDRAWIPAL_INHEL ) ) { // use HEL sefn = pdrv_lcl->lpDDCB->HELDDPalette.SetEntries; sehalfn = sefn; emulation = TRUE; } else { // use HAL sefn = pdrv_lcl->lpDDCB->HALDDPalette.SetEntries; sehalfn = pdrv_lcl->lpDDCB->cbDDPaletteCallbacks.SetEntries; emulation = FALSE; } if( sehalfn != NULL ) { sed.SetEntries = sehalfn; sed.lpDD = pdrv; sed.lpDDPalette = this; sed.dwBase = dwBase; sed.dwNumEntries = dwNumEntries; sed.lpEntries = lpEntries; DOHALCALL_NOWIN16( SetEntries, sefn, sed, rc, emulation ); if( rc == DDHAL_DRIVER_HANDLED ) { if( sed.ddRVal != DD_OK ) { DPF( 5, "DDHAL_SetEntries: ddrval = %ld", sed.ddRVal ); LEAVE_BOTH(); return (DWORD) sed.ddRVal; } // We have now set the palette as we have been asked; so // we may need to update some outstanding DCs. UpdateDCOnPaletteChanges( this ); } } else { LEAVE_BOTH(); return DDERR_UNSUPPORTED; } BUMP_PALETTE_STAMP(this); /* * If the palette's handle is non-zero, that means the palette has already been exposed to the * driver by a palette associate notify call. If the handle is zero, then the driver has never * seen the palette before and doesn't care about setentries for it. The driver will get its * first setentries immediately after the setpalette call (See DD_Surface_SetPalette) * Mustn't do this on ddhelp's context, since the DLL will be long gone. (Note this should never * happen anyway). */ if( dwHelperPid != GetCurrentProcessId() ) { if (this->dwHandle) { if ( pdrv_lcl->pPaletteUpdateNotify && pdrv_lcl->pD3DIUnknown) { pdrv_lcl->pPaletteUpdateNotify( pdrv_lcl->pD3DIUnknown, this->dwHandle , dwBase, dwNumEntries, lpEntries ); } } } LEAVE_BOTH(); return DD_OK; } /* DD_Palette_SetEntries */ #undef DPF_MODNAME #define DPF_MODNAME "GetEntries" /* * DD_Palette_GetEntries */ HRESULT DDAPI DD_Palette_GetEntries( LPDIRECTDRAWPALETTE lpDDPalette, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries ) { LPDDRAWI_DDRAWPALETTE_INT this_int; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_GBL this; DWORD size; DWORD entry_size; ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_Palette_GetEntries"); TRY { this_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( !VALID_DIRECTDRAWPALETTE_PTR( this_int ) ) { LEAVE_DDRAW(); return DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; if( dwFlags ) { DPF_ERR( "Invalid flags" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } this = this_lcl->lpGbl; /* * check number of entries */ size = FLAGS_TO_SIZE( this->dwFlags ); if( dwNumEntries < 1 || dwNumEntries > size ) { DPF_ERR( "Invalid number of entries" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } if( dwBase >= size ) { DPF_ERR( "Invalid base palette index" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } if( dwNumEntries+dwBase > size ) { DPF_ERR( "palette indices requested would go past the end of the palette" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } if( this->dwFlags & DDRAWIPAL_STORED_8INDEX ) { entry_size = sizeof( BYTE ); if( !VALID_BYTE_ARRAY( lpEntries, dwNumEntries ) ) { DPF_ERR( "Invalid 8-bit palette index array" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } } else { entry_size = sizeof( PALETTEENTRY ); if( !VALID_PALETTEENTRY_ARRAY( lpEntries, dwNumEntries ) ) { DPF_ERR( "Invalid PALETTEENTRY array" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } } /* GetEntries function body */ memcpy( lpEntries, ((LPBYTE)this->lpColorTable) + (dwBase * entry_size), dwNumEntries * entry_size ); } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } LEAVE_DDRAW(); return DD_OK; } /* DD_Palette_GetEntries */ #undef DPF_MODNAME #define DPF_MODNAME "GetPalette" /* * DD_Surface_GetPalette * * Surface function: get the palette associated with surface */ HRESULT DDAPI DD_Surface_GetPalette( LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWPALETTE FAR * lplpDDPalette) { LPDDRAWI_DDRAWSURFACE_INT this_int; LPDDRAWI_DDRAWSURFACE_LCL this_lcl; LPDDRAWI_DDRAWSURFACE_GBL this; HRESULT hr; ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_Surface_GetPalette"); TRY { if( !VALID_PTR_PTR( lplpDDPalette ) ) { DPF_ERR( "Invalid palette pointer" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } *lplpDDPalette = NULL; // in case we fail this_int = (LPDDRAWI_DDRAWSURFACE_INT) lpDDSurface; if( !VALID_DIRECTDRAWSURFACE_PTR( this_int ) ) { LEAVE_DDRAW(); return DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; this = this_lcl->lpGbl; if( SURFACE_LOST( this_lcl ) ) { LEAVE_DDRAW(); return DDERR_SURFACELOST; } // // For now, if the current surface is optimized, quit // if (this_lcl->ddsCaps.dwCaps & DDSCAPS_OPTIMIZED) { DPF_ERR( "It is an optimized surface" ); LEAVE_DDRAW(); return DDERR_ISOPTIMIZEDSURFACE; } if( this_lcl->lpDDPalette == NULL ) { DPF( 1, "No palette associated with surface" ); LEAVE_DDRAW(); return DDERR_NOPALETTEATTACHED; } } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } #ifdef POSTPONED if (LOWERTHANSURFACE4(this_int)) { hr = DD_Palette_QueryInterface( (LPDIRECTDRAWPALETTE) this_lcl->lpDDPalette, &IID_IDirectDrawPalette, (void**)lplpDDPalette ); } else { hr = DD_Palette_QueryInterface( (LPDIRECTDRAWPALETTE) this_lcl->lpDDPalette, &IID_IDirectDrawPalette2, (void**)lplpDDPalette ); } #else hr = DD_Palette_QueryInterface( (LPDIRECTDRAWPALETTE) this_lcl->lpDDPalette, &IID_IDirectDrawPalette, (void**)lplpDDPalette ); #endif LEAVE_DDRAW(); return hr; } /* DD_Surface_GetPalette */ #undef DPF_MODNAME #define DPF_MODNAME "SetPalette" /* * DD_Surface_SetPalette * * Surface function: set the palette associated with surface * * NOTE: Currently the only way a windowed app. has of * realizing its palette on the primary is to call SetPalette * (full screen app. palette's are realized for them by the * WM_ACTIVATEAPP hook). Hence, the logic is to AddRef the * palette only if it is not already set as the surface's * palette). * Perhaps we need a RealizePalette() call? */ HRESULT DDAPI DD_Surface_SetPalette( LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWPALETTE lpDDPalette ) { LPDDRAWI_DDRAWSURFACE_INT this_int; LPDDRAWI_DDRAWSURFACE_LCL this_lcl; LPDDRAWI_DDRAWSURFACE_GBL this; LPDDRAWI_DDRAWPALETTE_INT this_pal_int; LPDDRAWI_DDRAWPALETTE_LCL this_pal_lcl; LPDDRAWI_DDRAWPALETTE_GBL this_pal; LPDDRAWI_DDRAWPALETTE_INT prev_pal_int; LPDDPIXELFORMAT pddpf; LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl; LPDDRAWI_DIRECTDRAW_GBL pdrv; BOOL attach; DWORD rc; DDHAL_SETPALETTEDATA spd; LPDDHALSURFCB_SETPALETTE sphalfn; LPDDHALSURFCB_SETPALETTE spfn; BOOL emulation; BOOL isprimary; BOOL excl_exists; BOOL has_excl; ENTER_BOTH(); DPF(2,A,"ENTERAPI: DD_Surface_SetPalette"); TRY { this_int = (LPDDRAWI_DDRAWSURFACE_INT) lpDDSurface; if( !VALID_DIRECTDRAWSURFACE_PTR( this_int ) ) { LEAVE_BOTH(); return DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; this = this_lcl->lpGbl; // // For now, if the current surface is optimized, quit // if (this_lcl->ddsCaps.dwCaps & DDSCAPS_OPTIMIZED) { DPF_ERR( "It is an optimized surface" ); LEAVE_DDRAW(); return DDERR_ISOPTIMIZEDSURFACE; } /* * Palettes don't make any sense on z-buffers or execute * buffers. */ if( this_lcl->ddsCaps.dwCaps & ( DDSCAPS_ZBUFFER | DDSCAPS_EXECUTEBUFFER ) ) { DPF_ERR( "Invalid surface type: cannot attach palette" ); LEAVE_BOTH(); return DDERR_INVALIDSURFACETYPE; } // // New interfaces don't let mipmap sublevels have palettes // if ((!LOWERTHANSURFACE7(this_int)) && (this_lcl->lpSurfMore->ddsCapsEx.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL)) { DPF_ERR( "Cannot attach palette to mipmap sublevels" ); LEAVE_BOTH(); return DDERR_NOTONMIPMAPSUBLEVEL; } if( SURFACE_LOST( this_lcl ) ) { LEAVE_BOTH(); return DDERR_SURFACELOST; } this_pal_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( this_pal_int != NULL ) { if( !VALID_DIRECTDRAWPALETTE_PTR( this_pal_int ) ) { LEAVE_BOTH(); return DDERR_INVALIDOBJECT; } this_pal_lcl = this_pal_int->lpLcl; this_pal = this_pal_lcl->lpGbl; } else { this_pal_lcl = NULL; this_pal = NULL; } pdrv_lcl = this_lcl->lpSurfMore->lpDD_lcl; pdrv = pdrv_lcl->lpGbl; if ( this_pal_int && (this_pal->dwFlags & DDRAWIPAL_ALPHA) && (! (this_lcl->ddsCaps.dwCaps & DDSCAPS_TEXTURE)) ) { DPF_ERR( "Attaching palette w/alpha to non-texture surface" ); LEAVE_BOTH(); return DDERR_INVALIDSURFACETYPE; } /* * don't allow a palette from one global to be * used with a different one (because it doesn't work) */ if( this_pal_int && pdrv != this_pal_lcl->lpDD_lcl->lpGbl ) { /* * Don't check if either device isn't a display driver (i.e. 3dfx) * since that's a back-compat hole. */ if ( (this->lpDD->dwFlags & DDRAWI_DISPLAYDRV) && (this_pal_lcl->lpDD_lcl->lpGbl->dwFlags & DDRAWI_DISPLAYDRV) ) { DPF_ERR( "Can't set a palette created from one DDraw onto a surface created by another DDraw" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } } CheckExclusiveMode(pdrv_lcl, &excl_exists, &has_excl, FALSE, NULL, FALSE); /* * don't allow primary palette set if not exclusive mode owner */ isprimary = FALSE; if( this_lcl->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE ) { isprimary = TRUE; if( excl_exists ) { if( !has_excl ) { DPF_ERR( "Cannot set palette on primary when other process owns exclusive mode" ); LEAVE_BOTH(); return DDERR_NOEXCLUSIVEMODE; } } } /* * Was a palette previously attached to this surface? * If so, we will need to release if all goes well so * remember it. */ prev_pal_int = this_lcl->lpDDPalette; /* * NULL palette, remove palette from this surface */ attach = TRUE; if( this_pal == NULL ) { attach = FALSE; this_pal_int = prev_pal_int; if( this_pal_int == NULL ) { DPF_ERR( "No attached palette" ); LEAVE_BOTH(); return DDERR_NOPALETTEATTACHED; } this_pal_lcl = this_pal_int->lpLcl; this_pal = this_pal_lcl->lpGbl; } if( attach ) { /* * NOTE: We used to do a lot of HEL specific checking. With the * addition of support for palettes on non-primary surfaces and * non-256 entry palettes this became redundant. We also used * to explicitly check that, if attaching to the primary, the * current mode was palettized and 8-bit. Doesn't look to me like * any of that was necessary as DDPF_PALETTEINDEXED8 should be * set if the primary is 8-bit palettized. */ GET_PIXEL_FORMAT( this_lcl, this, pddpf ); if( ( ( this_pal->dwFlags & DDRAWIPAL_2 ) && !( pddpf->dwFlags & DDPF_PALETTEINDEXED1 ) ) || ( ( this_pal->dwFlags & DDRAWIPAL_4 ) && !( pddpf->dwFlags & DDPF_PALETTEINDEXED2 ) ) || ( ( this_pal->dwFlags & DDRAWIPAL_16 ) && !( pddpf->dwFlags & DDPF_PALETTEINDEXED4 ) ) || ( ( this_pal->dwFlags & DDRAWIPAL_256 ) && !( pddpf->dwFlags & DDPF_PALETTEINDEXED8 ) ) ) { DPF_ERR( "Palette size does not match surface format - cannot set palette" ); LEAVE_BOTH(); return DDERR_INVALIDPIXELFORMAT; } /* * Ensure that both the palette and surface agree on whether they are using * indices into the destination surface's palette. */ if( this_pal->dwFlags & DDRAWIPAL_STORED_8INDEX ) { if( !(pddpf->dwFlags & DDPF_PALETTEINDEXEDTO8) ) { DPF_ERR( "Surface is not PALETTEINDEXEDTO8 - cannot set palette" ); LEAVE_BOTH(); return DDERR_INVALIDPIXELFORMAT; } } else { if( pddpf->dwFlags & DDPF_PALETTEINDEXEDTO8 ) { DPF_ERR( "Surface is PALETTEINDEXEDTO8 - cannot set palette" ); LEAVE_BOTH(); return DDERR_INVALIDPIXELFORMAT; } } } } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_BOTH(); return DDERR_INVALIDPARAMS; } /* * ATTENTION!!! * We shouldn't pass optimized surfaces to an unsuspecting HAL, but if we don't then we could * break drivers that hook SetPalette... Since the HAL is probably only going to be watching * for a primary, and also is unlikely to go looking at the surface's contents, * I'm going to let this one slide. */ if( ( this_pal->dwFlags & DDRAWIPAL_INHEL) || ( pdrv_lcl->lpDDCB->HALDDSurface.SetPalette == NULL ) ) { // use HEL spfn = pdrv_lcl->lpDDCB->HELDDSurface.SetPalette; sphalfn = spfn; emulation = TRUE; } else { // use HAL spfn = pdrv_lcl->lpDDCB->HALDDSurface.SetPalette; sphalfn = pdrv_lcl->lpDDCB->cbDDSurfaceCallbacks.SetPalette; emulation = FALSE; } if( sphalfn != NULL ) { spd.SetPalette = sphalfn; spd.lpDD = pdrv; spd.lpDDPalette = this_pal; spd.lpDDSurface = this_lcl; spd.Attach = attach; DOHALCALL_NOWIN16( SetPalette, spfn, spd, rc, emulation ); if( rc == DDHAL_DRIVER_HANDLED ) { if( spd.ddRVal == DD_OK ) { if( attach ) { /* * Only AddRef the palette if its being attached to * a new surface. */ if( this_lcl->lpDDPalette != this_pal_int ) { this_lcl->lpDDPalette = this_pal_int; DD_Palette_AddRef( lpDDPalette ); } } else { this_lcl->lpDDPalette = NULL; } /* * If we had a previous palette and it was different * from the new palette then we must release it. * NOTE: We compare against the incoming parameter * rather than this_pal_lcl as this_pal_lcl is set to the * previous palette if we are removing a palette. * NOTE: It is important that we update the surface's * palette pointer before calling Release() as, otherwise, * release can end up calling SetPalette() and so on. */ if( ( prev_pal_int != NULL ) && ( prev_pal_int != (LPDDRAWI_DDRAWPALETTE_INT )lpDDPalette ) ) { // This palette may no longer the exclusive one if( isprimary ) { if( has_excl ) { prev_pal_int->lpLcl->lpGbl->dwFlags &= ~DDRAWIPAL_EXCLUSIVE; } } // Release it DD_Palette_Release( (LPDIRECTDRAWPALETTE)prev_pal_int ); } if( attach ) { // Ok, we have set the palette onto the surface // Check if there are any outstanding DCs that need updating UpdateOutstandingDC( this_lcl, this_pal ); } else { // Ok, we have removed a palette onto the surface // Check if there are any outstanding DCs that need updating UpdateOutstandingDC( this_lcl, NULL ); } BUMP_SURFACE_STAMP(this); /* * Update the driver's associations and palette entries */ if( dwHelperPid != GetCurrentProcessId() ) { BOOL bUpdateEntries = FALSE; if (attach) { if (this_pal->dwHandle == 0) { /* * The driver has never seen this palette before. We must send an associate notify first, and * then an update entries */ bUpdateEntries = TRUE; this_pal->dwHandle = GeneratePaletteHandle(pdrv_lcl); } if (this_pal->dwHandle && pdrv_lcl->pD3DIUnknown ) //could be zero in low memory conditions { if ( pdrv_lcl->pPaletteAssociateNotify ) { // NOTE: we send the handle for DX6 and down // for DX7 we pass the the local itself. // DX7 needs the whole local to get the // batching correct; MB41840 if( DDRAWILCL_DIRECTDRAW7 & pdrv_lcl->dwLocalFlags ) { LPPALETTEASSOCIATENOTIFY7 pPaletteAssociateNotify = (LPPALETTEASSOCIATENOTIFY7)pdrv_lcl->pPaletteAssociateNotify; pPaletteAssociateNotify( pdrv_lcl->pD3DIUnknown, this_pal->dwHandle, this_pal->dwFlags, this_lcl ); } else { // When a DX6 app is talking to a DX7 driver, // we need to force a flush of the token // stream as part of this SetPalette. // // This automatically happens if the number // of devices is > 1. So if necessary // we temporarily increment the device // count. We don't do this for IA64. // MB41840 for more details. #ifndef _WIN64 DWORD *pIUnknown = (DWORD *)(pdrv_lcl->pD3DIUnknown); DWORD *pD3D = (DWORD *)(*(pIUnknown + 2)); DWORD *pnumDevs = (DWORD *)(pD3D + 3); BOOL bFixDeviceCount = FALSE; DDASSERT(pD3D != NULL); if (*pnumDevs == 1) { *pnumDevs = 2; bFixDeviceCount = TRUE; } #endif // _WIN64 pdrv_lcl->pPaletteAssociateNotify( pdrv_lcl->pD3DIUnknown, this_pal->dwHandle, this_pal->dwFlags, this_lcl->lpSurfMore->dwSurfaceHandle ); #ifndef _WIN64 // Restore the device count if (bFixDeviceCount) { DDASSERT(*pnumDevs == 2); *pnumDevs = 1; } #endif // _WIN64 } } if ( pdrv_lcl->pPaletteUpdateNotify ) { pdrv_lcl->pPaletteUpdateNotify( pdrv_lcl->pD3DIUnknown, this_pal->dwHandle , 0, FLAGS_TO_SIZE(this_pal->dwFlags), this_pal->lpColorTable ); } } } } } LEAVE_BOTH(); return spd.ddRVal; } LEAVE_BOTH(); return DDERR_UNSUPPORTED; } /* * !!! NOTE: Currently if the driver does not care about * SetPalette we do nothing but return OK. Should we * not, however, still point the surface at the palette * and point the palette at the surface at the very * least? */ LEAVE_BOTH(); return DD_OK; } /* DD_Surface_SetPalette */ /* * SetPaletteAlways */ HRESULT SetPaletteAlways( LPDDRAWI_DDRAWSURFACE_INT psurf_int, LPDIRECTDRAWPALETTE lpDDPalette ) { LPDDRAWI_DDRAWSURFACE_LCL psurf_lcl; DWORD oldflag; HRESULT ddrval; psurf_lcl = psurf_int->lpLcl; oldflag = psurf_lcl->dwFlags & DDRAWISURF_INVALID; psurf_lcl->dwFlags &= ~DDRAWISURF_INVALID; ddrval = DD_Surface_SetPalette( (LPDIRECTDRAWSURFACE) psurf_int, lpDDPalette ); psurf_lcl->dwFlags |= oldflag; return ddrval; } /* SetPaletteAlways */ #undef DPF_MODNAME #define DPF_MODNAME "CreatePalette" /* * DD_CreatePalette * * Driver function: create a palette */ HRESULT DDAPI DD_CreatePalette( LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter ) { LPDDRAWI_DIRECTDRAW_INT this_int; LPDDRAWI_DIRECTDRAW_LCL this_lcl; LPDDRAWI_DIRECTDRAW_GBL this; LPDDRAWI_DDRAWPALETTE_INT ppal_int; LPDDRAWI_DDRAWPALETTE_LCL ppal_lcl; LPDDRAWI_DDRAWPALETTE_GBL ppal; DWORD pal_size; DDHAL_CREATEPALETTEDATA cpd; DWORD rc; DWORD pflags; BOOL is_excl; LPDDHAL_CREATEPALETTE cpfn; LPDDHAL_CREATEPALETTE cphalfn; BOOL emulation; BYTE indexedpe; BYTE hackindexedpe; PALETTEENTRY pe; PALETTEENTRY hackpe; DWORD num_entries; DWORD entry_size; int num_size_flags; if( pUnkOuter != NULL ) { return CLASS_E_NOAGGREGATION; } ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_CreatePalette"); TRY { this_int = (LPDDRAWI_DIRECTDRAW_INT) lpDD; if( !VALID_DIRECTDRAW_PTR( this_int ) ) { LEAVE_DDRAW(); return DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; this = this_lcl->lpGbl; if( !VALID_PTR_PTR( lplpDDPalette ) ) { LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } *lplpDDPalette = NULL; if( dwFlags & ~DDPCAPS_VALID ) { DPF_ERR( "Invalid caps" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } /* * verify that cooperative level is set */ if( !(this_lcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED) ) { DPF_ERR( "Must call SetCooperativeLevel before calling Create functions" ); LEAVE_DDRAW(); return DDERR_NOCOOPERATIVELEVELSET; } /* * verify flags */ if( dwFlags & (DDPCAPS_VSYNC| DDPCAPS_PRIMARYSURFACE| DDPCAPS_PRIMARYSURFACELEFT) ) { DPF_ERR( "Read only flags specified" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } num_size_flags = 0; if( dwFlags & DDPCAPS_1BIT ) num_size_flags++; if( dwFlags & DDPCAPS_2BIT ) num_size_flags++; if( dwFlags & DDPCAPS_4BIT ) num_size_flags++; if( dwFlags & DDPCAPS_8BIT ) num_size_flags++; if( num_size_flags != 1 ) { DPF_ERR( "Must specify one and one only of 2, 4, 16 or 256 color palette" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } if( dwFlags & DDPCAPS_ALPHA ) { if( dwFlags & DDPCAPS_8BITENTRIES ) { DPF_ERR( "8BITENTRIES not valid with ALPHA" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } } if( dwFlags & DDPCAPS_8BIT ) { if( dwFlags & DDPCAPS_8BITENTRIES ) { DPF_ERR( "8BITENTRIES only valid with 1BIT, 2BIT or 4BIT palette" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } } else { if( dwFlags & DDPCAPS_ALLOW256 ) { DPF_ERR( "ALLOW256 only valid with 8BIT palette" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } } pflags = SIZE_PCAPS_TO_FLAGS( dwFlags ); num_entries = FLAGS_TO_SIZE( pflags ); /* * Can't just assume the lpColorTable is an array of PALETTENTRYs. * If DDPCAPS_8BITENTRIES is set then this is in fact an array of * bytes in disguise. Validate appropriately. */ if( dwFlags & DDPCAPS_8BITENTRIES ) { entry_size = sizeof(BYTE); indexedpe = ((LPBYTE)lpColorTable)[num_entries-1]; // validate if( !VALID_BYTE_ARRAY( lpColorTable, num_entries ) ) { DPF_ERR( "Invalid lpColorTable array" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } /* * NOTE: You may well be wondering what this "hackindexedpe" bit is all about. * Well - indexedpe is not actually used for anything. It's only a probe to * test to see if the color table array is valid. We do this all over the place * but unfortunately we don't actually need the result here so our friend * Mr. Optimizing Compiler decides to discard the assignment and so nullify * the test. In order to ensure the array access stays in we declare dummy * variable and assign to them. This is enough to keep the code in (the * compiler is not smart enough to see that the variable assigned to is * not used). Same goes for hackpe below. */ hackindexedpe = indexedpe; } else { entry_size = sizeof(PALETTEENTRY); pe = lpColorTable[num_entries-1]; // validate if( !VALID_PALETTEENTRY_ARRAY( lpColorTable, num_entries ) ) { DPF_ERR( "Invalid lpColorTable array" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } hackpe = pe; } CheckExclusiveMode(this_lcl, NULL, &is_excl, FALSE, NULL, FALSE); } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } /* * allocate the palette object */ pal_size = sizeof( DDRAWI_DDRAWPALETTE_GBL ) + sizeof( DDRAWI_DDRAWPALETTE_LCL ); ppal_lcl = (LPDDRAWI_DDRAWPALETTE_LCL) MemAlloc( pal_size ); if( ppal_lcl == NULL ) { LEAVE_DDRAW(); return DDERR_OUTOFMEMORY; } ppal_lcl->lpGbl = (LPDDRAWI_DDRAWPALETTE_GBL) (((LPBYTE)ppal_lcl) + sizeof( DDRAWI_DDRAWPALETTE_LCL ) ); ppal = ppal_lcl->lpGbl; ppal_lcl->lpDD_lcl = this_lcl; ppal_lcl->lpDD_Int = this_int; /* * Initialize some palette global state */ ppal->dwContentsStamp = 1; if( dwFlags & DDPCAPS_ALLOW256 ) { pflags |= DDRAWIPAL_ALLOW256; } if( dwFlags & DDPCAPS_8BITENTRIES ) { pflags |= DDRAWIPAL_STORED_8INDEX; } if (dwFlags & DDPCAPS_ALPHA ) { pflags |= DDRAWIPAL_ALPHA; } ppal_lcl->pPrivateDataHead = NULL; /* * allocate palette */ ppal->lpColorTable = MemAlloc( entry_size * num_entries ); if( ppal->lpColorTable == NULL ) { MemFree( ppal_lcl ); LEAVE_DDRAW(); return DDERR_OUTOFMEMORY; } /* * Create an interface for this palette */ #ifdef POSTPONED if (LOWERTHANDDRAW4(this_int)) { #endif ppal_int = newPaletteInterface( ppal_lcl, (LPVOID)&ddPaletteCallbacks ); #ifdef POSTPONED } else { ppal_int = newPaletteInterface( ppal_lcl, (LPVOID)&ddPalette2Callbacks ); } #endif if( NULL == ppal_int ) { MemFree( ppal->lpColorTable ); MemFree( ppal_lcl ); LEAVE_DDRAW(); return DDERR_OUTOFMEMORY; } /* * copy the color table * we now copy the color table BEFORE we call the device's CreatePalette() * this is done as the device may want to overwrite certain of the palette * entries (e.g. if you don't specify DDPCAPS_ALLOW256 then the driver may * well choose to overwrite the 0 and 255 with black and white). */ memcpy( ppal->lpColorTable, lpColorTable, entry_size * num_entries ); /* * fill in misc stuff */ ppal->lpDD_lcl = this_lcl; ppal->dwFlags = pflags; /* * are palettes even supported by the driver? */ if( ( this->ddCaps.ddsCaps.dwCaps & DDSCAPS_PALETTE ) || ( this->ddHELCaps.ddsCaps.dwCaps & DDSCAPS_PALETTE ) ) { /* GEE: where do we allow the caller to require the palette * be provided in hardware? */ if( (this->dwFlags & DDRAWI_DISPLAYDRV) || this_lcl->lpDDCB->cbDDCallbacks.CreatePalette == NULL ) { // use HEL cpfn = this_lcl->lpDDCB->HELDD.CreatePalette; cphalfn = cpfn; emulation = TRUE; } else { // use HAL cpfn = this_lcl->lpDDCB->HALDD.CreatePalette; cphalfn = this_lcl->lpDDCB->cbDDCallbacks.CreatePalette; emulation = FALSE; } cpd.CreatePalette = this_lcl->lpDDCB->cbDDCallbacks.CreatePalette; cpd.lpDD = this; cpd.lpDDPalette=ppal; cpd.lpColorTable=lpColorTable; cpd.is_excl = is_excl; DOHALCALL( CreatePalette, cpfn, cpd, rc, emulation ); if( rc == DDHAL_DRIVER_HANDLED ) { if( cpd.ddRVal != DD_OK ) { DPF( 5, "DDHAL_CreatePalette: ddrval = %ld", cpd.ddRVal ); LEAVE_DDRAW(); return cpd.ddRVal; } } else { LEAVE_DDRAW(); return DDERR_UNSUPPORTED; } } else { LEAVE_DDRAW(); return DDERR_UNSUPPORTED; } /* * bump reference count, return object */ ppal->dwProcessId = GetCurrentProcessId(); ppal_lcl->dwLocalRefCnt = OBJECT_ISROOT; ppal_int->dwIntRefCnt++; ppal_lcl->dwLocalRefCnt++; ppal->dwRefCnt++; *lplpDDPalette = (LPDIRECTDRAWPALETTE) ppal_int; /* * If this ddraw object generates independent child objects, then this palette takes * a ref count on that ddraw object. */ if (CHILD_SHOULD_TAKE_REFCNT(this_int)) { /* * We need to remember which interface created this palette, in case we need to take a ref count * and then release it when the palette dies */ lpDD->lpVtbl->AddRef(lpDD); ppal_lcl->pAddrefedThisOwner = (IUnknown *) lpDD; } LEAVE_DDRAW(); return DD_OK; } /* DD_CreatePalette */ /* * ProcessPaletteCleanup * * A process is done, clean up any surfaces that it may have locked. * * NOTE: we enter with a lock taken on the DIRECTDRAW object. */ void ProcessPaletteCleanup( LPDDRAWI_DIRECTDRAW_GBL pdrv, DWORD pid, LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl ) { LPDDRAWI_DDRAWPALETTE_INT ppal_int; LPDDRAWI_DDRAWPALETTE_INT ppnext_int; LPDDRAWI_DDRAWPALETTE_GBL ppal; DWORD rcnt; /* * run through all palettes owned by the driver object, and find ones * that have been accessed by this process */ ppal_int = pdrv->palList; DPF( 4, "ProcessPaletteCleanup, ppal=%08lx", ppal_int ); while( ppal_int != NULL ) { ULONG rc; ppal = ppal_int->lpLcl->lpGbl; ppnext_int = ppal_int->lpLink; rc = 1; if( ( ppal->dwProcessId == pid ) && ( ( NULL == pdrv_lcl ) || ( pdrv_lcl == ppal_int->lpLcl->lpDD_lcl ) ) ) { /* * release the references by this process */ rcnt = ppal_int->dwIntRefCnt; DPF( 5, "Process %08lx had %ld accesses to palette %08lx", pid, rcnt, ppal_int ); while( rcnt > 0 ) { rc = InternalPaletteRelease( ppal_int ); if( rc == 0 ) { break; } rcnt--; } } else { DPF( 5, "Process %08lx does not have access to palette" ); } ppal_int = ppnext_int; } } /* ProcessPaletteCleanup */ /* * DD_Palette_IsEqual */ HRESULT EXTERN_DDAPI DD_Palette_IsEqual( LPDIRECTDRAWPALETTE lpDDPThis, LPDIRECTDRAWPALETTE lpDDPalette ) { LPDDRAWI_DDRAWPALETTE_INT this_int; LPDDRAWI_DDRAWPALETTE_LCL this_lcl; LPDDRAWI_DDRAWPALETTE_GBL this; LPDDRAWI_DDRAWPALETTE_INT pal_int; LPDDRAWI_DDRAWPALETTE_LCL pal_lcl; LPDDRAWI_DDRAWPALETTE_GBL pal; DWORD size; DWORD entry_size; UINT i,j; DWORD entry; ENTER_DDRAW(); DPF(2,A,"ENTERAPI: DD_Palette_IsEqual"); TRY { this_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPThis; if( !VALID_DIRECTDRAWPALETTE_PTR( this_int ) ) { LEAVE_DDRAW(); return DDERR_INVALIDOBJECT; } this_lcl = this_int->lpLcl; this = this_lcl->lpGbl; pal_int = (LPDDRAWI_DDRAWPALETTE_INT) lpDDPalette; if( !VALID_DIRECTDRAWPALETTE_PTR( pal_int ) ) { LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } pal_lcl = pal_int->lpLcl; pal = pal_lcl->lpGbl; } EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { DPF_ERR( "Exception encountered validating parameters" ); LEAVE_DDRAW(); return DDERR_INVALIDPARAMS; } /* * First check the flags */ if (this->dwFlags != pal->dwFlags) { DPF(2,"Different palette structures"); LEAVE_DDRAW(); return DD_FALSE; } size = FLAGS_TO_SIZE(this->dwFlags); if( this->dwFlags & DDRAWIPAL_STORED_8INDEX ) { entry_size = sizeof( BYTE ); } else { entry_size = sizeof( PALETTEENTRY ); } switch (size) { case 2: // fall-thru case 4: // fall-thru case 16: if (memcmp(this->lpColorTable, pal->lpColorTable, size*entry_size) != 0) { DPF(2, "Color tables are not the same" ); LEAVE_DDRAW(); return DD_FALSE; } break; case 256: for (i = 0; i < 16; ++i) { entry = i; for (j = 0; j < 16; j++) { if ((*(LPDWORD)&(this->lpColorTable[entry]) != (*(LPDWORD)&pal->lpColorTable[entry]))) { DPF(5,"Color table entry mismatch: 0x%08x, 0x%08x", *(LPDWORD)&this->lpColorTable[entry], *(LPDWORD)&pal->lpColorTable[entry] ); LEAVE_DDRAW(); return DD_FALSE; } entry += 16; } } } /* * The palettes are the same! */ LEAVE_DDRAW(); return DD_OK; } /* DD_Palette_SetEntries */
28.203635
124
0.585543
[ "object" ]
2d7e22f792bfa402c426f25659454bfea906f9ab
466
h
C
Validation/Environment.h
MichealEButler/TreeABM
f5bca9d0fb4cc6b2100295d6f252a771b398477a
[ "MIT" ]
null
null
null
Validation/Environment.h
MichealEButler/TreeABM
f5bca9d0fb4cc6b2100295d6f252a771b398477a
[ "MIT" ]
null
null
null
Validation/Environment.h
MichealEButler/TreeABM
f5bca9d0fb4cc6b2100295d6f252a771b398477a
[ "MIT" ]
null
null
null
#ifndef ENVIRONMENT_H #define ENVIRONMENT_H #include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector> using namespace std; class Environment { public: Environment(); ~Environment(); void loadDEGD(string filename, float change); void loadRain(string filename); void closeFile(string filename); void readDEGD(string filename); vector<int> _year; vector<float> _DEGD; vector<float> _rain; private: }; #endif
15.032258
47
0.733906
[ "vector" ]
2d80c2017094ed3d412f4657b03e59b7c85e7d48
944
h
C
server/src/hsogserver/meta/impl/SensorConfig.h
TeamAutonomousCarOffenburg/TACO_2018
ebb63e466578fc3911269d4a714ebff0a516dbf6
[ "BSD-3-Clause" ]
1
2019-09-11T23:06:25.000Z
2019-09-11T23:06:25.000Z
server/src/hsogserver/meta/impl/SensorConfig.h
TeamAutonomousCarOffenburg/TACO_2018
ebb63e466578fc3911269d4a714ebff0a516dbf6
[ "BSD-3-Clause" ]
null
null
null
server/src/hsogserver/meta/impl/SensorConfig.h
TeamAutonomousCarOffenburg/TACO_2018
ebb63e466578fc3911269d4a714ebff0a516dbf6
[ "BSD-3-Clause" ]
1
2019-04-08T09:52:24.000Z
2019-04-08T09:52:24.000Z
#pragma once #include "meta/ISensorConfig.h" #include "utils/geometry/Pose3D.h" #include <eigen3/Eigen/Dense> namespace taco { /** * The SensorConfig represents an arbitrary sensor configuration. * * \author Stefan Glaser */ class SensorConfig : public virtual ISensorConfig { public: SensorConfig(const std::string &name, const Eigen::Vector3d &position, const Eigen::AngleAxisd &orientation); SensorConfig(const std::string &name, const std::string &perceptorName, const Eigen::Vector3d &position, const Eigen::AngleAxisd &orientation); virtual ~SensorConfig(); virtual const std::string &getName() const; virtual const std::string &getPerceptorName() const; virtual const Pose3D &getPose() const; private: /** The name of the sensor. */ std::string _name; /** The corresponding perceptor name */ std::string _perceptorName; /** The position where and how the sensor is mounted on the car. */ Pose3D _pose; }; }
24.842105
110
0.736229
[ "geometry" ]
2d88e6b931a934de21176e1fef98f3712fa381d6
3,388
h
C
tools/clang/plugins/CheckIPCVisitor.h
ADVAN-ELAA-8QM-PRC1/platform-external-v8
d424a9e93b8e25ab0e3ac5aead27a5fac0795a1b
[ "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
tools/clang/plugins/CheckIPCVisitor.h
ADVAN-ELAA-8QM-PRC1/platform-external-v8
d424a9e93b8e25ab0e3ac5aead27a5fac0795a1b
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
tools/clang/plugins/CheckIPCVisitor.h
ADVAN-ELAA-8QM-PRC1/platform-external-v8
d424a9e93b8e25ab0e3ac5aead27a5fac0795a1b
[ "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright (c) 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This check ensures that 32/64-bit unstable types are not used in IPC. // // A type (or typedef) is unstable if it changes size between 32/ 64-bit // platforms. However, it's impossible to accurately identify unstable // typedefs, because their definitions rely on the preprocessor. For // example uintptr_t is either unsigned int or unsigned long. // // So we're not trying to be accurate, and just blacklisting some types // that are known to be unstable: // 1. Types: long / unsigned long (but not typedefs to) // 2. Typedefs: intmax_t, uintmax_t, intptr_t, uintptr_t, wint_t, // size_t, rsize_t, ssize_t, ptrdiff_t, dev_t, off_t, clock_t, // time_t, suseconds_t (including typedefs to) // // Additionally, templates referencing blacklisted types (e.g. vector<long>) // are also blacklisted. // // Blacklisted types are checked in: // 1. IPC::WriteParam() calls // 2. IPC::CheckedTuple<> specializations // #ifndef TOOLS_CLANG_PLUGINS_CHECKIPC_VISITOR_H_ #define TOOLS_CLANG_PLUGINS_CHECKIPC_VISITOR_H_ #include <vector> #include "clang/AST/AST.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Frontend/CompilerInstance.h" #include "llvm/ADT/StringSet.h" namespace chrome_checker { class CheckIPCVisitor { public: explicit CheckIPCVisitor(clang::CompilerInstance& compiler); void set_context(clang::ASTContext* context) { context_ = context; } void BeginDecl(clang::Decl* decl); void EndDecl(); void VisitTemplateSpecializationType( clang::TemplateSpecializationType* spec); void VisitCallExpr(clang::CallExpr* call_expr); private: // ValidateXXX functions return false if validation failed and diagnostic // was reported. They return true otherwise (not applicable / validation // succeeded). bool ValidateWriteParam(const clang::CallExpr* call_expr); bool ValidateWriteParamSignature(const clang::CallExpr* call_expr); bool ValidateWriteParamArgument(const clang::Expr* arg_expr); bool ValidateCheckedTuple( const clang::TemplateSpecializationType* spec); template <typename T> const T* GetParentDecl() const; bool IsBlacklistedType(clang::QualType type) const; bool IsBlacklistedTypedef(const clang::TypedefNameDecl* tdef) const; struct CheckDetails { clang::QualType entry_type; clang::QualType exit_type; llvm::SmallVector<const clang::TypedefType*, 5> typedefs; }; bool CheckType(clang::QualType type, CheckDetails* details) const; bool CheckIntegerType(clang::QualType type, CheckDetails* details) const; bool CheckTemplateArgument(const clang::TemplateArgument& arg, CheckDetails* details) const; void ReportCheckError(const CheckDetails& details, clang::SourceLocation loc, unsigned error); clang::CompilerInstance& compiler_; clang::ASTContext* context_; unsigned error_write_param_bad_type_; unsigned error_tuple_bad_type_; unsigned error_write_param_bad_signature_; unsigned note_see_here_; std::vector<const clang::Decl*> decl_stack_; llvm::StringSet<> blacklisted_typedefs_; }; } // namespace chrome_checker #endif // TOOLS_CLANG_PLUGINS_CHECKIPC_VISITOR_H_
33.88
76
0.748819
[ "vector" ]
2d8fb3f8b1a38599865dc8dfc3a3bd604a1ba24a
1,219
h
C
toolbox/unused/shear_forces.h
katjawolff/custom_fit_garments
1d6f9dcba612010bb5552201f39595f7b288b8d5
[ "MIT" ]
4
2021-08-15T09:28:51.000Z
2022-03-14T10:19:09.000Z
toolbox/unused/shear_forces.h
katjawolff/custom_fit_garments
1d6f9dcba612010bb5552201f39595f7b288b8d5
[ "MIT" ]
1
2021-12-24T07:16:34.000Z
2021-12-24T07:16:34.000Z
toolbox/unused/shear_forces.h
katjawolff/custom_fit_garments
1d6f9dcba612010bb5552201f39595f7b288b8d5
[ "MIT" ]
null
null
null
#ifndef GARMENTSHAPE_SHEAR_FORCES_H #define GARMENTSHAPE_SHEAR_FORCES_H #include <vector> #include <Eigen/Sparse> #include <Eigen/Dense> class Shear{ private: double k_shear; double k_damping; int n, m, n3, m81; // number of vertices and faces Eigen::VectorXd a; // triangle area of reference configuration std::vector< Eigen::MatrixXd > B; // precomp std::vector< Eigen::Matrix2d > V_inverse; // transformation matrix for each triangle of reference configuration Eigen::MatrixXi F; Eigen::SparseMatrix<double> K; // out: stiffness matrix Eigen::SparseMatrix<double> D; // out: damping matrix Eigen::VectorXi K_data, D_data; // store the non-zero index data for K and D public: Shear(); void init(double k_shear, double k_damping, Eigen::MatrixXd& V, Eigen::MatrixXi& F); void precompute_rest_shape(Eigen::MatrixXd& V); void compute_forces( const Eigen::MatrixXd& X, // in: vertex positions const Eigen::VectorXd& V, // in: velocitiy at vertex positions Eigen::VectorXd& F, // out: force vector Eigen::SparseMatrix<double>& K, // out: stiffness matrix Eigen::SparseMatrix<double>& D // out: damping matrix ); }; #endif //GARMENTSHAPE_SHEAR_SHEAR_FORCES_H
30.475
112
0.721083
[ "vector" ]
31a579bc12d4020ef943c95c89c5100f9e9a4dc1
18,556
h
C
entity.h
AutoLS/Bullet-Hell-NSFW
6768db9b9d7f94adb9e74ebdcf0fd8896e7fdf71
[ "MIT" ]
null
null
null
entity.h
AutoLS/Bullet-Hell-NSFW
6768db9b9d7f94adb9e74ebdcf0fd8896e7fdf71
[ "MIT" ]
null
null
null
entity.h
AutoLS/Bullet-Hell-NSFW
6768db9b9d7f94adb9e74ebdcf0fd8896e7fdf71
[ "MIT" ]
null
null
null
#ifndef ENTITY_H #define ENTITY_H #include "physics.h" #include "animation.h" enum entity_type { ENTITY_TYPE_PLAYER, ENTITY_TYPE_WALL, ENTITY_TYPE_WALL_DYNAMIC, ENTITY_TYPE_SPIKE, ENTITY_TYPE_FIREBALL_1, ENTITY_TYPE_BOSS_1, ENTITY_TYPE_DILDO, ENTITY_TYPE_WATER_DROP, ENTITY_TYPE_CUM_DROP, }; enum entity_spawn_timer { PLATFORM_SPAWN_TIMER, PLAYER_ATTACK_SPAWN_TIMER, DILDO_ATTACK_SPAWN_TIMER, DILDO_ATTACK_2_SPAWN_TIMER, DILDO_ATTACK_3_SPAWN_TIMER, WATER_DROP_ATTACK_SPAWN_TIMER, CUM_DROP_ATTACK_SPAWN_TIMER, CUM_DROP_ATTACK_2_SPAWN_TIMER, CUM_DROP_ATTACK_3_SPAWN_TIMER, MAX_SPAWN_TIMER, }; struct entity { rigid_body Body; entity_type Type; real32 HP; real32 Theta; bool Sliding; bool Attack; bool OnGround; bool OnSlope; bool Jump; bool Translating; bool Invincible; bool Static; v2 TranslatePos; bool Alive; animation* Animation; int AnimationCount; image_data Texture; timer Timer; }; struct entity_pool { entity* Entities; stack DeadStack; int UsedEntities; int PlayerIndex; int EntitySize; }; entity_pool InitializeEntityPool(int EntitySize, uint32 StackCapacity) { entity_pool EntityPool = {}; EntityPool.EntitySize = EntitySize; EntityPool.Entities = (entity*)malloc(sizeof(entity) * EntitySize); EntityPool.DeadStack.Size = 0; EntityPool.DeadStack.Capacity = StackCapacity; EntityPool.DeadStack.MyStack = (int*)malloc(sizeof(int) * EntityPool.DeadStack.Capacity); Push(&EntityPool.DeadStack, -1); return EntityPool; } void ClearEntityPool(entity_pool* Pool) { Pool->UsedEntities = 0; Pool->Entities = (entity*)malloc(sizeof(entity) * Pool->EntitySize); Pool->DeadStack.Size = 0; Pool->DeadStack.Capacity = 5; free(Pool->DeadStack.MyStack); Pool->DeadStack.MyStack = (int*)malloc(sizeof(int) * Pool->DeadStack.Capacity); Push(&Pool->DeadStack, -1); } int AddEntity(entity_pool* Pool, rigid_body Body, animation* Animation, int AnimationCount, entity_type Type, real32 HP = 0, image_data Texture = {}, real32 Theta = 0, timer Timer = {}) { entity Entity = {}; Entity.Body = Body; Entity.Type = Type; Entity.Alive = true; Entity.Animation = Animation; Entity.AnimationCount = AnimationCount; Entity.Texture = Texture; Entity.HP = HP; if(Timer.Time == 0) Entity.Timer = CreateTimer(0); else Entity.Timer = Timer; Entity.Theta = Theta; switch(Type) { case ENTITY_TYPE_WALL: case ENTITY_TYPE_WALL_DYNAMIC: case ENTITY_TYPE_SPIKE: Entity.Static = true; } int DeadIndex = Peek(&Pool->DeadStack); if(DeadIndex == -1) { Pool->Entities[Pool->UsedEntities++] = Entity; return Pool->UsedEntities - 1; } else { Pool->Entities[DeadIndex] = Entity; Pop(&Pool->DeadStack); return DeadIndex; } } void KillEntity(entity_pool* Pool, int Index) { entity* Entity = &Pool->Entities[Index]; if(!Entity->Invincible) { Entity->Alive = false; Push(&Pool->DeadStack, Index); } //printf("Killed. Entity index: %d\n", Pool->UsedEntities); } bool IsEntityOutOfScreen(entity* Entity, v2 WinDim) { return Entity->Body.Position.x > WinDim.x || Entity->Body.Position.x < -WinDim.x || Entity->Body.Position.y > WinDim.y || Entity->Body.Position.y < -WinDim.y; } void ProcessEntityAnimationTimers(entity_pool* Pool, real32 t) { for(int i = 0; i < Pool->UsedEntities; ++i) { entity* Entity = &Pool->Entities[i]; if(Entity->Animation && Entity->Alive) { for(int j = 0; j < Entity->AnimationCount; ++j) { ProcessTimer(&Entity->Animation[j].Timer, t); } } } } void ProcessEntitySpawnTimers(timer* Timer, real32 t) { for(int i = 0; i < MAX_SPAWN_TIMER; ++i) { ProcessTimer(&Timer[i], t); } } void TranslateEntity(entity* Entity, v2 Pos, real32 Speed = 200.0f) { v2 Distance = Pos - Entity->Body.Position; real32 R = Length(Distance); real32 Theta = Degrees((real32)acos(Distance.x/R)); if(R) { Entity->Translating = true; Entity->TranslatePos = Pos; if(Distance.y > 0) Entity->Body.Velocity = V2(Cos(Radians(Theta)), Sin(Radians(Theta))) * Speed; else Entity->Body.Velocity = V2(Cos(Radians(Theta)), -Sin(Radians(Theta))) * Speed; } } void SpawnFloatingPlatform(entity_pool* Pool, v2 WinDim, v2 Range) { rigid_body Platform = {}; v2 P = V2(Rand32(Range.x, Range.y), -400); Platform = InitializeBody(P, V2(0, 30), V2(100, 25), V2(100, 25), WinDim, 0, 50); AddEntity(Pool, Platform, 0, 0, ENTITY_TYPE_WALL); } void DildoAttack(entity_pool* Pool, v2 WinDim, image_data Texture, v2 Range) { v2 P = V2(Rand32(Range.x, Range.y), 400); rigid_body Dildo = InitializeBody(P, V2(0, -300), V2(40, 145), V2(180, 180), WinDim, 180, 50, BODY_RECT, V2(0, -15)); AddEntity(Pool, Dildo, 0, 0, ENTITY_TYPE_DILDO, 0, Texture); } void DildoAttack2(entity_pool* Pool, v2 WinDim, image_data Texture, v2 Pos) { real32 Theta = Rand32(-30, 30); rigid_body Dildo = InitializeBody(Pos, V2(-Cos(Radians(Theta)), -Sin(Radians(Theta))) * 200, V2(10, 50), V2(50, 50), WinDim, 90 + Theta, 50); AddEntity(Pool, Dildo, 0, 0, ENTITY_TYPE_DILDO, 0, Texture); } void DildoAttack3(entity_pool* Pool, image_data Texture, v2 WinDim) { v2 Pos = V2(Rand32(-500, 500), Rand32(100, 400)); v2 Distance = Pos - Pool->Entities[Pool->PlayerIndex].Body.Position; real32 R = Length(Distance); real32 X = Distance.x/R; real32 Theta = Degrees((real32)acos(X)); rigid_body Dildo = InitializeBody(Pos, V2(), V2(45, 180), V2(180, 180), WinDim, Theta + 90, 10); Dildo.Force = V2(-Cos(Radians(Theta)), -Sin(Radians(Theta))) * 3000; AddEntity(Pool, Dildo, 0, 0, ENTITY_TYPE_DILDO, 0, Texture); } void WaterDropAttack(entity_pool* Pool, v2 WinDim, image_data Texture, v2 Pos) { int Count = rand() % 5 + 1; real32 Theta = 0; for(int i = 0; i < Count; ++i) { Theta = Rand32(-60, -30); rigid_body WaterDrop = InitializeBody(Pos, V2(-Cos(Radians(Theta)), Sin(Radians(Theta)*100)) * 300, V2(30, 45), V2(100, 100), WinDim, Theta, 50); AddEntity(Pool, WaterDrop, 0, 0, ENTITY_TYPE_WATER_DROP, 0, Texture); } } void CumDropAttack(entity_pool* Pool, v2 WinDim, image_data Texture, v2 Pos, real32 t) { real32 Theta = Sin(t*10) * 70 + 270; v2 Dim = V2(20.38f, 38.76f); v2 RenderDim = V2(24.38f, 44.76f); rigid_body Cum = InitializeBody(Pos, V2(Cos(Radians(Theta)), Sin(Radians(Theta))) * 400, Dim, RenderDim, WinDim, Theta - 270, 10); AddEntity(Pool, Cum, 0, 0, ENTITY_TYPE_CUM_DROP, 0, Texture); } void CumDropAttack2(entity_pool* Pool, v2 WinDim, image_data Texture, v2 Pos, real32 t) { real32 Theta = t * 30; v2 Dim = V2(20.38f, 38.76f); v2 RenderDim = V2(24.38f, 44.76f); for(int i = 0; i < 4; ++i) { rigid_body Cum = InitializeBody(Pos, V2(Cos(Radians(Theta)), Sin(Radians(Theta))) * 400, Dim, RenderDim, WinDim, Theta + 90, 10); AddEntity(Pool, Cum, 0, 0, ENTITY_TYPE_CUM_DROP, 0, Texture); Theta += 90; } } real32 CumDropAttack3(entity_pool* Pool, v2 WinDim, image_data Texture, v2 Pos) { v2 Distance = Pos - Pool->Entities[Pool->PlayerIndex].Body.Position; real32 R = Length(Distance); real32 X = Distance.x/R; real32 Theta = Degrees((real32)acos(X)); v2 Dim = V2(15.38f, 38.76f); v2 RenderDim = V2(24.38f, 44.76f); rigid_body Dildo = InitializeBody(Pos, V2(), Dim, RenderDim, WinDim, Theta + 270, 10); Dildo.Force = V2(-Cos(Radians(Theta)), -Sin(Radians(Theta))) * 3000; AddEntity(Pool, Dildo, 0, 0, ENTITY_TYPE_DILDO, 0, Texture); return Theta; } void CumDropAttack4(entity_pool* Pool, v2 WinDim, image_data Texture, v2 Pos) { real32 Theta = 10; v2 Dim = V2(20.38f, 38.76f); v2 RenderDim = V2(24.38f, 44.76f); for(int i = 0; i < 12; ++i) { rigid_body Cum = InitializeBody(Pos, V2(Cos(Radians(Theta)), Sin(Radians(Theta))) * 200, Dim, RenderDim, WinDim, Theta + 90, 10); AddEntity(Pool, Cum, 0, 0, ENTITY_TYPE_DILDO, 0, Texture); Theta += 30; } } void UpdatePlayer(entity* Player, game_input* GameInput, v2 WinDim, real32 t) { v2 Force = V2(); real32 Theta = 0; real32 Drag = 5.0f; if(GameInput->KeyState[SDL_SCANCODE_LEFT] && !Player->Attack && !Player->Sliding) { Player->Body.Flip = SDL_FLIP_HORIZONTAL; Force += V2(-12500, 0); } if(GameInput->KeyState[SDL_SCANCODE_RIGHT] && !Player->Attack && !Player->Sliding) { Player->Body.Flip = SDL_FLIP_NONE; Force += V2(12500, 0); } if(GameInput->Keyboard.Keys[KEY_DOWN].EndedDown && Length(Player->Body.Velocity) > 200 && Player->OnGround) { Player->Sliding = true; if(Length(Player->Body.Velocity) < 250) Player->Body.Velocity.x *= 1.3f; if(Player->Body.Flip == SDL_FLIP_HORIZONTAL) { Theta -= 90; } else { Theta += 90; } if(Player->Body.Angle != 0) { Theta = 0; } } if(Player->Sliding) { Drag = 1.5f; //Force += V2(3000,0); } if(Player->Body.Angle != 0 && (!GameInput->KeyState[SDL_SCANCODE_DOWN] || Length(Player->Body.Velocity) < 70)) { Player->Sliding = false; Theta += -Player->Body.Angle; //Player->Body.Angle += Theta; printf("%.1f\n", Theta); } Force += V2(0, -9800); Player->Body.Force = Force; Player->Body.Angle += Theta; ComputeTorque(&Player->Body); IntegrateLinearMotion(&Player->Body, t, WinDim, Drag); RotatePolygon(&Player->Body.Shape.Polygon, Theta, WinDim); //IntegrateAngularMotion(&Player->Body, t); } void UpdateEntities(entity_pool* Pool, render* Graphics, game_input* GameInput, real32 t, image_data* GameAssets, timer* EntitySpawnTimer) { int PlayerIndex = Pool->PlayerIndex; v2 WinDim = V2(Graphics->WinDim); for(int i = 0; i < Pool->UsedEntities; ++i) { entity* Entity = &Pool->Entities[i]; if(Entity->Alive) { switch(Entity->Type) { case ENTITY_TYPE_PLAYER: { UpdatePlayer(Entity, GameInput, WinDim, t); Entity->Body.RenderRect = SetRectRounded(Entity->Body.Position, Entity->Body.RenderDim); } break; case ENTITY_TYPE_FIREBALL_1: { real32 Drag = 0.0f; IntegrateLinearMotion(&Entity->Body, t, WinDim, Drag); v2 P = Entity->Body.Position; v2 Dim = Entity->Body.Shape.Dim; Entity->Body.Rect = Rect32(V2(P.x - Dim.x * 0.5f, P.y - Dim.y * 0.5f), Dim); Entity->Body.RenderRect = SetRectRounded(Entity->Body.Position, Entity->Body.RenderDim); if(IsEntityOutOfScreen(Entity, WinDim)) { KillEntity(Pool, i); } } break; case ENTITY_TYPE_WALL: case ENTITY_TYPE_WALL_DYNAMIC: { real32 Drag = 0.0f; IntegrateLinearMotion(&Entity->Body, t, WinDim, Drag); v2 P = Entity->Body.Position; v2 Dim = Entity->Body.Shape.Dim; Entity->Body.Rect = Rect32(V2(P.x - Dim.x * 0.5f, P.y - Dim.y * 0.5f), Dim); Entity->Body.RenderRect = SetRectRounded(Entity->Body.Position, Entity->Body.RenderDim); if(IsEntityOutOfScreen(Entity, WinDim)) { KillEntity(Pool, i); } } break; case ENTITY_TYPE_BOSS_1: { real32 Drag = 0.0f; IntegrateLinearMotion(&Entity->Body, t, WinDim, Drag); Entity->Body.RenderRect = SetRectRounded(Entity->Body.Position, Entity->Body.RenderDim); } break; case ENTITY_TYPE_DILDO: { real32 Drag = 0; IntegrateLinearMotion(&Entity->Body, t, WinDim, Drag); Entity->Body.RenderRect = SetRectRounded(Entity->Body.Position, Entity->Body.RenderDim); if(IsEntityOutOfScreen(Entity, WinDim)) { KillEntity(Pool, i); } } break; case ENTITY_TYPE_CUM_DROP: { real32 Drag = 0; IntegrateLinearMotion(&Entity->Body, t, WinDim, Drag); Entity->Body.RenderRect = SetRectRounded(Entity->Body.Position, Entity->Body.RenderDim); if(IsEntityOutOfScreen(Entity, WinDim)) { KillEntity(Pool, i); } } break; case ENTITY_TYPE_WATER_DROP: { v2 Force = V2(-3000, -9800); real32 Drag = 0; Entity->Body.Force = Force; ComputeTorque(&Entity->Body, Entity->Body.Shape.Dim * 0.5f); IntegrateLinearMotion(&Entity->Body, t, WinDim, Drag); IntegrateAngularMotion(&Entity->Body, t, WinDim); Entity->Body.RenderRect = SetRectRounded(Entity->Body.Position, Entity->Body.RenderDim); if(IsEntityOutOfScreen(Entity, WinDim)) { KillEntity(Pool, i); } } break; } if(Entity->Translating) { if(Length(Entity->TranslatePos - Entity->Body.Position) < 5) { Entity->Translating = false; Entity->Body.Velocity = V2(); } } } } } void ResolveEntitiesCollision(entity_pool* Pool, v2 WinDim, real32 t, game_state* GameState, Mix_Chunk** SFX) { for(int i = 0; i < Pool->UsedEntities; ++i) { entity* EntityA = &Pool->Entities[i]; if(*GameState == STATE_GAMEOVER) break; if(EntityA->Alive && !EntityA->Static) { for(int j = 0; j < Pool->UsedEntities; ++j) { entity* EntityB = &Pool->Entities[j]; if(i != j && EntityB->Alive && EntityB->Type != EntityA->Type && TestAABB(&EntityA->Body.BoundingBox, &EntityB->Body.BoundingBox)) { switch(EntityA->Type) { case ENTITY_TYPE_PLAYER: { CheckCollision(&EntityA->Body, &EntityB->Body); switch(EntityB->Type) { case ENTITY_TYPE_WALL: case ENTITY_TYPE_WALL_DYNAMIC: { ResolveCollision(&EntityA->Body, WinDim); if(IsBodyOnGround(&EntityA->Body, &EntityB->Body)) { EntityA->OnGround = true; EntityA->Jump = false; } if(IsBodyOnSlope(&EntityA->Body, &EntityB->Body)) { EntityA->OnSlope = true; } } break; case ENTITY_TYPE_FIREBALL_1: break; case ENTITY_TYPE_SPIKE: case ENTITY_TYPE_BOSS_1: { if(EntityA->Body.CollideInfo.Collide) EntityA->HP -= 100; } break; default: { if(EntityA->Body.CollideInfo.Collide && !EntityA->Timer.Active) { //printf("Dead\n"); //*GameState = STATE_GAMEOVER; Mix_PlayChannel(-1, SFX[OOF_SFX], 0); StartTimer(&EntityA->Timer); EntityA->HP--; KillEntity(Pool, j); break; } } }; } break; case ENTITY_TYPE_FIREBALL_1: { CheckCollision(&EntityA->Body, &EntityB->Body); switch(EntityB->Type) { case ENTITY_TYPE_WALL: case ENTITY_TYPE_WALL_DYNAMIC: { ResolveCollisionReflect(&EntityA->Body, WinDim); } break; case ENTITY_TYPE_BOSS_1: { if(EntityA->Body.CollideInfo.Collide) { if(!Mix_Playing(1)) { Mix_Volume(1, 20); Mix_PlayChannel(1, SFX[HENTAI_MOAN_SFX], 0); } SDL_SetTextureColorMod(EntityB->Texture.Texture, 255, 50, 50); EntityB->HP -= 2; KillEntity(Pool, i); printf("HP: %.1f\n", EntityB->HP); } } break; }; } break; case ENTITY_TYPE_WATER_DROP: { CheckCollision(&EntityA->Body, &EntityB->Body); switch(EntityB->Type) { case ENTITY_TYPE_WALL: case ENTITY_TYPE_WALL_DYNAMIC: { ResolveCollisionReflect(&EntityA->Body, WinDim); } break; }; } break; case ENTITY_TYPE_CUM_DROP: { if(TestGJK(&EntityA->Body.Shape.Polygon, &EntityB->Body.Shape.Polygon)) { switch(EntityB->Type) { case ENTITY_TYPE_WALL: case ENTITY_TYPE_WALL_DYNAMIC: { KillEntity(Pool, i); } break; }; } } break; } } } } } } void ResetEntityTextureMod(entity_pool* Pool) { for(int i = 0; i < Pool->UsedEntities; ++i) { entity* Entity = &Pool->Entities[i]; if(Entity->Alive && Entity->Texture.Texture) { uint8 r = Entity->Texture.r; uint8 g = Entity->Texture.g; uint8 b = Entity->Texture.b; SDL_SetTextureColorMod(Entity->Texture.Texture, r, g, b); } } } void RenderEntities(entity_pool* Pool, render* Graphics) { for(int i = 0; i < Pool->UsedEntities; ++i) { entity Entity = Pool->Entities[i]; if(Entity.Alive) { switch(Entity.Type) { case ENTITY_TYPE_PLAYER: { if(Entity.Body.Angle != 0) { Entity.Body.Angle -= Entity.Body.Angle; Entity.Body.RenderRect.y += 10; RenderAnimation(&Entity.Animation[PLAYER_SLIDE_ANIMATION], Graphics, &Entity.Body); } else if(Entity.Attack) { RenderAnimation(&Entity.Animation[PLAYER_ATTACK_ANIMATION], Graphics, &Entity.Body); if(Entity.Animation[PLAYER_ATTACK_ANIMATION].Ended) Pool->Entities[i].Attack = false; } else if(Length(Entity.Body.Velocity) >= 1.3f && Entity.Body.Colliding) { RenderAnimation(&Entity.Animation[PLAYER_RUN_ANIMATION], Graphics, &Entity.Body); } else if(Length(Entity.Body.Velocity) >= 1.3f) { if(Entity.Body.Velocity.y < -200) { Pool->Entities[i].Animation[PLAYER_JUMP_ANIMATION].Ended = true; } RenderAnimation(&Entity.Animation[PLAYER_JUMP_ANIMATION], Graphics, &Entity.Body); } else { RenderAnimation(&Entity.Animation[PLAYER_IDLE_ANIMATION], Graphics, &Entity.Body); } } break; case ENTITY_TYPE_WALL: case ENTITY_TYPE_WALL_DYNAMIC: { DrawBodyLines(&Entity.Body, Graphics->Renderer, {255, 255, 255, 255}); } break; case ENTITY_TYPE_FIREBALL_1: { //DrawBodyLines(&Entity.Body, Graphics->Renderer, {255, 255, 255, 255}); StartAnimation(Pool->Entities[i].Animation); RenderAnimation(Pool->Entities[i].Animation, Graphics, &Entity.Body); } break; case ENTITY_TYPE_BOSS_1: { //DrawBodyLines(&Entity.Body, Graphics->Renderer, {255, 255, 255, 255}); RenderBody(&Entity.Body, Graphics, Entity.Texture.Texture, 0, &Entity.Body.RenderRect); } break; default: { //DrawBodyLines(&Entity.Body, Graphics->Renderer, {255, 255, 255, 255}); RenderBody(&Entity.Body, Graphics, Entity.Texture.Texture, 0, &Entity.Body.RenderRect); } } } } } #endif
28.200608
125
0.623949
[ "render", "shape" ]
31a5f28a3b50cee0b8e7d31b2306b5954457a08b
1,594
c
C
SGP-SGM/TP nachos/test/test_lock.c
nap56/Master1
5944ffdb16c09ced7aaef4e18f9164386da93c65
[ "MIT" ]
null
null
null
SGP-SGM/TP nachos/test/test_lock.c
nap56/Master1
5944ffdb16c09ced7aaef4e18f9164386da93c65
[ "MIT" ]
null
null
null
SGP-SGM/TP nachos/test/test_lock.c
nap56/Master1
5944ffdb16c09ced7aaef4e18f9164386da93c65
[ "MIT" ]
null
null
null
/** * * Simple test case for the locks synchronisation * * ANDRIAMILANTO Tompoariniaina * IHSINE Azzeddine * * TP SGP nachos * 2015 - 2016 * */ // Nachos system calls #include "userlib/syscall.h" #include "userlib/libnachos.h" #define MAX_THREADS 10 ThreadId threads[MAX_THREADS]; int i = 1; // Function to say who is each threads void whoAmI(int l) { // Transform the lock LockId lock = (LockId)l; int x; // Take the lock if (LockAcquire(lock) < 0) n_printf("Error acquire lock"); // Wait and then display who he is n_printf("I am the thread number %d!\n", i); x = i; i++; // Release the lock if (LockRelease(lock) < 0) n_printf("Error release lock"); n_printf("End of thread n°%d\n", x); Exit(0); } /** * Main function */ int main() { // Create a lock LockId lock = LockCreate("Lock"); // Take the lock if (LockAcquire(lock) < 0) n_printf("Error acquire lock"); // Create a lot of threads int j; for(j = 0; j < MAX_THREADS; j++) { n_printf("Thread n°%d, lock = %d and whoAmI = %d \n", j, (int)lock, (int)whoAmI); threads[j] = newThread("Thread", (int)whoAmI, (int)lock); } // Release the lock n_printf("End of threads creating, now we release the lock\n"); if (LockRelease(lock) < 0) n_printf("Error release lock"); n_printf("The main lock is finally released\n"); // Wait each threads for (j = 0; j < MAX_THREADS; j++) { if (Join(threads[j]) < 0) n_printf("Error joining thread j=%d", j); } // Destroy the lock if (LockDestroy(lock) < 0) n_printf("Error destroying the lock"); // Exit the program return 0; }
18.534884
83
0.643036
[ "transform" ]
31a8b42538baa0bf305a66d987659747550bd2ca
631
h
C
samples/client/petstore/cpp-tizen/src/Helpers.h
MalcolmScoffable/openapi-generator
73605a0c0e0c825286c95123c63678ba75b44d5c
[ "Apache-2.0" ]
14,570
2015-01-01T21:46:46.000Z
2022-03-31T22:28:15.000Z
samples/client/petstore/cpp-tizen/src/Helpers.h
MalcolmScoffable/openapi-generator
73605a0c0e0c825286c95123c63678ba75b44d5c
[ "Apache-2.0" ]
9,672
2018-05-12T14:25:43.000Z
2022-03-31T23:59:30.000Z
samples/client/petstore/cpp-tizen/src/Helpers.h
MalcolmScoffable/openapi-generator
73605a0c0e0c825286c95123c63678ba75b44d5c
[ "Apache-2.0" ]
6,907
2015-01-02T05:29:47.000Z
2022-03-31T00:55:45.000Z
#ifndef _HELPERS_H_ #define _HELPERS_H_ #include <string> #include <glib-object.h> #include <json-glib/json-glib.h> using namespace std; JsonNode * json_from_string (const char *str, GError **mygerror); char * json_to_string (JsonNode *node, gboolean pretty); JsonNode* converttoJson(void* v, string type, string containerType); void jsonToValue(void* target, JsonNode* ptr, string type, string innerType); void helper_func(JsonObject *object, const gchar* member_name, JsonNode *member_node,gpointer user_data); string stringify(void* ptr, string type); bool isprimitive(string type); #endif /* HELPERS_H_ */
20.354839
105
0.754358
[ "object" ]
31ab893b32cfe864737773f23968e33e89c21fc4
631
h
C
src/models/executable.h
remeh/mehstation-config
15bac605127dbe15f89fd53ae1d769b0d03c744b
[ "MIT" ]
3
2017-01-03T04:40:02.000Z
2021-02-25T13:45:19.000Z
src/models/executable.h
remeh/mehstation-config
15bac605127dbe15f89fd53ae1d769b0d03c744b
[ "MIT" ]
1
2016-12-12T18:30:09.000Z
2016-12-12T20:26:25.000Z
src/models/executable.h
remeh/mehstation-config
15bac605127dbe15f89fd53ae1d769b0d03c744b
[ "MIT" ]
null
null
null
#pragma once #include <QList> #include <QString> #include "model.h" #include "executable_resource.h" class Executable : public Model { public: Executable(); Executable(int id, int platformId, QString displayName, QString filepath, QString description, QString genres, QString players, QString publisher, QString developer, QString releaseDate, QString rating); int id; int platformId; QString displayName; QString filepath; QString description; QString genres; QString players; QString publisher; QString developer; QString releaseDate; QString rating; QList<ExecutableResource> resources; };
22.535714
112
0.757528
[ "model" ]
31b2350f7cb880eaf00f353ea6f3b390bbe720f1
4,552
h
C
NeuroKernel/network/HiddenLayer.h
lesit/NeuroStudio
f505065d694a8614587e7cc243ede72c141bd80b
[ "W3C" ]
21
2018-11-15T08:23:14.000Z
2022-03-30T15:44:59.000Z
NeuroKernel/network/HiddenLayer.h
lesit/NeuroStudio
f505065d694a8614587e7cc243ede72c141bd80b
[ "W3C" ]
null
null
null
NeuroKernel/network/HiddenLayer.h
lesit/NeuroStudio
f505065d694a8614587e7cc243ede72c141bd80b
[ "W3C" ]
1
2021-12-08T01:17:27.000Z
2021-12-08T01:17:27.000Z
#pragma once #include "AbstractLayer.h" #include "core/filter_calc.h" #include "../nsas/NeuroEntryAccess.h" #include "NeuralNetworkTypes.h" namespace np { namespace network { struct _SLICE_INPUT { AbstractLayer* layer; nsas::_SLICE_INFO slice_info; tensor::TensorShape GetTensor() const { return slice_info.GetTensor(layer->GetOutTensorShape()); } }; typedef std::vector<_SLICE_INPUT> _slice_input_vector; class HiddenLayerConfigure; class HiddenLayer : public AbstractLayer { public: static HiddenLayer* CreateInstance(np::network::_layer_type type, neuro_u32 uid); virtual ~HiddenLayer(); virtual _binding_model_type GetBindingModelType() const override { return _binding_model_type::network_hidden_layer; } virtual _layer_type GetLayerType() const override; virtual bool AvailableChangeType() const { return true; } bool ChangeLayerType(_layer_type layer_type, const nsas::_LAYER_STRUCTURE_UNION* default_entry, _slice_input_vector* erased_input_vector=NULL); void ChangeEntry(const nsas::_LAYER_STRUCTURE_UNION& entry); void CheckChangedEntry(); virtual void EntryValidation(); tensor::TensorShape MakeOutTensorShape() const; virtual bool SetOutTensorShape(const tensor::TensorShape& ts); virtual bool HasActivation() const; virtual bool AvailableChangeActivation() const; virtual _activation_type GetActivation() const; virtual neuro_u32 AvailableInputCount() const; virtual bool AvailableSetSideInput(const HiddenLayer* input) const; virtual neuro_u32 GetLayerDataInfoVector(_layer_data_info_vector& info_vector) const; bool AttachStoredInfo(const nsas::_HIDDEN_LAYER_ENTRY& entry, const nsas::_input_entry_vector& input_vector, const _uid_layer_map& layer_map); void SetStoredNidSet(const nsas::_LAYER_DATA_NID_SET* nid_set); const nsas::_LAYER_DATA_NID_SET& GetStoredNidSet() const { return m_stored_sub_nid_set; } nsas::_LAYER_STRUCTURE_UNION& GetEntry() { return m_entry; } const nsas::_LAYER_STRUCTURE_UNION& GetEntry() const { return m_entry; } bool AvailableConnectHiddenLayer() const override; bool AvailableConnectOutputLayer() const override; bool IsConnectedOutputLayer() const; const _slice_input_vector& GetInputVector() const { return m_input_vector; } const _SLICE_INPUT* GetMainInput() const { return m_input_vector.size()>0 ? &m_input_vector[0] : NULL; } tensor::TensorShape GetMainInputTs() const { return m_input_vector.size()>0 ? m_input_vector[0].GetTensor() : tensor::TensorShape(); } bool InsertInput(AbstractLayer* layer, AbstractLayer* insert_prev=NULL); bool BatchAppendInputs(_slice_input_vector input_vector); const HiddenLayer* GetSideInput() const { return m_side_input; } bool SetSideInput(HiddenLayer* input); bool DelInput(AbstractLayer* layer); bool ReleaseInput(AbstractLayer* layer); int FindInputIndex(AbstractLayer* layer) const; void CheckOutputTensor() override; void OnRemove() override; bool HasWeight() const; const _LAYER_WEIGHT_INFO* GetWeightInfo(_layer_data_type type) const { if (type == _layer_data_type::weight) return &m_weight_info; else if(type==_layer_data_type::bias) return &m_bias_info; return NULL; } void SetWeightInfo(_layer_data_type type, const _LAYER_WEIGHT_INFO& info) { if (type == _layer_data_type::weight) m_weight_info = info; else if (type == _layer_data_type::bias) m_bias_info = info; } _weight_init_type GetWeightInitType(_layer_data_type type) const; void SetActivation(network::_activation_type type) { if (!AvailableChangeActivation()) return; m_activation_type = type; } void SetVirtualPosition(const nsas::_VIRTUAL_POSITION& vp) { memcpy(&m_virtual_position, &vp, sizeof(nsas::_VIRTUAL_POSITION)); } const nsas::_VIRTUAL_POSITION& GetVirtualPosition() const { return m_virtual_position; } protected: HiddenLayer(neuro_u32 uid); bool SetLayerType(_layer_type type); virtual void OnInsertedInput(AbstractLayer* layer) {} protected: HiddenLayerConfigure* m_entry_configure; nsas::_LAYER_STRUCTURE_UNION m_entry; _activation_type m_activation_type; _LAYER_WEIGHT_INFO m_weight_info; _LAYER_WEIGHT_INFO m_bias_info; _slice_input_vector m_input_vector; HiddenLayer* m_side_input; nsas::_LAYER_DATA_NID_SET m_stored_sub_nid_set; nsas::_VIRTUAL_POSITION m_virtual_position; }; typedef std::vector<HiddenLayer*> _hidden_layer_vector; } }
31.178082
146
0.760764
[ "vector" ]
31b933fc90a55bb4e385f7e3fa8285e130790116
1,098
h
C
polymorphic_memory/pmr_three.h
zcoderz/cppLanguageFeatures
5881b0e87184162197406c427c1e986b4f3d07dd
[ "BSD-3-Clause" ]
null
null
null
polymorphic_memory/pmr_three.h
zcoderz/cppLanguageFeatures
5881b0e87184162197406c427c1e986b4f3d07dd
[ "BSD-3-Clause" ]
null
null
null
polymorphic_memory/pmr_three.h
zcoderz/cppLanguageFeatures
5881b0e87184162197406c427c1e986b4f3d07dd
[ "BSD-3-Clause" ]
null
null
null
// // Created by usman on 3/10/22. // #ifndef CPPLANGUAGEFEATURES_PMR_THREE_H #define CPPLANGUAGEFEATURES_PMR_THREE_H #include <iostream> #include <string> #include <vector> #include <array> #include <cstdlib> // for std::byte #include <memory_resource> #include "track_new.h" class PMRThree { public: static void testMe() { // allocate some memory on the stack: std::array<std::byte, 200000> buf; //use the stack based buffer but when capacity of buffer is reached allocate from heap //reuse the allocated memory on subsequent allocations for (int num : {1000, 2000, 500, 2000, 3000, 50000, 1000}) { std::cout << "-- check with " << num << " elements:\n"; TrackNew::reset(); std::pmr::monotonic_buffer_resource pool{buf.data(), buf.size()}; std::pmr::vector<std::pmr::string> coll{&pool}; for (int i = 0; i < num; ++i) { coll.emplace_back("just a non-SSO string"); } TrackNew::status(); } } }; #endif //CPPLANGUAGEFEATURES_PMR_THREE_H
28.894737
94
0.60929
[ "vector" ]
31ba5c0952b892e45bdf98c4faded5c250f77d67
8,448
h
C
include/NeuralNetwork/NeuralLayer/NeuralLayer.h
alekstheod/tnnlib
90d45f74a37769fcd444e481af6c05a1a1ca400f
[ "BSD-2-Clause" ]
4
2015-03-26T13:42:04.000Z
2022-02-08T10:43:37.000Z
include/NeuralNetwork/NeuralLayer/NeuralLayer.h
alekstheod/tnnlib
90d45f74a37769fcd444e481af6c05a1a1ca400f
[ "BSD-2-Clause" ]
3
2016-02-20T11:55:01.000Z
2018-06-24T09:12:28.000Z
include/NeuralNetwork/NeuralLayer/NeuralLayer.h
alekstheod/tnnlib
90d45f74a37769fcd444e481af6c05a1a1ca400f
[ "BSD-2-Clause" ]
1
2018-06-24T01:51:12.000Z
2018-06-24T01:51:12.000Z
/** * Copyright (c) 2011, Alex Theodoridis * All rights reserved. * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the * following conditions are met: * Redistributions of source code must retain the above * copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE */ #pragma once #include <NeuralNetwork/INeuralLayer.h> #include <NeuralNetwork/Neuron/INeuron.h> #include <NeuralNetwork/Serialization/NeuralLayerMemento.h> #include <boost/iterator/transform_iterator.hpp> #include <boost/bind/placeholders.hpp> #include <boost/bind.hpp> #include <range/v3/all.hpp> #include <algorithm> #include <array> #include <functional> namespace nn { namespace detail { /** * Represent the NeuralLayer in perceptron. */ template< class NeuronType, std::size_t neuronsNumber, std::size_t inputsNumber > struct NeuralLayer { using Neuron = INeuron< typename NeuronType::template adjust< inputsNumber > >; using Var = typename Neuron::Var; using NeuronMemento = typename Neuron::Memento; using Memento = NeuralLayerMemento< NeuronMemento, neuronsNumber >; template< template< class > class NewType > using wrap = NeuralLayer< NewType< NeuronType >, neuronsNumber, inputsNumber >; template< unsigned int inputs > using adjust = NeuralLayer< NeuronType, neuronsNumber, inputs >; template< typename VarType > using use = NeuralLayer< typename NeuronType::template use< VarType >, neuronsNumber, inputsNumber >; static constexpr unsigned int CONST_NEURONS_NUMBER = neuronsNumber; static constexpr unsigned int CONST_INPUTS_NUMBER = inputsNumber; private: /** * A list of the neurons. */ typedef typename std::vector< Neuron > Container; Container m_neurons{neuronsNumber}; public: /** * Constructor will initialize the layer by the given inputs number * and neurons number. */ static_assert(neuronsNumber > 0, "Invalid template argument neuronsNumber == 0"); static_assert(inputsNumber > 0, "Invalid template argument inputsNumber <= 1"); /** * @see {INeuralLayer} */ auto cbegin() const -> decltype(m_neurons.cbegin()) { return m_neurons.cbegin(); } /** * @see {INeuralLayer} */ auto cend() const -> decltype(m_neurons.cend()) { return m_neurons.cend(); } /** * @see {INeuralLayer} */ auto begin() -> decltype(m_neurons.begin()) { return m_neurons.begin(); } /** * @see {INeuralLayer} */ auto end() -> decltype(m_neurons.end()) { return m_neurons.end(); } /** * @see {INeuralLayer} */ auto size() const -> decltype(m_neurons.size()) { return m_neurons.size(); } /** * @see {INeuralLayer} */ const Neuron& operator[](unsigned int id) const { return m_neurons[id]; } /** * @see {INeuralLayer} */ Neuron& operator[](unsigned int id) { return m_neurons[id]; } /** * @see {INeuralLayer} */ void setInput(unsigned int inputId, const Var& value) { std::for_each(m_neurons.begin(), m_neurons.end(), std::bind(&Neuron::setInput, std::placeholders::_1, inputId, value)); } const Var& getBias(unsigned int neuronId) const { return m_neurons[neuronId].getBias(); } /** * @see {INeuralLayer} */ const Memento getMemento() const { using namespace ranges; Memento memento; memento.neurons = m_neurons | views::transform([](const Neuron& n) { return n.getMemento(); }) | ranges::to< decltype(memento.neurons) >; return memento; } /** * @see {INeuralLayer} */ void setMemento(const Memento& memento) { using namespace ranges; m_neurons = memento.neurons | views::transform([](const NeuronMemento& m) { Neuron neuron; neuron->setMemento(m); return neuron; }) | ranges::to< decltype(m_neurons) >; } /** * @see {INeuralLayer} */ Var getOutput(unsigned int outputId) const { return m_neurons[outputId].getOutput(); } /** * @see {INeuralLayer} */ template< typename Layer > void calculateOutputs(Layer& nextLayer) { auto begin = boost::make_transform_iterator(m_neurons.begin(), boost::bind(&Neuron::calcDotProduct, _1)); auto end = boost::make_transform_iterator(m_neurons.end(), boost::bind(&Neuron::calcDotProduct, _1)); for(unsigned int i = 0; i < m_neurons.size(); i++) { nextLayer.setInput(i, m_neurons[i].calculateOutput(begin, end)); } } /** * @see {INeuralLayer} */ void calculateOutputs() { auto begin = boost::make_transform_iterator(m_neurons.begin(), boost::bind(&Neuron::calcDotProduct, ::_1)); auto end = boost::make_transform_iterator(m_neurons.end(), boost::bind(&Neuron::calcDotProduct, ::_1)); using IteratorType = decltype(begin); std::for_each(m_neurons.begin(), m_neurons.end(), std::bind(&Neuron::template calculateOutput< IteratorType >, std::placeholders::_1, begin, end)); } }; } // namespace detail template< template< template< class > class, class, std::size_t > class NeuronType, template< class > class ActivationFunctionType, std::size_t size, std::size_t inputsNumber = 2, typename Var = float > using NeuralLayer = detail::NeuralLayer< NeuronType< ActivationFunctionType, Var, inputsNumber >, size, inputsNumber >; } // namespace nn
36.730435
104
0.522372
[ "vector", "transform" ]
31e2b2b887cce8e6d83e97a1d8dd80a56cab3497
5,536
h
C
gtsam/inference/SymbolicFactorGraph.h
malcolmreynolds/GTSAM
e911b4d39f8a8c8604663bd46f10e7f53c860ae8
[ "BSD-3-Clause" ]
1
2017-07-23T19:34:50.000Z
2017-07-23T19:34:50.000Z
gtsam/inference/SymbolicFactorGraph.h
malcolmreynolds/GTSAM
e911b4d39f8a8c8604663bd46f10e7f53c860ae8
[ "BSD-3-Clause" ]
null
null
null
gtsam/inference/SymbolicFactorGraph.h
malcolmreynolds/GTSAM
e911b4d39f8a8c8604663bd46f10e7f53c860ae8
[ "BSD-3-Clause" ]
null
null
null
/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ /** * @file SymbolicFactorGraph.h * @date Oct 29, 2009 * @author Frank Dellaert */ #pragma once #include <gtsam/global_includes.h> #include <gtsam/inference/FactorGraph.h> #include <gtsam/inference/IndexFactor.h> namespace gtsam { template<class FACTOR> class EliminationTree; } namespace gtsam { template<class CONDITIONAL> class BayesNet; } namespace gtsam { template<class CONDITIONAL, class CLIQUE> class BayesTree; } namespace gtsam { class IndexConditional; } namespace gtsam { typedef EliminationTree<IndexFactor> SymbolicEliminationTree; typedef BayesNet<IndexConditional> SymbolicBayesNet; typedef BayesTree<IndexConditional> SymbolicBayesTree; /** Symbolic IndexFactor Graph * \nosubgrouping */ class SymbolicFactorGraph: public FactorGraph<IndexFactor> { public: /// @name Standard Constructors /// @{ /** Construct empty factor graph */ SymbolicFactorGraph() { } /** Construct from a BayesNet */ GTSAM_EXPORT SymbolicFactorGraph(const SymbolicBayesNet& bayesNet); /** Construct from a BayesTree */ GTSAM_EXPORT SymbolicFactorGraph(const SymbolicBayesTree& bayesTree); /** * Construct from a factor graph of any type */ template<class FACTOR> SymbolicFactorGraph(const FactorGraph<FACTOR>& fg); /** Eliminate the first \c n frontal variables, returning the resulting * conditional and remaining factor graph - this is very inefficient for * eliminating all variables, to do that use EliminationTree or * JunctionTree. Note that this version simply calls * FactorGraph<IndexFactor>::eliminateFrontals with EliminateSymbolic * as the eliminate function argument. */ GTSAM_EXPORT std::pair<sharedConditional, SymbolicFactorGraph> eliminateFrontals(size_t nFrontals) const; /** Factor the factor graph into a conditional and a remaining factor graph. * Given the factor graph \f$ f(X) \f$, and \c variables to factorize out * \f$ V \f$, this function factorizes into \f$ f(X) = f(V;Y)f(Y) \f$, where * \f$ Y := X\V \f$ are the remaining variables. If \f$ f(X) = p(X) \f$ is * a probability density or likelihood, the factorization produces a * conditional probability density and a marginal \f$ p(X) = p(V|Y)p(Y) \f$. * * For efficiency, this function treats the variables to eliminate * \c variables as fully-connected, so produces a dense (fully-connected) * conditional on all of the variables in \c variables, instead of a sparse * BayesNet. If the variables are not fully-connected, it is more efficient * to sequentially factorize multiple times. * Note that this version simply calls * FactorGraph<GaussianFactor>::eliminate with EliminateSymbolic as the eliminate * function argument. */ GTSAM_EXPORT std::pair<sharedConditional, SymbolicFactorGraph> eliminate(const std::vector<Index>& variables) const; /** Eliminate a single variable, by calling SymbolicFactorGraph::eliminate. */ GTSAM_EXPORT std::pair<sharedConditional, SymbolicFactorGraph> eliminateOne(Index variable) const; /// @} /// @name Standard Interface /// @{ /** * Return the set of variables involved in the factors (computes a set * union). */ GTSAM_EXPORT FastSet<Index> keys() const; /// @} /// @name Advanced Interface /// @{ /** Push back unary factor */ GTSAM_EXPORT void push_factor(Index key); /** Push back binary factor */ GTSAM_EXPORT void push_factor(Index key1, Index key2); /** Push back ternary factor */ GTSAM_EXPORT void push_factor(Index key1, Index key2, Index key3); /** Push back 4-way factor */ GTSAM_EXPORT void push_factor(Index key1, Index key2, Index key3, Index key4); /** Permute the variables in the factors */ GTSAM_EXPORT void permuteWithInverse(const Permutation& inversePermutation); /** Apply a reduction, which is a remapping of variable indices. */ GTSAM_EXPORT void reduceWithInverse(const internal::Reduction& inverseReduction); }; /** Create a combined joint factor (new style for EliminationTree). */ GTSAM_EXPORT IndexFactor::shared_ptr CombineSymbolic(const FactorGraph<IndexFactor>& factors, const FastMap<Index, std::vector<Index> >& variableSlots); /** * CombineAndEliminate provides symbolic elimination. * Combine and eliminate can also be called separately, but for this and * derived classes calling them separately generally does extra work. */ GTSAM_EXPORT std::pair<boost::shared_ptr<IndexConditional>, boost::shared_ptr<IndexFactor> > EliminateSymbolic(const FactorGraph<IndexFactor>&, size_t nrFrontals = 1); /// @} /** Template function implementation */ template<class FACTOR> SymbolicFactorGraph::SymbolicFactorGraph(const FactorGraph<FACTOR>& fg) { for (size_t i = 0; i < fg.size(); i++) { if (fg[i]) { IndexFactor::shared_ptr factor(new IndexFactor(*fg[i])); push_back(factor); } else push_back(IndexFactor::shared_ptr()); } } } // namespace gtsam
36.421053
120
0.683345
[ "vector" ]
31ecb12e79f1b41f019605de500371cc2466b97a
1,965
h
C
wrappers/8.1.1/vtkImageToImageStencilWrap.h
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
6
2016-02-03T12:48:36.000Z
2020-09-16T15:07:51.000Z
wrappers/8.1.1/vtkImageToImageStencilWrap.h
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
4
2016-02-13T01:30:43.000Z
2020-03-30T16:59:32.000Z
wrappers/8.1.1/vtkImageToImageStencilWrap.h
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
null
null
null
/* this file has been autogenerated by vtkNodeJsWrap */ /* editing this might proof futile */ #ifndef NATIVE_EXTENSION_VTK_VTKIMAGETOIMAGESTENCILWRAP_H #define NATIVE_EXTENSION_VTK_VTKIMAGETOIMAGESTENCILWRAP_H #include <nan.h> #include <vtkSmartPointer.h> #include <vtkImageToImageStencil.h> #include "vtkImageStencilAlgorithmWrap.h" #include "../../plus/plus.h" class VtkImageToImageStencilWrap : public VtkImageStencilAlgorithmWrap { public: using Nan::ObjectWrap::Wrap; static void Init(v8::Local<v8::Object> exports); static void InitPtpl(); static void ConstructorGetter( v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info); VtkImageToImageStencilWrap(vtkSmartPointer<vtkImageToImageStencil>); VtkImageToImageStencilWrap(); ~VtkImageToImageStencilWrap( ); static Nan::Persistent<v8::FunctionTemplate> ptpl; private: static void New(const Nan::FunctionCallbackInfo<v8::Value>& info); static void GetInput(const Nan::FunctionCallbackInfo<v8::Value>& info); static void GetLowerThreshold(const Nan::FunctionCallbackInfo<v8::Value>& info); static void GetUpperThreshold(const Nan::FunctionCallbackInfo<v8::Value>& info); static void NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info); static void SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info); static void SetInputData(const Nan::FunctionCallbackInfo<v8::Value>& info); static void SetLowerThreshold(const Nan::FunctionCallbackInfo<v8::Value>& info); static void SetUpperThreshold(const Nan::FunctionCallbackInfo<v8::Value>& info); static void ThresholdBetween(const Nan::FunctionCallbackInfo<v8::Value>& info); static void ThresholdByLower(const Nan::FunctionCallbackInfo<v8::Value>& info); static void ThresholdByUpper(const Nan::FunctionCallbackInfo<v8::Value>& info); #ifdef VTK_NODE_PLUS_VTKIMAGETOIMAGESTENCILWRAP_CLASSDEF VTK_NODE_PLUS_VTKIMAGETOIMAGESTENCILWRAP_CLASSDEF #endif }; #endif
38.529412
82
0.792875
[ "object" ]
31eeebfa687d6e77b358c8a4289eb939e72009e0
20,072
c
C
src/types.c
veera-sivarajan/funlisp
d2f80725a8305cf27ff96165b93e084edd644391
[ "BSD-3-Clause" ]
11
2018-06-01T08:39:45.000Z
2021-09-24T07:11:29.000Z
src/types.c
veera-sivarajan/funlisp
d2f80725a8305cf27ff96165b93e084edd644391
[ "BSD-3-Clause" ]
36
2018-05-27T16:59:03.000Z
2021-05-18T01:30:35.000Z
src/types.c
veera-sivarajan/funlisp
d2f80725a8305cf27ff96165b93e084edd644391
[ "BSD-3-Clause" ]
2
2020-12-06T03:25:22.000Z
2021-05-17T14:14:28.000Z
/* * types.c: language types for funlisp * * Stephen Brennan <stephen@brennan.io> */ #include <assert.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "funlisp_internal.h" #include "iter.h" #include "hashtable.h" #define TYPE_HEADER \ &type_type_obj, \ NULL, \ 'w' /* * Some generic functions for types */ static lisp_value *eval_error(lisp_runtime *rt, lisp_scope *s, lisp_value *v) { (void)s; (void)v; return lisp_error(rt, LE_NOEVAL, "cannot evaluate this object"); } static lisp_value *eval_same(lisp_runtime *rt, lisp_scope *s, lisp_value *v) { (void)rt; (void)s; return v; } static lisp_value *call_error(lisp_runtime *rt, lisp_scope *s, lisp_value *c, lisp_list *v) { (void)s; (void)c; (void)v; return lisp_error(rt, LE_NOCALL, "not callable!"); } static void simple_free(lisp_runtime *rt, void *v) { (void)rt; free(v); } static bool has_next_index_lt_state(struct iterator *iter) { return iter->index < iter->state_int; } /* * type */ static void type_print(FILE *f, lisp_value *v); static lisp_value *type_new(lisp_runtime *rt); static int type_compare(lisp_value *self, lisp_value *other); static lisp_type type_type_obj = { TYPE_HEADER, /* name */ "type", /* print */ type_print, /* new */ type_new, /* free */ simple_free, /* expand */ iterator_empty, /* eval */ eval_error, /* call */ call_error, /* compare */ type_compare, }; lisp_type *type_type = &type_type_obj; static void type_print(FILE *f, lisp_value *v) { lisp_type *value = (lisp_type*) v; fprintf(f, "%s", value->name); } static lisp_value *type_new(lisp_runtime *rt) { lisp_type *type; (void) rt; /* unused */ type = malloc(sizeof(lisp_type)); return (lisp_value*)type; } static int type_compare(lisp_value *self, lisp_value *other) { if (self->type != other->type || self->type != type_type) return 0; /* can compare by pointer since there should only ever be one of each * type */ return self == other; } /* * scope */ static void scope_print(FILE *f, lisp_value*v); static lisp_value *scope_new(lisp_runtime *rt); static void scope_free(lisp_runtime *rt, void *v); static struct iterator scope_expand(lisp_value *); static int scope_compare(lisp_value *self, lisp_value *other); static lisp_type type_scope_obj = { TYPE_HEADER, /* name */ "scope", /* print */ scope_print, /* new */ scope_new, /* free */ scope_free, /* expand */ scope_expand, /* eval */ eval_error, /* call */ call_error, /* compare */ scope_compare, }; lisp_type *type_scope = &type_scope_obj; unsigned int lisp_text_hash(void *t) { struct lisp_text **text = t; return ht_string_hash(&(*text)->s); } int lisp_text_compare(void *left, void *right) { lisp_symbol **sym1 = left; lisp_symbol **sym2 = right; return strcmp((*sym1)->s, (*sym2)->s); } static lisp_value *scope_new(lisp_runtime *rt) { lisp_scope *scope; (void) rt; /* unused */ scope = malloc(sizeof(lisp_scope)); scope->up = NULL; ht_init(&scope->scope, lisp_text_hash, lisp_text_compare, sizeof(void*), sizeof(void*)); return (lisp_value*)scope; } static void scope_free(lisp_runtime *rt, void *v) { lisp_scope *scope; (void) rt; /* unused */ scope = (lisp_scope*) v; ht_destroy(&scope->scope); free(scope); } static void scope_print(FILE *f, lisp_value *v) { lisp_scope *scope = (lisp_scope*) v; struct iterator it = ht_iter_keys_ptr(&scope->scope); fprintf(f, "(scope:"); while (it.has_next(&it)) { lisp_value *key = it.next(&it); lisp_value *value = ht_get_ptr(&scope->scope, key); fprintf(f, " "); lisp_print(f, key); fprintf(f, ": "); lisp_print(f, value); } fprintf(f, ")"); } static struct iterator scope_expand(lisp_value *v) { lisp_scope *scope = (lisp_scope *) v; if (scope->up) { return iterator_concat3( iterator_single_value(scope->up), ht_iter_keys_ptr(&scope->scope), ht_iter_values_ptr(&scope->scope) ); } else { return iterator_concat2( ht_iter_keys_ptr(&scope->scope), ht_iter_values_ptr(&scope->scope) ); } } static int scope_compare(lisp_value *self, lisp_value *other) { lisp_scope *lhs, *rhs; lisp_symbol *key; lisp_value *value, *rhs_value; struct iterator it; /* easy quick checks - same type? same pointer value? */ if (self == other) return 1; /* short circuit because comparison is hard */ if (self->type != other->type || self->type != type_scope) return 0; lhs = (lisp_scope*) self; rhs = (lisp_scope*) other; /* now actual equality test - first check parent scope equality */ if (lhs->up && rhs->up) { /* both parents non-NULL */ if (!scope_compare((lisp_value*)lhs->up, (lisp_value*)rhs->up)) return 0; /* parents aren't equal! */ } else if (lhs->up || rhs->up) { /* at least one parent non-NULL, but not both! */ return 0; } /* now test equality of scope contents - are they same length? */ if (ht_length(&lhs->scope) != ht_length(&lhs->scope)) return 0; /* now actually compare keys and values, yawn */ it = ht_iter_keys_ptr(&lhs->scope); while (it.has_next(&it)) { key = (lisp_symbol*) it.next(&it); rhs_value = (lisp_value*) ht_get_ptr(&rhs->scope, key); if (!rhs_value) { /* key not in other scope */ it.close(&it); return 0; } value = (lisp_value*) ht_get_ptr(&lhs->scope, key); if (!lisp_compare(value, rhs_value)) { it.close(&it); return 0; } } /* fiine, they're equal, but somehow not the same pointer */ it.close(&it); return 1; } /* * list */ static void list_print(FILE *f, lisp_value *v); static lisp_value *list_new(lisp_runtime *rt); static lisp_value *list_eval(lisp_runtime*, lisp_scope*, lisp_value*); static struct iterator list_expand(lisp_value*); static int list_compare(lisp_value *self, lisp_value *other); static lisp_type type_list_obj = { TYPE_HEADER, /* name */ "list", /* print */ list_print, /* new */ list_new, /* free */ simple_free, /* expand */ list_expand, /* eval */ list_eval, /* call */ call_error, /* compare */ list_compare, }; lisp_type *type_list = &type_list_obj; static lisp_value *list_eval(lisp_runtime *rt, lisp_scope *scope, lisp_value *v) { lisp_value *callable; lisp_list *list = (lisp_list*) v; if (lisp_nil_p(v)) { return lisp_error(rt, LE_NOCALL, "Cannot call empty list"); } if (list->right->type != type_list) { return lisp_error(rt, LE_SYNTAX, "unexpected cons cell"); } callable = lisp_eval(rt, scope, list->left); lisp_error_check(callable); return lisp_call(rt, scope, callable, (lisp_list*) list->right); } static void list_print_internal(FILE *f, lisp_list *list) { if (lisp_nil_p((lisp_value*)list)) { return; } lisp_print(f, list->left); if (list->right->type != type_list) { fprintf(f, " . "); lisp_print(f, list->right); return; } else if (!lisp_nil_p((lisp_value*)list)) { fprintf(f, " "); list_print_internal(f, (lisp_list*)list->right); } } static void list_print(FILE *f, lisp_value *v) { fprintf(f, "("); list_print_internal(f, (lisp_list*)v); fprintf(f, ")"); } static lisp_value *list_new(lisp_runtime *rt) { lisp_list *list; (void) rt; /* unused */ list = malloc(sizeof(lisp_list)); list->left = NULL; list->right = NULL; return (lisp_value*) list; } int lisp_nil_p(lisp_value *l) { return (l->type == type_list) && (((lisp_list*)l)->right == NULL) && (((lisp_list*)l)->left == NULL); } static void *list_expand_next(struct iterator *it) { lisp_list *l = (lisp_list*) it->ds; it->index++; switch (it->index) { case 1: return l->left; case 2: return l->right; default: return NULL; } } static bool list_has_next(struct iterator *it) { lisp_value *l = (lisp_value*)it->ds; if (lisp_nil_p(l)) { return false; } else { return it->index < it->state_int; } } static struct iterator list_expand(lisp_value *v) { struct iterator it = {0}; it.ds = v; it.state_int = 2; it.index = 0; it.next = list_expand_next; it.has_next = list_has_next; it.close = iterator_close_noop; return it; } static int list_compare(lisp_value *self, lisp_value *other) { lisp_list *lhs, *rhs; if (self == other) return 1; if (self->type != other->type || self->type != type_list) return 0; lhs = (lisp_list*) self; rhs = (lisp_list*) other; if (lisp_nil_p(self) && lisp_nil_p(other)) return 1; /* both nil */ if (lisp_nil_p(self) || lisp_nil_p(other)) return 0; /* one nil but not both */ return (lisp_compare(lhs->left, rhs->left) && lisp_compare(lhs->right, rhs->right)); } /* * symbol */ static void text_print(FILE *f, lisp_value *v); static lisp_value *text_new(lisp_runtime *rt); static lisp_value *symbol_eval(lisp_runtime*, lisp_scope*, lisp_value*); static void text_free(lisp_runtime *rt, void *v); static int text_compare(lisp_value *self, lisp_value *other); static lisp_type type_symbol_obj = { TYPE_HEADER, /* name */ "symbol", /* print */ text_print, /* new */ text_new, /* free */ text_free, /* expand */ iterator_empty, /* eval */ symbol_eval, /* call */ call_error, /* commpare */ text_compare, }; lisp_type *type_symbol = &type_symbol_obj; static void text_print(FILE *f, lisp_value *v) { struct lisp_text *text = (struct lisp_text*) v; fprintf(f, "%s", text->s); } static lisp_value *text_new(lisp_runtime *rt) { struct lisp_text *text; (void) rt; /* unused */ text = malloc(sizeof(struct lisp_text)); text->s = NULL; text->can_free = 1; return (lisp_value*)text; } static void text_free(lisp_runtime *rt, void *v) { struct lisp_text *text = (struct lisp_text*) v; /* if this is cached, we must un-cache it! */ if (text->type == type_string && rt->strcache) lisp_textcache_remove(rt->strcache, text); else if (text->type == type_symbol && rt->symcache) lisp_textcache_remove(rt->symcache, text); /* respect ownership of text */ if (text->can_free) free(text->s); free(text); } static lisp_value *symbol_eval(lisp_runtime *rt, lisp_scope *scope, lisp_value *value) { lisp_symbol *symbol; (void)rt; symbol = (lisp_symbol*) value; return lisp_scope_lookup(rt, scope, symbol); } static int text_compare(lisp_value *self, lisp_value *other) { struct lisp_text *lhs, *rhs; if (self == other) return 1; if (self->type != other->type) return 0; lhs = (struct lisp_text*) self; rhs = (struct lisp_text*)other; return strcmp(lhs->s, rhs->s) == 0; } /* * integer */ static void integer_print(FILE *f, lisp_value *v); static lisp_value *integer_new(lisp_runtime *rt); static int integer_compare(lisp_value *self, lisp_value *other); static lisp_type type_integer_obj = { TYPE_HEADER, /* name */ "integer", /* print */ integer_print, /* new */ integer_new, /* free */ simple_free, /* expand */ iterator_empty, /* eval */ eval_same, /* call */ call_error, /* compare */ integer_compare, }; lisp_type *type_integer = &type_integer_obj; static void integer_print(FILE *f, lisp_value *v) { lisp_integer *integer = (lisp_integer*) v; fprintf(f, "%d", integer->x); } static lisp_value *integer_new(lisp_runtime *rt) { lisp_integer *integer; (void) rt; /* unused */ integer = malloc(sizeof(lisp_integer)); integer->x = 0; return (lisp_value*)integer; } static int integer_compare(lisp_value *self, lisp_value *other) { lisp_integer *lhs, *rhs; if (self == other) return 1; if (self->type != other->type || self->type != type_integer) return 0; lhs = (lisp_integer*) self; rhs = (lisp_integer*) other; return lhs->x == rhs->x; } /* string */ static lisp_type type_string_obj = { TYPE_HEADER, /* name */ "string", /* print */ text_print, /* new */ text_new, /* free */ text_free, /* expand */ iterator_empty, /* eval */ eval_same, /* call */ call_error, /* compare */ text_compare, }; lisp_type *type_string = &type_string_obj; /* * builtin */ static void builtin_print(FILE *f, lisp_value *v); static lisp_value *builtin_new(lisp_runtime *rt); static lisp_value *builtin_call(lisp_runtime *rt, lisp_scope *scope, lisp_value *c, lisp_list *arguments); static int builtin_compare(lisp_value *self, lisp_value *other); static lisp_type type_builtin_obj = { TYPE_HEADER, /* name */ "builtin", /* print */ builtin_print, /* new */ builtin_new, /* free */ simple_free, /* expand */ iterator_empty, /* eval */ eval_error, /* call */ builtin_call, /* compare */ builtin_compare, }; lisp_type *type_builtin = &type_builtin_obj; static void builtin_print(FILE *f, lisp_value *v) { lisp_builtin *builtin = (lisp_builtin*) v; fprintf(f, "<builtin function %s>", builtin->name); } static lisp_value *builtin_new(lisp_runtime *rt) { lisp_builtin *builtin; (void) rt; /* unused */ builtin = malloc(sizeof(lisp_builtin)); builtin->call = NULL; builtin->name = NULL; builtin->evald = 0; return (lisp_value*) builtin; } static lisp_value *builtin_call(lisp_runtime *rt, lisp_scope *scope, lisp_value *c, lisp_list *arguments) { lisp_builtin *builtin = (lisp_builtin*) c; if (builtin->evald) { arguments = lisp_eval_list(rt, scope, arguments); lisp_error_check(arguments); } else if (lisp_is_bad_list(arguments)) { /* lisp_eval_list() does this check for us, don't need to * duplicate */ return lisp_error(rt, LE_SYNTAX, "unexpected cons cell"); } return builtin->call(rt, scope, arguments, builtin->user); } static int builtin_compare(lisp_value *self, lisp_value *other) { lisp_builtin *lhs, *rhs; if (self == other) return 1; if (self->type != other->type || self->type != type_builtin) return 0; lhs = (lisp_builtin*) self; rhs = (lisp_builtin*) other; return ( lhs->call == rhs->call && lhs->user == rhs->user && lhs->evald == rhs->evald && strcmp(lhs->name, rhs->name) == 0 ); } /* * lambda */ static void lambda_print(FILE *f, lisp_value *v); static lisp_value *lambda_new(lisp_runtime *rt); static lisp_value *lambda_call(lisp_runtime *rt, lisp_scope *scope, lisp_value *c, lisp_list *arguments); static struct iterator lambda_expand(lisp_value *v); static int lambda_compare(lisp_value *self, lisp_value *other); static lisp_type type_lambda_obj = { TYPE_HEADER, /* name */ "lambda", /* print */ lambda_print, /* new */ lambda_new, /* free */ simple_free, /* expand */ lambda_expand, /* eval */ eval_error, /* call */ lambda_call, /* compare */ lambda_compare, }; lisp_type *type_lambda = &type_lambda_obj; static void lambda_print(FILE *f, lisp_value *v) { lisp_lambda *l = (lisp_lambda *) v; char *name = l->first_binding ? l->first_binding->s : "(anonymous)"; if (l->lambda_type == TP_LAMBDA) { fprintf(f, "<lambda %s>", name); } else { fprintf(f, "<macro %s>", name); } } static lisp_value *lambda_new(lisp_runtime *rt) { lisp_lambda *lambda; (void) rt; /* unused */ lambda = malloc(sizeof(lisp_lambda)); lambda->args = NULL; lambda->code = NULL; lambda->closure = NULL; lambda->first_binding = NULL; lambda->lambda_type = TP_LAMBDA; return (lisp_value*) lambda; } static lisp_value *lambda_call(lisp_runtime *rt, lisp_scope *scope, lisp_value *c, lisp_list *arguments) { lisp_lambda *lambda = (lisp_lambda*) c; lisp_list *argvalues, *it1, *it2; lisp_scope *inner; lisp_value *result; if (lambda->lambda_type == TP_MACRO) { /* macros receive their arguments un-evaluated */ argvalues = arguments; } else { /* lambdas evaluate their arguments */ argvalues = lisp_eval_list(rt, scope, arguments); lisp_error_check(argvalues); } if (lisp_is_bad_list(argvalues)) { return lisp_error(rt, LE_SYNTAX, "unexpected cons cell"); } inner = (lisp_scope*)lisp_new(rt, type_scope); inner->up = lambda->closure; it1 = lambda->args; it2 = argvalues; while (!lisp_nil_p((lisp_value*)it1) && !lisp_nil_p((lisp_value*)it2)) { lisp_scope_bind(inner, (lisp_symbol*) it1->left, it2->left); it1 = (lisp_list*) it1->right; it2 = (lisp_list*) it2->right; } if (!lisp_nil_p((lisp_value*)it1)) { return lisp_error(rt, LE_2FEW, "not enough arguments to lambda call"); } if (!lisp_nil_p((lisp_value*)it2)) { return lisp_error(rt, LE_2MANY, "too many arguments to lambda call"); } result = lisp_progn(rt, inner, lambda->code); lisp_error_check(result); if (lambda->lambda_type == TP_MACRO) { /* for macros, we've now evaluated the macro to get code, now * evaluate the code */ result = lisp_eval(rt, scope, result); } return result; } static void *lambda_expand_next(struct iterator *it) { lisp_lambda *l = (lisp_lambda*)it->ds; it->index++; switch (it->index) { case 1: return l->args; case 2: return l->code; case 3: return l->closure; case 4: return l->first_binding; default: return NULL; } } static struct iterator lambda_expand(lisp_value *v) { lisp_lambda *l = (lisp_lambda *) v; struct iterator it = {0}; it.ds = v; it.state_int = l->first_binding ? 4 : 3; it.index = 0; it.next = lambda_expand_next; it.has_next = has_next_index_lt_state; it.close = iterator_close_noop; return it; } static int lambda_compare(lisp_value *self, lisp_value *other) { lisp_lambda *lhs, *rhs; if (self == other) return 1; if (self->type != other->type || self->type != type_lambda) return 0; lhs = (lisp_lambda*) self; rhs = (lisp_lambda*) other; return ( lhs->lambda_type == rhs->lambda_type && lisp_compare((lisp_value*)lhs->args, (lisp_value*)rhs->args) && lisp_compare((lisp_value*)lhs->code, (lisp_value*)rhs->code) && lisp_compare((lisp_value*)lhs->closure, (lisp_value*)rhs->closure) /* explicitly DO NOT compare first binding */ ); } /* * some shortcuts for accessing these type methods on lisp values */ void lisp_print(FILE *f, lisp_value *value) { value->type->print(f, value); } void lisp_free(lisp_runtime *rt, lisp_value *value) { value->type->free(rt, value); } lisp_value *lisp_eval(lisp_runtime *rt, lisp_scope *scope, lisp_value *value) { return value->type->eval(rt, scope, value); } lisp_value *lisp_call(lisp_runtime *rt, lisp_scope *scope, lisp_value *callable, lisp_list *args) { lisp_value *rv; /* create new stack frame */ rt->stack = lisp_list_new(rt, callable, (lisp_value *) rt->stack); rt->stack_depth++; /* make function call */ rv = callable->type->call(rt, scope, callable, args); /* get rid of stack frame */ rt->stack = (lisp_list*) rt->stack->right; rt->stack_depth--; return rv; } lisp_value *lisp_new(lisp_runtime *rt, lisp_type *typ) { lisp_value *new = typ->new(rt); new->type = typ; new->next = NULL; new->mark = GC_NOMARK; if (rt->head == NULL) { rt->head = new; rt->tail = new; } else { rt->tail->next = new; rt->tail = new; } return new; } int lisp_compare(lisp_value *self, lisp_value *other) { return self->type->compare(self, other); } /* * module */ static void module_print(FILE *f, lisp_value*v); static lisp_value *module_new(lisp_runtime *rt); static struct iterator module_expand(lisp_value *); static int module_compare(lisp_value *self, lisp_value *other); static lisp_type type_module_obj = { TYPE_HEADER, /* name */ "module", /* print */ module_print, /* new */ module_new, /* free */ simple_free, /* expand */ module_expand, /* eval */ eval_error, /* call */ call_error, /* compare */ module_compare, }; lisp_type *type_module = &type_module_obj; static lisp_value *module_new(lisp_runtime *rt) { lisp_module *module; (void) rt; /* unused */ module = malloc(sizeof(lisp_module)); module->contents = NULL; module->name = NULL; module->name = NULL; return (lisp_value*)module; } static void module_print(FILE *f, lisp_value *v) { lisp_module *module = (lisp_module*) v; fprintf(f, "<module '%s' from '%s' at 0x%p>", module->name->s, module->file->s, (void*)module); } static struct iterator module_expand(lisp_value *v) { lisp_module *module = (lisp_module *) v; return iterator_from_args(3, module->name, module->file, module->contents ); } static int module_compare(lisp_value *self, lisp_value *other) { /* Compare by value for simplicity. */ return self == other; }
23.476023
89
0.673625
[ "object" ]
31f0bfe9f7b6bc6d2e90aec23bddb8ea23462141
719
h
C
src/virusdetector.h
RabbitBio/RabbitV
2ea5155c1178b444ebc325c91c72e3e8ee928d89
[ "MIT" ]
3
2022-03-26T02:21:14.000Z
2022-03-29T04:30:33.000Z
src/virusdetector.h
RabbitBio/RabbitV
2ea5155c1178b444ebc325c91c72e3e8ee928d89
[ "MIT" ]
null
null
null
src/virusdetector.h
RabbitBio/RabbitV
2ea5155c1178b444ebc325c91c72e3e8ee928d89
[ "MIT" ]
null
null
null
#ifndef VIRUSDETECTOR_H #define VIRUSDETECTOR_H #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> #include "options.h" #include "read.h" #include "kmer.h" #include "genomes.h" #include "kmercollection.h" using namespace std; class VirusDetector{ public: VirusDetector(Options* opt); ~VirusDetector(); bool detect(Read* r); bool scan(string& seq); void report(); Kmer* getKmer() {return mKmer;} Genomes* getGenomes() {return mGenomes;} KmerCollection* getKmerCollection() {return mKmerCollection;} private: Options* mOptions; Genomes* mGenomes; Kmer* mKmer; KmerCollection* mKmerCollection; uint64 mHits; uint64 keymask; }; #endif
17.975
65
0.694019
[ "vector" ]
31f7b388cdebe070903498033049e3d2c5621a97
2,276
h
C
Project1/Src/Skull.h
yokamonian/Skull_Random_Defence
0b9918887d3676b8b56132a6e542494dfcb052bb
[ "Unlicense" ]
null
null
null
Project1/Src/Skull.h
yokamonian/Skull_Random_Defence
0b9918887d3676b8b56132a6e542494dfcb052bb
[ "Unlicense" ]
null
null
null
Project1/Src/Skull.h
yokamonian/Skull_Random_Defence
0b9918887d3676b8b56132a6e542494dfcb052bb
[ "Unlicense" ]
null
null
null
#pragma once #include "GameObject.h" #include "Storage.h" /// <summary> /// Skull : 게임 내 등장하는 아군 유닛(타워) 클래스. /// </summary> // 스컬 상태 정보 enum class SKULLMode { IDLE, ATTACK, SKILL }; class AstarTile; class Skull : public GameObject { private: int damage; // 데미지 int abilityPower; // 공속 int attackSpeed; // 스킬 데미지 int skillCount; // 스킬에 필요한 타격수 int growthDmg; // 성장 데미지(킬) int growthAp; // 성장 스킬 데미지(킬) int upgradeDmg; // 성급업 데미지 int upgradeAp; // 성급업 공속 int upgradeAs; // 성급업 스킬에 필요한 타격수 int upgradeSc; // 성급업 스킬데미지 int idleFrame; // 기본 동작 애니메이션 프레임 int attackFrame; // 공격 동작 애니메이션 프레임 int skillFrame; // 스킬 동작 애니메이션 프레임 Image* img; // 스컬 이미지 이름 SkullData* info; // 스컬 정보 AstarTile* nowTile; // 스컬 현재 위치 ISOTILE* nowSkullTile; // 스컬이 존재하는 타일 위치 bool isSelected = false; // (스컬이)선택되었는지 Storage* storage; // 스컬 저장공간 SKULLMode skullMode; // 스컬의 동작상태 POINT prevPos; // 스컬의 이전 위치 POINT fieldPos; // 필드 위치 public: virtual HRESULT Init(); // 유닛 정보 세팅 void SetSkull(TILE_NUM_INFO buildPos, string* skullName); void SetSkull(POINT pos, string* skullName); // 유닛 위치 세팅 및 이동 void SetPrevPos(POINT _prevPos) { prevPos = _prevPos; } void SetPos(POINT _pos) { pos = _pos; } void SetPos(int posX, int posY) { pos.x = posX; pos.y = posY; } void SetSelected(bool _isSelected) { isSelected = _isSelected; } void SetFieldPos(POINT _pos) { fieldPos = _pos; } // 유닛저장소 세팅 void SetStorage(Storage* _storage) { if (_storage == nullptr && storage != nullptr) { if (storage->GetSkullTile() == nullptr) storage->SetIsEmpty(true); } storage = _storage; storage->SetSkullTile(this); storage->SetIsEmpty(false); } Storage* GetStorage() { return storage; } POINT GetFieldPos() { return fieldPos; } POINT GetPrevPos() { return prevPos; } void SetNowTile(AstarTile* astar) { nowTile = astar; } AstarTile* GetSkullPos() { return nowTile; } void SetNowSkullTile(ISOTILE* _skull) { nowSkullTile = _skull; } ISOTILE* GetSkullTile() { return nowSkullTile; } bool GetIsSelected() { return isSelected; } virtual void Release(); virtual void Update(); virtual void Render(HDC hdc); };
28.098765
65
0.637522
[ "render" ]
31f7e6f25706d4ac0a49880dc6e1cb652cc929c2
1,441
c
C
lib/wizards/tiergon/dungeon/monsters/qspectre.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/tiergon/dungeon/monsters/qspectre.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
lib/wizards/tiergon/dungeon/monsters/qspectre.c
vlehtola/questmud
8bc3099b5ad00a9e0261faeb6637c76b521b6dbe
[ "MIT" ]
null
null
null
inherit "obj/monster"; reset(arg) { string chat_str; ::reset(arg); if(arg) { return; } set_level(21); set_name("Spectral miner"); set_short("A spectral miner is moving furiously around the room"); set_long("This is the tormented spectral apparition of a dead miner. He seems intent on achieving some goal.\n"); set_exp(58000); set_alias("miner","specter","spectre"); set_al(0); set_gender(1); set_race("human"); set_undead(1); if (!chat_str) { chat_str = allocate(2); chat_str[0] = "The spectre points at the rubble, makes a hacking movement with his transparent hands.\n"; chat_str[1] = "The spectral miner holds his hand out expectantly at you.\n"; } load_chat(20, chat_str); } catch_tell(str) { string tmp1,tmp2; object ob; ::catch_tell(str); if (sscanf(str, "%s gives %s to you.", tmp1, tmp2) == 2) { ob = present("pick", this_object()); if (ob && this_player()->query_name() == tmp1 && !ob->query_no_save()) { destruct(ob); write("The spectre furiously attacks the pile of rubble with the pick you gave him\n"); write("In a few moments, the rubble is gone, and the southern tunnel is accessible again. \n"); call_other(environment(this_object()), "add_exit", "south", "/wizards/tiergon/dungeon/a6"); call_out("delay_dest",1); } } } delay_dest() { destruct(this_object()); }
27.188679
117
0.6322
[ "object" ]
ee06d7e56f3c4ae291b78c4f70c31e7d35a9bfc8
19,293
h
C
Arduino/MavLinkView/mavlink/ardupilotmega/mavlink_msg_obstacle_distance_3d.h
socke7/MAVLinkView
76ebbb5c4460026ce20ab5fcd9b2e7690b3e117c
[ "MIT" ]
null
null
null
Arduino/MavLinkView/mavlink/ardupilotmega/mavlink_msg_obstacle_distance_3d.h
socke7/MAVLinkView
76ebbb5c4460026ce20ab5fcd9b2e7690b3e117c
[ "MIT" ]
null
null
null
Arduino/MavLinkView/mavlink/ardupilotmega/mavlink_msg_obstacle_distance_3d.h
socke7/MAVLinkView
76ebbb5c4460026ce20ab5fcd9b2e7690b3e117c
[ "MIT" ]
1
2021-09-03T21:33:52.000Z
2021-09-03T21:33:52.000Z
#pragma once // MESSAGE OBSTACLE_DISTANCE_3D PACKING #define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D 11037 typedef struct __mavlink_obstacle_distance_3d_t { uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/ float x; /*< [m] X position of the obstacle.*/ float y; /*< [m] Y position of the obstacle.*/ float z; /*< [m] Z position of the obstacle.*/ float min_distance; /*< [m] Minimum distance the sensor can measure.*/ float max_distance; /*< [m] Maximum distance the sensor can measure.*/ uint16_t obstacle_id; /*< Unique ID given to each obstacle so that its movement can be tracked. Use UINT16_MAX if object ID is unknown or cannot be determined.*/ uint8_t sensor_type; /*< Class id of the distance sensor type.*/ uint8_t frame; /*< Coordinate frame of reference.*/ } mavlink_obstacle_distance_3d_t; #define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN 28 #define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN 28 #define MAVLINK_MSG_ID_11037_LEN 28 #define MAVLINK_MSG_ID_11037_MIN_LEN 28 #define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC 130 #define MAVLINK_MSG_ID_11037_CRC 130 #if MAVLINK_COMMAND_24BIT #define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE_3D { \ 11037, \ "OBSTACLE_DISTANCE_3D", \ 9, \ { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_obstacle_distance_3d_t, time_boot_ms) }, \ { "sensor_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_obstacle_distance_3d_t, sensor_type) }, \ { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 27, offsetof(mavlink_obstacle_distance_3d_t, frame) }, \ { "obstacle_id", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_obstacle_distance_3d_t, obstacle_id) }, \ { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_obstacle_distance_3d_t, x) }, \ { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_obstacle_distance_3d_t, y) }, \ { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_obstacle_distance_3d_t, z) }, \ { "min_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_obstacle_distance_3d_t, min_distance) }, \ { "max_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_obstacle_distance_3d_t, max_distance) }, \ } \ } #else #define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE_3D { \ "OBSTACLE_DISTANCE_3D", \ 9, \ { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_obstacle_distance_3d_t, time_boot_ms) }, \ { "sensor_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_obstacle_distance_3d_t, sensor_type) }, \ { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 27, offsetof(mavlink_obstacle_distance_3d_t, frame) }, \ { "obstacle_id", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_obstacle_distance_3d_t, obstacle_id) }, \ { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_obstacle_distance_3d_t, x) }, \ { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_obstacle_distance_3d_t, y) }, \ { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_obstacle_distance_3d_t, z) }, \ { "min_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_obstacle_distance_3d_t, min_distance) }, \ { "max_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_obstacle_distance_3d_t, max_distance) }, \ } \ } #endif /** * @brief Pack a obstacle_distance_3d message * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * * @param time_boot_ms [ms] Timestamp (time since system boot). * @param sensor_type Class id of the distance sensor type. * @param frame Coordinate frame of reference. * @param obstacle_id Unique ID given to each obstacle so that its movement can be tracked. Use UINT16_MAX if object ID is unknown or cannot be determined. * @param x [m] X position of the obstacle. * @param y [m] Y position of the obstacle. * @param z [m] Z position of the obstacle. * @param min_distance [m] Minimum distance the sensor can measure. * @param max_distance [m] Maximum distance the sensor can measure. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_obstacle_distance_3d_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint32_t time_boot_ms, uint8_t sensor_type, uint8_t frame, uint16_t obstacle_id, float x, float y, float z, float min_distance, float max_distance) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN]; _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_float(buf, 4, x); _mav_put_float(buf, 8, y); _mav_put_float(buf, 12, z); _mav_put_float(buf, 16, min_distance); _mav_put_float(buf, 20, max_distance); _mav_put_uint16_t(buf, 24, obstacle_id); _mav_put_uint8_t(buf, 26, sensor_type); _mav_put_uint8_t(buf, 27, frame); memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); #else mavlink_obstacle_distance_3d_t packet; packet.time_boot_ms = time_boot_ms; packet.x = x; packet.y = y; packet.z = z; packet.min_distance = min_distance; packet.max_distance = max_distance; packet.obstacle_id = obstacle_id; packet.sensor_type = sensor_type; packet.frame = frame; memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); #endif msg->msgid = MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D; return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); } /** * @brief Pack a obstacle_distance_3d message on a channel * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message will be sent over * @param msg The MAVLink message to compress the data into * @param time_boot_ms [ms] Timestamp (time since system boot). * @param sensor_type Class id of the distance sensor type. * @param frame Coordinate frame of reference. * @param obstacle_id Unique ID given to each obstacle so that its movement can be tracked. Use UINT16_MAX if object ID is unknown or cannot be determined. * @param x [m] X position of the obstacle. * @param y [m] Y position of the obstacle. * @param z [m] Z position of the obstacle. * @param min_distance [m] Minimum distance the sensor can measure. * @param max_distance [m] Maximum distance the sensor can measure. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_obstacle_distance_3d_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint32_t time_boot_ms,uint8_t sensor_type,uint8_t frame,uint16_t obstacle_id,float x,float y,float z,float min_distance,float max_distance) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN]; _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_float(buf, 4, x); _mav_put_float(buf, 8, y); _mav_put_float(buf, 12, z); _mav_put_float(buf, 16, min_distance); _mav_put_float(buf, 20, max_distance); _mav_put_uint16_t(buf, 24, obstacle_id); _mav_put_uint8_t(buf, 26, sensor_type); _mav_put_uint8_t(buf, 27, frame); memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); #else mavlink_obstacle_distance_3d_t packet; packet.time_boot_ms = time_boot_ms; packet.x = x; packet.y = y; packet.z = z; packet.min_distance = min_distance; packet.max_distance = max_distance; packet.obstacle_id = obstacle_id; packet.sensor_type = sensor_type; packet.frame = frame; memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); #endif msg->msgid = MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D; return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); } /** * @brief Encode a obstacle_distance_3d struct * * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * @param obstacle_distance_3d C-struct to read the message contents from */ static inline uint16_t mavlink_msg_obstacle_distance_3d_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_obstacle_distance_3d_t* obstacle_distance_3d) { return mavlink_msg_obstacle_distance_3d_pack(system_id, component_id, msg, obstacle_distance_3d->time_boot_ms, obstacle_distance_3d->sensor_type, obstacle_distance_3d->frame, obstacle_distance_3d->obstacle_id, obstacle_distance_3d->x, obstacle_distance_3d->y, obstacle_distance_3d->z, obstacle_distance_3d->min_distance, obstacle_distance_3d->max_distance); } /** * @brief Encode a obstacle_distance_3d struct on a channel * * @param system_id ID of this system * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message will be sent over * @param msg The MAVLink message to compress the data into * @param obstacle_distance_3d C-struct to read the message contents from */ static inline uint16_t mavlink_msg_obstacle_distance_3d_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_obstacle_distance_3d_t* obstacle_distance_3d) { return mavlink_msg_obstacle_distance_3d_pack_chan(system_id, component_id, chan, msg, obstacle_distance_3d->time_boot_ms, obstacle_distance_3d->sensor_type, obstacle_distance_3d->frame, obstacle_distance_3d->obstacle_id, obstacle_distance_3d->x, obstacle_distance_3d->y, obstacle_distance_3d->z, obstacle_distance_3d->min_distance, obstacle_distance_3d->max_distance); } /** * @brief Send a obstacle_distance_3d message * @param chan MAVLink channel to send the message * * @param time_boot_ms [ms] Timestamp (time since system boot). * @param sensor_type Class id of the distance sensor type. * @param frame Coordinate frame of reference. * @param obstacle_id Unique ID given to each obstacle so that its movement can be tracked. Use UINT16_MAX if object ID is unknown or cannot be determined. * @param x [m] X position of the obstacle. * @param y [m] Y position of the obstacle. * @param z [m] Z position of the obstacle. * @param min_distance [m] Minimum distance the sensor can measure. * @param max_distance [m] Maximum distance the sensor can measure. */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS static inline void mavlink_msg_obstacle_distance_3d_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t sensor_type, uint8_t frame, uint16_t obstacle_id, float x, float y, float z, float min_distance, float max_distance) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN]; _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_float(buf, 4, x); _mav_put_float(buf, 8, y); _mav_put_float(buf, 12, z); _mav_put_float(buf, 16, min_distance); _mav_put_float(buf, 20, max_distance); _mav_put_uint16_t(buf, 24, obstacle_id); _mav_put_uint8_t(buf, 26, sensor_type); _mav_put_uint8_t(buf, 27, frame); _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D, buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); #else mavlink_obstacle_distance_3d_t packet; packet.time_boot_ms = time_boot_ms; packet.x = x; packet.y = y; packet.z = z; packet.min_distance = min_distance; packet.max_distance = max_distance; packet.obstacle_id = obstacle_id; packet.sensor_type = sensor_type; packet.frame = frame; _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D, (const char *)&packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); #endif } /** * @brief Send a obstacle_distance_3d message * @param chan MAVLink channel to send the message * @param struct The MAVLink struct to serialize */ static inline void mavlink_msg_obstacle_distance_3d_send_struct(mavlink_channel_t chan, const mavlink_obstacle_distance_3d_t* obstacle_distance_3d) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS mavlink_msg_obstacle_distance_3d_send(chan, obstacle_distance_3d->time_boot_ms, obstacle_distance_3d->sensor_type, obstacle_distance_3d->frame, obstacle_distance_3d->obstacle_id, obstacle_distance_3d->x, obstacle_distance_3d->y, obstacle_distance_3d->z, obstacle_distance_3d->min_distance, obstacle_distance_3d->max_distance); #else _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D, (const char *)obstacle_distance_3d, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); #endif } #if MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN <= MAVLINK_MAX_PAYLOAD_LEN /* This varient of _send() can be used to save stack space by re-using memory from the receive buffer. The caller provides a mavlink_message_t which is the size of a full mavlink message. This is usually the receive buffer for the channel, and allows a reply to an incoming message with minimum stack space usage. */ static inline void mavlink_msg_obstacle_distance_3d_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t sensor_type, uint8_t frame, uint16_t obstacle_id, float x, float y, float z, float min_distance, float max_distance) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char *buf = (char *)msgbuf; _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_float(buf, 4, x); _mav_put_float(buf, 8, y); _mav_put_float(buf, 12, z); _mav_put_float(buf, 16, min_distance); _mav_put_float(buf, 20, max_distance); _mav_put_uint16_t(buf, 24, obstacle_id); _mav_put_uint8_t(buf, 26, sensor_type); _mav_put_uint8_t(buf, 27, frame); _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D, buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); #else mavlink_obstacle_distance_3d_t *packet = (mavlink_obstacle_distance_3d_t *)msgbuf; packet->time_boot_ms = time_boot_ms; packet->x = x; packet->y = y; packet->z = z; packet->min_distance = min_distance; packet->max_distance = max_distance; packet->obstacle_id = obstacle_id; packet->sensor_type = sensor_type; packet->frame = frame; _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D, (const char *)packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); #endif } #endif #endif // MESSAGE OBSTACLE_DISTANCE_3D UNPACKING /** * @brief Get field time_boot_ms from obstacle_distance_3d message * * @return [ms] Timestamp (time since system boot). */ static inline uint32_t mavlink_msg_obstacle_distance_3d_get_time_boot_ms(const mavlink_message_t* msg) { return _MAV_RETURN_uint32_t(msg, 0); } /** * @brief Get field sensor_type from obstacle_distance_3d message * * @return Class id of the distance sensor type. */ static inline uint8_t mavlink_msg_obstacle_distance_3d_get_sensor_type(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 26); } /** * @brief Get field frame from obstacle_distance_3d message * * @return Coordinate frame of reference. */ static inline uint8_t mavlink_msg_obstacle_distance_3d_get_frame(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 27); } /** * @brief Get field obstacle_id from obstacle_distance_3d message * * @return Unique ID given to each obstacle so that its movement can be tracked. Use UINT16_MAX if object ID is unknown or cannot be determined. */ static inline uint16_t mavlink_msg_obstacle_distance_3d_get_obstacle_id(const mavlink_message_t* msg) { return _MAV_RETURN_uint16_t(msg, 24); } /** * @brief Get field x from obstacle_distance_3d message * * @return [m] X position of the obstacle. */ static inline float mavlink_msg_obstacle_distance_3d_get_x(const mavlink_message_t* msg) { return _MAV_RETURN_float(msg, 4); } /** * @brief Get field y from obstacle_distance_3d message * * @return [m] Y position of the obstacle. */ static inline float mavlink_msg_obstacle_distance_3d_get_y(const mavlink_message_t* msg) { return _MAV_RETURN_float(msg, 8); } /** * @brief Get field z from obstacle_distance_3d message * * @return [m] Z position of the obstacle. */ static inline float mavlink_msg_obstacle_distance_3d_get_z(const mavlink_message_t* msg) { return _MAV_RETURN_float(msg, 12); } /** * @brief Get field min_distance from obstacle_distance_3d message * * @return [m] Minimum distance the sensor can measure. */ static inline float mavlink_msg_obstacle_distance_3d_get_min_distance(const mavlink_message_t* msg) { return _MAV_RETURN_float(msg, 16); } /** * @brief Get field max_distance from obstacle_distance_3d message * * @return [m] Maximum distance the sensor can measure. */ static inline float mavlink_msg_obstacle_distance_3d_get_max_distance(const mavlink_message_t* msg) { return _MAV_RETURN_float(msg, 20); } /** * @brief Decode a obstacle_distance_3d message into a struct * * @param msg The message to decode * @param obstacle_distance_3d C-struct to decode the message contents into */ static inline void mavlink_msg_obstacle_distance_3d_decode(const mavlink_message_t* msg, mavlink_obstacle_distance_3d_t* obstacle_distance_3d) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS obstacle_distance_3d->time_boot_ms = mavlink_msg_obstacle_distance_3d_get_time_boot_ms(msg); obstacle_distance_3d->x = mavlink_msg_obstacle_distance_3d_get_x(msg); obstacle_distance_3d->y = mavlink_msg_obstacle_distance_3d_get_y(msg); obstacle_distance_3d->z = mavlink_msg_obstacle_distance_3d_get_z(msg); obstacle_distance_3d->min_distance = mavlink_msg_obstacle_distance_3d_get_min_distance(msg); obstacle_distance_3d->max_distance = mavlink_msg_obstacle_distance_3d_get_max_distance(msg); obstacle_distance_3d->obstacle_id = mavlink_msg_obstacle_distance_3d_get_obstacle_id(msg); obstacle_distance_3d->sensor_type = mavlink_msg_obstacle_distance_3d_get_sensor_type(msg); obstacle_distance_3d->frame = mavlink_msg_obstacle_distance_3d_get_frame(msg); #else uint8_t len = msg->len < MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN? msg->len : MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN; memset(obstacle_distance_3d, 0, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); memcpy(obstacle_distance_3d, _MAV_PAYLOAD(msg), len); #endif }
46.601449
372
0.770487
[ "object" ]
ee094a90328e4c2bc0bb64107d43a0a687e58369
21,756
h
C
Code from the book/Ch23/Ex23_03/Form1.h
salomarx/Visual_studio_2008_for_C_plus
5ff62b7e7f6232df38152390cc56c2d394567cab
[ "MIT" ]
null
null
null
Code from the book/Ch23/Ex23_03/Form1.h
salomarx/Visual_studio_2008_for_C_plus
5ff62b7e7f6232df38152390cc56c2d394567cab
[ "MIT" ]
null
null
null
Code from the book/Ch23/Ex23_03/Form1.h
salomarx/Visual_studio_2008_for_C_plus
5ff62b7e7f6232df38152390cc56c2d394567cab
[ "MIT" ]
null
null
null
#pragma once namespace Ex23_03 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // dataGridView->AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode::AllCells; dataGridView->AutoResizeColumnHeadersHeight(); // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::DataGridView^ dataGridView; private: Ex22_03::Customers^ Customers; private: System::Windows::Forms::BindingSource^ customersBindingSource; private: Ex22_03::CustomersTableAdapters::CustomersTableAdapter^ CustomersTableAdapter; private: System::Windows::Forms::DataGridViewTextBoxColumn^ customerIDDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ companyNameDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ contactNameDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ contactTitleDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ addressDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ cityDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ regionDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ postalCodeDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ countryDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ phoneDataGridViewTextBoxColumn; private: System::Windows::Forms::DataGridViewTextBoxColumn^ faxDataGridViewTextBoxColumn; private: System::Windows::Forms::BindingNavigator^ bindingNavigator1; private: System::Windows::Forms::ToolStripButton^ bindingNavigatorAddNewItem; private: System::Windows::Forms::ToolStripLabel^ bindingNavigatorCountItem; private: System::Windows::Forms::ToolStripButton^ bindingNavigatorDeleteItem; private: System::Windows::Forms::ToolStripButton^ bindingNavigatorMoveFirstItem; private: System::Windows::Forms::ToolStripButton^ bindingNavigatorMovePreviousItem; private: System::Windows::Forms::ToolStripSeparator^ bindingNavigatorSeparator; private: System::Windows::Forms::ToolStripTextBox^ bindingNavigatorPositionItem; private: System::Windows::Forms::ToolStripSeparator^ bindingNavigatorSeparator1; private: System::Windows::Forms::ToolStripButton^ bindingNavigatorMoveNextItem; private: System::Windows::Forms::ToolStripButton^ bindingNavigatorMoveLastItem; private: System::Windows::Forms::ToolStripSeparator^ bindingNavigatorSeparator2; private: System::ComponentModel::IContainer^ components; protected: private: /// <summary> /// Required designer variable. /// </summary> #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->components = (gcnew System::ComponentModel::Container()); System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); this->dataGridView = (gcnew System::Windows::Forms::DataGridView()); this->customerIDDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->companyNameDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->contactNameDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->contactTitleDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->addressDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->cityDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->regionDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->postalCodeDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->countryDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->phoneDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->faxDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->customersBindingSource = (gcnew System::Windows::Forms::BindingSource(this->components)); this->Customers = (gcnew Ex22_03::Customers()); this->CustomersTableAdapter = (gcnew Ex22_03::CustomersTableAdapters::CustomersTableAdapter()); this->bindingNavigator1 = (gcnew System::Windows::Forms::BindingNavigator(this->components)); this->bindingNavigatorMoveFirstItem = (gcnew System::Windows::Forms::ToolStripButton()); this->bindingNavigatorMovePreviousItem = (gcnew System::Windows::Forms::ToolStripButton()); this->bindingNavigatorSeparator = (gcnew System::Windows::Forms::ToolStripSeparator()); this->bindingNavigatorPositionItem = (gcnew System::Windows::Forms::ToolStripTextBox()); this->bindingNavigatorCountItem = (gcnew System::Windows::Forms::ToolStripLabel()); this->bindingNavigatorSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->bindingNavigatorMoveNextItem = (gcnew System::Windows::Forms::ToolStripButton()); this->bindingNavigatorMoveLastItem = (gcnew System::Windows::Forms::ToolStripButton()); this->bindingNavigatorSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->bindingNavigatorAddNewItem = (gcnew System::Windows::Forms::ToolStripButton()); this->bindingNavigatorDeleteItem = (gcnew System::Windows::Forms::ToolStripButton()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->customersBindingSource))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->Customers))->BeginInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->bindingNavigator1))->BeginInit(); this->bindingNavigator1->SuspendLayout(); this->SuspendLayout(); // // dataGridView // this->dataGridView->AutoGenerateColumns = false; this->dataGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; this->dataGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(11) {this->customerIDDataGridViewTextBoxColumn, this->companyNameDataGridViewTextBoxColumn, this->contactNameDataGridViewTextBoxColumn, this->contactTitleDataGridViewTextBoxColumn, this->addressDataGridViewTextBoxColumn, this->cityDataGridViewTextBoxColumn, this->regionDataGridViewTextBoxColumn, this->postalCodeDataGridViewTextBoxColumn, this->countryDataGridViewTextBoxColumn, this->phoneDataGridViewTextBoxColumn, this->faxDataGridViewTextBoxColumn}); this->dataGridView->DataSource = this->customersBindingSource; this->dataGridView->Dock = System::Windows::Forms::DockStyle::Fill; this->dataGridView->Location = System::Drawing::Point(0, 0); this->dataGridView->Name = L"dataGridView"; this->dataGridView->Size = System::Drawing::Size(442, 262); this->dataGridView->TabIndex = 0; // // customerIDDataGridViewTextBoxColumn // this->customerIDDataGridViewTextBoxColumn->DataPropertyName = L"CustomerID"; this->customerIDDataGridViewTextBoxColumn->HeaderText = L"CustomerID"; this->customerIDDataGridViewTextBoxColumn->Name = L"customerIDDataGridViewTextBoxColumn"; // // companyNameDataGridViewTextBoxColumn // this->companyNameDataGridViewTextBoxColumn->DataPropertyName = L"CompanyName"; this->companyNameDataGridViewTextBoxColumn->HeaderText = L"CompanyName"; this->companyNameDataGridViewTextBoxColumn->Name = L"companyNameDataGridViewTextBoxColumn"; // // contactNameDataGridViewTextBoxColumn // this->contactNameDataGridViewTextBoxColumn->DataPropertyName = L"ContactName"; this->contactNameDataGridViewTextBoxColumn->HeaderText = L"ContactName"; this->contactNameDataGridViewTextBoxColumn->Name = L"contactNameDataGridViewTextBoxColumn"; // // contactTitleDataGridViewTextBoxColumn // this->contactTitleDataGridViewTextBoxColumn->DataPropertyName = L"ContactTitle"; this->contactTitleDataGridViewTextBoxColumn->HeaderText = L"ContactTitle"; this->contactTitleDataGridViewTextBoxColumn->Name = L"contactTitleDataGridViewTextBoxColumn"; // // addressDataGridViewTextBoxColumn // this->addressDataGridViewTextBoxColumn->DataPropertyName = L"Address"; this->addressDataGridViewTextBoxColumn->HeaderText = L"Address"; this->addressDataGridViewTextBoxColumn->Name = L"addressDataGridViewTextBoxColumn"; // // cityDataGridViewTextBoxColumn // this->cityDataGridViewTextBoxColumn->DataPropertyName = L"City"; this->cityDataGridViewTextBoxColumn->HeaderText = L"City"; this->cityDataGridViewTextBoxColumn->Name = L"cityDataGridViewTextBoxColumn"; // // regionDataGridViewTextBoxColumn // this->regionDataGridViewTextBoxColumn->DataPropertyName = L"Region"; this->regionDataGridViewTextBoxColumn->HeaderText = L"Region"; this->regionDataGridViewTextBoxColumn->Name = L"regionDataGridViewTextBoxColumn"; // // postalCodeDataGridViewTextBoxColumn // this->postalCodeDataGridViewTextBoxColumn->DataPropertyName = L"PostalCode"; this->postalCodeDataGridViewTextBoxColumn->HeaderText = L"PostalCode"; this->postalCodeDataGridViewTextBoxColumn->Name = L"postalCodeDataGridViewTextBoxColumn"; // // countryDataGridViewTextBoxColumn // this->countryDataGridViewTextBoxColumn->DataPropertyName = L"Country"; this->countryDataGridViewTextBoxColumn->HeaderText = L"Country"; this->countryDataGridViewTextBoxColumn->Name = L"countryDataGridViewTextBoxColumn"; // // phoneDataGridViewTextBoxColumn // this->phoneDataGridViewTextBoxColumn->DataPropertyName = L"Phone"; this->phoneDataGridViewTextBoxColumn->HeaderText = L"Phone"; this->phoneDataGridViewTextBoxColumn->Name = L"phoneDataGridViewTextBoxColumn"; // // faxDataGridViewTextBoxColumn // this->faxDataGridViewTextBoxColumn->DataPropertyName = L"Fax"; this->faxDataGridViewTextBoxColumn->HeaderText = L"Fax"; this->faxDataGridViewTextBoxColumn->Name = L"faxDataGridViewTextBoxColumn"; // // customersBindingSource // this->customersBindingSource->DataMember = L"Customers"; this->customersBindingSource->DataSource = this->Customers; // // Customers // this->Customers->DataSetName = L"Customers"; this->Customers->SchemaSerializationMode = System::Data::SchemaSerializationMode::IncludeSchema; // // CustomersTableAdapter // this->CustomersTableAdapter->ClearBeforeFill = true; // // bindingNavigator1 // this->bindingNavigator1->AddNewItem = this->bindingNavigatorAddNewItem; this->bindingNavigator1->BindingSource = this->customersBindingSource; this->bindingNavigator1->CountItem = this->bindingNavigatorCountItem; this->bindingNavigator1->DeleteItem = this->bindingNavigatorDeleteItem; this->bindingNavigator1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(11) {this->bindingNavigatorMoveFirstItem, this->bindingNavigatorMovePreviousItem, this->bindingNavigatorSeparator, this->bindingNavigatorPositionItem, this->bindingNavigatorCountItem, this->bindingNavigatorSeparator1, this->bindingNavigatorMoveNextItem, this->bindingNavigatorMoveLastItem, this->bindingNavigatorSeparator2, this->bindingNavigatorAddNewItem, this->bindingNavigatorDeleteItem}); this->bindingNavigator1->Location = System::Drawing::Point(0, 0); this->bindingNavigator1->MoveFirstItem = this->bindingNavigatorMoveFirstItem; this->bindingNavigator1->MoveLastItem = this->bindingNavigatorMoveLastItem; this->bindingNavigator1->MoveNextItem = this->bindingNavigatorMoveNextItem; this->bindingNavigator1->MovePreviousItem = this->bindingNavigatorMovePreviousItem; this->bindingNavigator1->Name = L"bindingNavigator1"; this->bindingNavigator1->PositionItem = this->bindingNavigatorPositionItem; this->bindingNavigator1->Size = System::Drawing::Size(442, 25); this->bindingNavigator1->TabIndex = 1; this->bindingNavigator1->Text = L"bindingNavigator1"; // // bindingNavigatorMoveFirstItem // this->bindingNavigatorMoveFirstItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->bindingNavigatorMoveFirstItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMoveFirstItem.Image"))); this->bindingNavigatorMoveFirstItem->Name = L"bindingNavigatorMoveFirstItem"; this->bindingNavigatorMoveFirstItem->RightToLeftAutoMirrorImage = true; this->bindingNavigatorMoveFirstItem->Size = System::Drawing::Size(23, 22); this->bindingNavigatorMoveFirstItem->Text = L"Move first"; // // bindingNavigatorMovePreviousItem // this->bindingNavigatorMovePreviousItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->bindingNavigatorMovePreviousItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMovePreviousItem.Image"))); this->bindingNavigatorMovePreviousItem->Name = L"bindingNavigatorMovePreviousItem"; this->bindingNavigatorMovePreviousItem->RightToLeftAutoMirrorImage = true; this->bindingNavigatorMovePreviousItem->Size = System::Drawing::Size(23, 22); this->bindingNavigatorMovePreviousItem->Text = L"Move previous"; // // bindingNavigatorSeparator // this->bindingNavigatorSeparator->Name = L"bindingNavigatorSeparator"; this->bindingNavigatorSeparator->Size = System::Drawing::Size(6, 25); // // bindingNavigatorPositionItem // this->bindingNavigatorPositionItem->AccessibleName = L"Position"; this->bindingNavigatorPositionItem->AutoSize = false; this->bindingNavigatorPositionItem->Name = L"bindingNavigatorPositionItem"; this->bindingNavigatorPositionItem->Size = System::Drawing::Size(50, 23); this->bindingNavigatorPositionItem->Text = L"0"; this->bindingNavigatorPositionItem->ToolTipText = L"Current position"; // // bindingNavigatorCountItem // this->bindingNavigatorCountItem->Name = L"bindingNavigatorCountItem"; this->bindingNavigatorCountItem->Size = System::Drawing::Size(42, 22); this->bindingNavigatorCountItem->Text = L"of {0}"; this->bindingNavigatorCountItem->ToolTipText = L"Total number of items"; // // bindingNavigatorSeparator1 // this->bindingNavigatorSeparator1->Name = L"bindingNavigatorSeparator"; this->bindingNavigatorSeparator1->Size = System::Drawing::Size(6, 25); // // bindingNavigatorMoveNextItem // this->bindingNavigatorMoveNextItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->bindingNavigatorMoveNextItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMoveNextItem.Image"))); this->bindingNavigatorMoveNextItem->Name = L"bindingNavigatorMoveNextItem"; this->bindingNavigatorMoveNextItem->RightToLeftAutoMirrorImage = true; this->bindingNavigatorMoveNextItem->Size = System::Drawing::Size(23, 22); this->bindingNavigatorMoveNextItem->Text = L"Move next"; // // bindingNavigatorMoveLastItem // this->bindingNavigatorMoveLastItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->bindingNavigatorMoveLastItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorMoveLastItem.Image"))); this->bindingNavigatorMoveLastItem->Name = L"bindingNavigatorMoveLastItem"; this->bindingNavigatorMoveLastItem->RightToLeftAutoMirrorImage = true; this->bindingNavigatorMoveLastItem->Size = System::Drawing::Size(23, 22); this->bindingNavigatorMoveLastItem->Text = L"Move last"; // // bindingNavigatorSeparator2 // this->bindingNavigatorSeparator2->Name = L"bindingNavigatorSeparator"; this->bindingNavigatorSeparator2->Size = System::Drawing::Size(6, 25); // // bindingNavigatorAddNewItem // this->bindingNavigatorAddNewItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->bindingNavigatorAddNewItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorAddNewItem.Image"))); this->bindingNavigatorAddNewItem->Name = L"bindingNavigatorAddNewItem"; this->bindingNavigatorAddNewItem->RightToLeftAutoMirrorImage = true; this->bindingNavigatorAddNewItem->Size = System::Drawing::Size(23, 22); this->bindingNavigatorAddNewItem->Text = L"Add new"; this->bindingNavigatorAddNewItem->Click += gcnew System::EventHandler(this, &Form1::bindingNavigatorAddNewItem_Click); // // bindingNavigatorDeleteItem // this->bindingNavigatorDeleteItem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->bindingNavigatorDeleteItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorDeleteItem.Image"))); this->bindingNavigatorDeleteItem->Name = L"bindingNavigatorDeleteItem"; this->bindingNavigatorDeleteItem->RightToLeftAutoMirrorImage = true; this->bindingNavigatorDeleteItem->Size = System::Drawing::Size(23, 22); this->bindingNavigatorDeleteItem->Text = L"Delete"; this->bindingNavigatorDeleteItem->Click += gcnew System::EventHandler(this, &Form1::bindingNavigatorDeleteItem_Click); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(442, 262); this->Controls->Add(this->bindingNavigator1); this->Controls->Add(this->dataGridView); this->Name = L"Form1"; this->Text = L"Using a Binding Source Component"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->customersBindingSource))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->Customers))->EndInit(); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->bindingNavigator1))->EndInit(); this->bindingNavigator1->ResumeLayout(false); this->bindingNavigator1->PerformLayout(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { // TODO: This line of code loads data into the 'Customers._Customers' table. You can move, or remove it, as needed. this->CustomersTableAdapter->Fill(this->Customers->_Customers); } private: System::Void bindingNavigatorAddNewItem_Click(System::Object^ sender, System::EventArgs^ e) { try { CustomersTableAdapter->Update(Customers->_Customers); // CustomersTableAdapter->Update(NorthwindDataSet->Customers); } catch (Exception^ ex) { MessageBox::Show(L"Update Failed!\n"+ex, L"Database Record Update Error", MessageBoxButtons::OK, MessageBoxIcon::Error); } } private: System::Void bindingNavigatorDeleteItem_Click(System::Object^ sender, System::EventArgs^ e) { try { CustomersTableAdapter->Update(Customers->_Customers); } catch (Exception^ ex) { MessageBox::Show(L"Delete Failed!\n"+ex, L"Database Record Delete Error", MessageBoxButtons::OK, MessageBoxIcon::Error); } } }; }
56.362694
167
0.730235
[ "object" ]
ee13c77f66aafa862ebaaef175dd3d8b8c5a8aaf
3,619
h
C
src/mit/miti/core.h
DmitriWamback/Mi-engine
97704fd5f2f1093133ddddf143bf39aa3785655e
[ "Apache-2.0" ]
2
2021-12-10T00:22:36.000Z
2021-12-10T00:22:38.000Z
src/mit/miti/core.h
DmitriWamback/Mi-engine
97704fd5f2f1093133ddddf143bf39aa3785655e
[ "Apache-2.0" ]
null
null
null
src/mit/miti/core.h
DmitriWamback/Mi-engine
97704fd5f2f1093133ddddf143bf39aa3785655e
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <fstream> #include <sstream> #include <map> #include <vector> #include <string> #include <thread> #include <functional> #include <list> #include "net/socket_server.h" #include <GL/glew.h> #include <GLFW/glfw3.h> GLFWwindow* main_window; #define KEY_UP GLFW_PRESS #define KEY_DOWN GLFW_RELEASE #define MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_RIGHT #define MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_LEFT // Index = position in dimension n + the weight attribute (1) #define DTYPE2 3 #define DTYPE3 4 #define DTYPE1 2 #define GetKeyDown(key) glfwGetKey(main_window, key) == KEY_UP #define GetKeyUp(key) glfwGetKey(main_window, key) == KEY_DOWN #define GetMouseButtonDown(key) glfwGetMouseButton(main_window, key) == KEY_UP #define GetMouseButtonUp(key) glfwGetMouseButton(main_window, key) == KEY_DOWN void GetMousePosition(double* x, double* y) { glfwGetCursorPos(main_window, x, y); } #include <glm/vec2.hpp> #include <glm/vec3.hpp> #include <glm/vec4.hpp> #include <glm/mat4x4.hpp> #include <glm/gtc/matrix_transform.hpp> #include "shader.h" #include "util/perlin_noise.h" #include "util/camera.h" #include "util/renderable.h" namespace MITI { namespace Core { MITI::MITISocketServer serv; MITI::Camera camera; MITI::Shader main_shader; MITI::CoreGraphics::Renderable* renderable; void InitializeMITI(int width, int height) { serv = MITI::MITISocketServer::CreateLocalhost(); camera = MITI::Camera::Create(); glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); #if defined(__APPLE__) glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #endif main_window = glfwCreateWindow(width, height, "MITI", NULL, NULL); glfwMakeContextCurrent(main_window); glewExperimental = GL_TRUE; glewInit(); } void scroll(GLFWwindow* window, double x, double y) { camera.UpdateZoom(y); } void StartMainLoop() { serv.WaitConnection(); main_shader = MITI::Shader::Create("vMain.glsl", "fMain.glsl", "MAIN_SHADER"); MITI::CoreGraphics::renderbuf r = MITI::CoreGraphics::renderbuf(); renderable = MITI::CoreGraphics::Triangle::Create(r); glm::mat4 model = glm::mat4(1.f); glfwSetScrollCallback(main_window, scroll); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB); glEnable(GL_DEPTH_TEST); while (!glfwWindowShouldClose(main_window)) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.05, 0.05, 0.05, 0.0); int width; int height; glfwGetWindowSize(main_window, &width, &height); #if defined(__APPLE__) if (width > height) glViewport(0, -abs(width-height), width*2, width*2); else glViewport(-abs(width-height), 0, height*2, height*2); #else if (width > height) glViewport(0, -abs(width-height)/2, width, width); else glViewport(-abs(width-height)/2, 0, height, height); #endif std::string data = serv.Read(); camera.Update(); main_shader.use(); main_shader.setMatr4("projection", camera.projection); main_shader.setMatr4("view", camera.view); main_shader.setMatr4("model", model); renderable->Render(); glfwPollEvents(); glfwSwapBuffers(main_window); } } }}
31.469565
86
0.658193
[ "render", "vector", "model" ]
ee13daafe1c1648c53983a47043d43a88c33ebe6
20,368
h
C
lib/linalg/Vector.h
siuwuncheung/libROM
4e97ab38ebb27195b8eb9b789d932cb9073509c7
[ "ECL-2.0", "Apache-2.0", "MIT" ]
1
2021-12-06T20:41:00.000Z
2021-12-06T20:41:00.000Z
lib/linalg/Vector.h
siuwuncheung/libROM
4e97ab38ebb27195b8eb9b789d932cb9073509c7
[ "ECL-2.0", "Apache-2.0", "MIT" ]
null
null
null
lib/linalg/Vector.h
siuwuncheung/libROM
4e97ab38ebb27195b8eb9b789d932cb9073509c7
[ "ECL-2.0", "Apache-2.0", "MIT" ]
null
null
null
/****************************************************************************** * * Copyright (c) 2013-2021, Lawrence Livermore National Security, LLC * and other libROM project developers. See the top-level COPYRIGHT * file for details. * * SPDX-License-Identifier: (Apache-2.0 OR MIT) * *****************************************************************************/ // Description: A simple, parallel Vector class with the utility needed to // support the basis generation methods of this library. A // distributed Vector has its rows distributed across processors. #ifndef included_Vector_h #define included_Vector_h #include "utils/Utilities.h" #include <vector> #include <functional> namespace CAROM { /** * Class Vector is a simple vector class in which the dimensions may be * distributed across multiple processes. This class supports only the basic * operations that are needed by the SVD library. */ class Vector { public: Vector(); /** * @brief Constructor creating a Vector with uninitialized values. * * @pre dim > 0 * * @param[in] dim When undistributed, the total dimension of the Vector. * When distributed, the part of the total dimension of * the Vector on this processor. * @param[in] distributed If true the dimensions of the Vector are spread * over all processors. */ Vector( int dim, bool distributed); /** * @brief Constructor in which the Vector is given its initial values. * * @pre vec != 0 * @pre dim > 0 * * @param[in] vec The initial values of the Vector. * @param[in] dim When undistributed, the total dimension of the Vector. * When distributed, the part of the total dimension of * the Vector on this processor. * @param[in] distributed If true the dimensions of the Vector are spread * over all processors. * @param[in] copy_data If true the vector allocates is own storage and * copies the contents of vec into its own storage. * Otherwise it uses vec as its storage. */ Vector( double* vec, int dim, bool distributed, bool copy_data = true); /** * @brief Copy constructor. * * @param[in] other The Vector to copy. */ Vector( const Vector& other); /** * @brief Destructor. */ ~Vector(); /** * @brief Assignment operator. * * @param[in] rhs The Vector to assign to this. * * @return This after rhs has been assigned to it. */ Vector& operator = ( const Vector& rhs); /** * @brief Addition operator. * * @param[in] rhs The Vector to add to this. * * @return This after rhs has been added to it. */ Vector& operator += ( const Vector& rhs); /** * @brief Equal operator. * * @param[in] a The double precision number to which every * Vector entry should be set. * * @return This with every element of the Vector set to a. */ Vector& operator = ( const double& a); /** * @brief Transform the vector using a supplied function. * * @param[in] transformer A transformer function which takes in as input a * size and a vector. * * @return The newly transformed vector. */ Vector& transform(std::function<void(const int size, double* vector)> transformer); /** * @brief Transform a vector using a supplied function and store the * results in another vector. * * @param[out] result A vector which will store the transformed result. * * @param[in] transformer A transformer function which takes in as input a * size and transforms the vector. */ void transform(Vector& result, std::function<void(const int size, double* vector)> transformer) const; /** * @brief Transform a vector using a supplied function and store the * results in another vector. * * @param[out] result A vector which will store the transformed result. * * @param[in] transformer A transformer function which takes in as input a * size and transforms the vector. */ void transform(Vector*& result, std::function<void(const int size, double* vector)> transformer) const; /** * @brief Transform the vector using a supplied function. * * @param[in] transformer A transformer function which takes in as input a * size and transforms the origVector and stores the result in * resultVector. * * @return The newly transformed vector. */ Vector& transform(std::function<void(const int size, double* origVector, double* resultVector)> transformer); /** * @brief Transform a vector using a supplied function and store the * results in another vector. * * @param[out] result A vector which will store the transformed result. * * @param[in] transformer A transformer function which takes in as input a * size and transforms the origVector and stores the result in * resultVector. */ void transform(Vector& result, std::function<void(const int size, double* origVector, double* resultVector)> transformer) const; /** * @brief Transform a vector using a supplied function and store the * results in another vector. * * @param[out] result A vector which will store the transformed result. * * @param[in] transformer A transformer function which takes in as input a * size and transforms the origVector and stores the result in * resultVector. */ void transform(Vector*& result, std::function<void(const int size, double* origVector, double* resultVector)> transformer) const; /** * @brief Sets the length of the vector and reallocates storage if * needed. All values are initialized to zero. * * @param[in] dim When undistributed, the total dimension of the Vector. * When distributed, the part of the total dimension of * the Vector on this processor. */ void setSize( int dim) { if (dim > d_alloc_size) { if (!d_owns_data) { CAROM_ERROR("Can not reallocate externally owned storage."); } if (d_vec) { delete [] d_vec; } // Allocate new array and initialize all values to zero. d_vec = new double [dim] {0.0}; d_alloc_size = dim; } d_dim = dim; } /** * @brief Returns true if the Vector is distributed. * * @return True if the Vector is distributed. */ bool distributed() const { return d_distributed; } /** * @brief Returns the dimension of the Vector on this processor. * * @return The part of the Vector's dimension on this processor. */ int dim() const { return d_dim; } /** * @brief Inner product, reference form. * * For distributed Vectors this is a parallel operation. * * @pre dim() == other.dim() * @pre distributed() == other.distributed() * * @param[in] other The Vector to form the inner product with this. * * @return The inner product of this and other. */ double inner_product( const Vector& other) const; /** * @brief Inner product, pointer version. * * For distributed Vectors this is a parallel operation. * * @pre other != 0 * @pre dim() == other->dim() * @pre distributed() == other->distributed() * * @param[in] other The Vector to form the inner product with this. * * @return The inner product of this and other. */ double inner_product( const Vector* other) const { CAROM_VERIFY(other != 0); return inner_product(*other); } /** * @brief Form the norm of this. * * For a distributed Vector this is a parallel operation. * * @return The norm of this. */ double norm() const; /** * @brief Form the squared norm of this. * * For a distributed Vector this is a parallel operation. * * @return The squared norm of this. */ double norm2() const; /** * @brief Normalizes the Vector and returns its norm. * * For a distributed Vector this is a parallel operation. * * @return The norm of this. */ double normalize(); /** * @brief Adds other and this and returns the result, reference version. * * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] other The other summand. * * @return this + other */ Vector* plus( const Vector& other) const { Vector* result = 0; plus(other, result); return result; } /** * @brief Adds other and this and returns the result, pointer version. * * @pre other != 0 * @pre distributed() == other->distributed() * @pre dim() == other->dim() * * @param[in] other The other summand. * * @return this + other */ Vector* plus( const Vector* other) const { CAROM_VERIFY(other != 0); return plus(*other); } /** * @brief Adds other and this and fills result with the answer. * * Result will be allocated if unallocated or resized appropriately if * already allocated. * * @pre result == 0 || result->distributed() == distributed() * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] other The other summand. * @param[out] result this + other */ void plus( const Vector& other, Vector*& result) const; /** * @brief Adds other and this and fills result with the answer. * * Result will be resized appropriately. * * @pre result.distributed() == distributed() * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] other The other summand. * @param[out] result this + other */ void plus( const Vector& other, Vector& result) const; /** * @brief Adds factor*other and this and returns the result, reference * version. * * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] factor Multiplicative factor applied to other. * @param[in] other The other summand. * * @return this + factor*other */ Vector* plusAx( double factor, const Vector& other) { Vector* result = 0; plusAx(factor, other, result); return result; } /** * @brief Adds factor*other and this and returns the result, pointer * version. * * @pre distributed() == other->distributed() * @pre dim() == other->dim() * * @param[in] factor Multiplicative factor applied to other. * @param[in] other The other summand. * * @return this + factor*other */ Vector* plusAx( double factor, const Vector* other) { CAROM_VERIFY(other != 0); return plusAx(factor, *other); } /** * @brief Adds factor*other and this and fills result with the answer. * * Result will be allocated if unallocated or resized appropriately if * already allocated. * * @pre result == 0 || result->distributed() == distributed() * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] factor Multiplicative factor applied to other. * @param[in] other The other summand. * @param[out] result this + factor*other */ void plusAx( double factor, const Vector& other, Vector*& result) const; /** * @brief Adds factor*other and this and fills result with the answer. * * Result will be resized appropriately. * * @pre result.distributed() == distributed() * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] factor Multiplicative factor applied to other. * @param[in] other The other summand. * @param[out] result this + factor*other */ void plusAx( double factor, const Vector& other, Vector& result) const; /** * @brief Adds factor*other to this, reference version. * * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] factor Multiplicative factor applied to other. * @param[in] other The other summand. */ void plusEqAx( double factor, const Vector& other); /** * @brief Adds factor*other to this, pointer version. * * @pre other != 0 * @pre distributed() == other->distributed() * @pre dim() == other->dim() * * @param[in] factor Multiplicative factor applied to other. * @param[in] other The other summand. */ void plusEqAx( double factor, const Vector* other) { CAROM_VERIFY(other != 0); plusEqAx(factor, *other); } /** * @brief Subtracts other and this and returns the result, reference * version. * * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] other The other subtrahand. * * @return this - other */ Vector* minus( const Vector& other) const { Vector* result = 0; minus(other, result); return result; } /** * @brief Subtracts other and this and returns the result, pointer * version. * * @pre other != 0 * @pre distributed() == other->distributed() * @pre dim() == other->dim() * * @param[in] other The other subtrahand. * * @return this - other */ Vector* minus( const Vector* other) const { CAROM_VERIFY(other != 0); return minus(*other); } /** * @brief Subtracts other and this and fills result with the answer. * * Result will be allocated if unallocated or resized appropriately if * already allocated. * * @pre result == 0 || result->distributed() == distributed() * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] other The other subtrahend. * @param[out] result this - other */ void minus( const Vector& other, Vector*& result) const; /** * @brief Subtracts other and this and fills result with the answer. * * Result will be resized appropriately. * * @pre result.distributed() == distributed() * @pre distributed() == other.distributed() * @pre dim() == other.dim() * * @param[in] other The other subtrahend. * @param[out] result this - other */ void minus( const Vector& other, Vector& result) const; /** * @brief Multiplies this by the supplied constant and returns the * result. * * @param[in] factor Factor to multiply by. * * @return factor*this */ Vector* mult( double factor) const { Vector* result = 0; mult(factor, result); return result; } /** * @brief Multiplies this by the supplied constant and fills result with * the answer. * * @pre result == 0 || result->distributed() == distributed() * * @param[in] factor Factor to multiply by. * @param[out] result factor*this */ void mult( double factor, Vector*& result) const; /** * @brief Multiplies this by the supplied constant and fills result with * the answer. * * @pre result.distributed() == distributed() * * @param[in] factor Factor to multiply by. * @param[out] result factor*this */ void mult( double factor, Vector& result) const; /** * @brief Const Vector member access. * * @pre (0 <= i) && (i < dim()) * * @param[in] i The component of the Vector on this processor requested. * * @return The requested component of the Vector on this processor. */ const double& item( int i) const { CAROM_ASSERT((0 <= i) && (i < dim())); return d_vec[i]; } /** * @brief Non-const Vector member access. * * Allows constructs of the form vec[i] = val; * * @pre (0 <= i) && (i < dim()) * * @param[in] i The component of the Vector on this processor requested. * * @return The requested component of the Vector on this processor. */ double& item( int i) { CAROM_ASSERT((0 <= i) && (i < dim())); return d_vec[i]; } /** * @brief Const Vector member access. * * @pre (0 <= i) && (i < dim()) * * @param[in] i The component of the Vector on this processor requested. * * @return The requested component of the Vector on this processor. */ const double& operator() (int i) const { return item(i); } /** * @brief Non-const Vector member access. * * Allows constructs of the form vec[i] = val; * * @pre (0 <= i) && (i < dim()) * * @param[in] i The component of the Vector on this processor requested. * * @return The requested component of the Vector on this processor. */ double& operator() (int i) { return item(i); } /** * @brief print Vector into (a) ascii file(s). * * @param[in] prefix The name of the prefix of the file name. * */ void print(const char * prefix); /** * @brief write Vector into (a) HDF file(s). * * @param[in] base_file_name The base part of the file name. * */ void write(const std::string& base_file_name); /** * @brief read Vector from (a) HDF file(s). * * @param[in] base_file_name The base part of the file name. * */ void read(const std::string& base_file_name); /** * @brief read read a single rank of a distributed Vector from (a) HDF file(s). * * @param[in] base_file_name The base part of the file name. * @param[in] rank The rank to read from. * */ void local_read(const std::string& base_file_name, int rank); /** * @brief Get the vector data as a pointer. */ double *getData() const { return d_vec; } private: /** * @brief The storage for the Vector's values on this processor. */ double* d_vec; /** * @brief The part of the Vector's dimension on this processor. */ int d_dim; /** * @brief The currently allocated size. * * d_dim <= d_alloc_size */ int d_alloc_size; /** * @brief If true, the Vector's dimensions are distributed over all * processors. * * Each processor does not need to hold the same number of dimensions. */ bool d_distributed; /** * @brief The number of processors being run on. */ int d_num_procs; /** * @brief If true, this object owns its underlying data, d_vec, and * is responsible for its deletion. * * If d_owns_data is false, then the object may not reallocate d_vec. */ bool d_owns_data; }; /** * @brief Get center point of a group of points. */ int getCenterPoint(std::vector<Vector*> points, bool use_centroid); /** * @brief Get center point of a group of points. */ int getCenterPoint(std::vector<Vector> points, bool use_centroid); } #endif
26.146341
128
0.562844
[ "object", "vector", "transform" ]