File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010# Project
1111cmake_minimum_required (VERSION 3.1 FATAL_ERROR )
12- project (spacy-cpp VERSION 1.01 LANGUAGES CXX )
12+ project (spacy-cpp VERSION 1.02 LANGUAGES CXX )
1313set (CMAKE_CXX_STANDARD 11)
1414if (MSVC )
1515 if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]" )
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ namespace Spacy
4848 template <>
4949 double Python::Convert<double >::get_value(PyObjectPtr p_obj)
5050 {
51- assert (PyFloat_Check (p_obj. get () ));
51+ assert (Custom_PyFloat_Check (p_obj));
5252 return PyFloat_AsDouble (p_obj.get ());
5353 }
5454
@@ -112,4 +112,18 @@ namespace Spacy
112112 {
113113 return PyObjectPtr (PyUnicode_FromStringAndSize (p_val.c_str (), p_val.size ()));
114114 }
115+
116+ bool Python::Custom_PyFloat_Check (PyObjectPtr p_obj)
117+ {
118+ if (PyFloat_Check (p_obj.get ()))
119+ {
120+ return true ;
121+ }
122+ else
123+ {
124+ PyObjectPtr __float__ (PyObject_HasAttrString (p_obj.get (), " __float__" ) ?
125+ PyObject_GetAttrString (p_obj.get (), " __float__" ) : nullptr );
126+ return (__float__.get () != nullptr ) ? PyCallable_Check (__float__.get ()) : false ;
127+ }
128+ }
115129}
Original file line number Diff line number Diff line change @@ -142,7 +142,9 @@ namespace Spacy
142142 assert (0 );
143143 }
144144 };
145-
145+
146+ static bool Custom_PyFloat_Check (PyObjectPtr p_obj);
147+
146148 private:
147149 std::shared_ptr<char *> m_argv;
148150 };
Original file line number Diff line number Diff line change @@ -330,7 +330,7 @@ int main()
330330 Spacy::Token back = doc.tokens ().at (2 );
331331 unittest::ExpectEqual (std::string, give.pos_ (), " VERB" );
332332 unittest::ExpectEqual (std::string, it.pos_ (), " PRON" );
333- unittest::ExpectEqual (std::string, back.pos_ (), " PART " );
333+ unittest::ExpectEqual (std::string, back.pos_ (), " ADV " );
334334 }
335335
336336 // Token::prob
@@ -385,7 +385,7 @@ int main()
385385 Spacy::Token back = doc.tokens ().at (2 );
386386 unittest::ExpectEqual (std::string, give.tag_ (), " VB" );
387387 unittest::ExpectEqual (std::string, it.tag_ (), " PRP" );
388- unittest::ExpectEqual (std::string, back.tag_ (), " RP " );
388+ unittest::ExpectEqual (std::string, back.tag_ (), " RB " );
389389 }
390390
391391 // Token::text
You can’t perform that action at this time.
0 commit comments