Skip to content

Commit 05ce294

Browse files
committed
fix failing tests and do minor python3 touch ups
1 parent 9f523df commit 05ce294

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# Project
1111
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
12-
project(spacy-cpp VERSION 1.03 LANGUAGES CXX)
12+
project(spacy-cpp VERSION 1.04 LANGUAGES CXX)
1313
set (CMAKE_CXX_STANDARD 11)
1414
if(MSVC)
1515
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import spacy
3333
nlp = spacy.load("en_core_web_sm")
3434
doc = nlp(u"This is a sentence.")
3535
for token in doc:
36-
print token.text + " [" + token.pos_ + "]"
36+
print (token.text + " [" + token.pos_ + "]")
3737
```
3838

3939

src/spacy/nlp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Spacy
2727
PyObjectPtr text(Python::get_object<std::string>(p_text));
2828
std::vector<PyObjectPtr> args = std::vector<PyObjectPtr>({text});
2929
PyObjectPtr doc(Python::call_method<PyObjectPtr>(m_nlp, args));
30-
return Doc(doc);
30+
return doc;
3131
}
3232

3333
Vocab Nlp::vocab() const

src/spacy/spacy.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Spacy
2525
{
2626
if (m_spacy.get() == nullptr)
2727
{
28-
throw std::runtime_error("No module named spacy. Try: pip install -U spacy");
28+
throw std::runtime_error("No module named spacy. Try: pip3 install -U spacy");
2929
}
3030
}
3131

@@ -41,9 +41,9 @@ namespace Spacy
4141
if (nlp.get() == nullptr)
4242
{
4343
throw std::runtime_error("Can't find model '" + p_model + "'. "
44-
"Try: python -m spacy download " + p_model);
44+
"Try: python3 -m spacy download " + p_model);
4545
}
46-
return Nlp(nlp);
46+
return nlp;
4747
}
4848

4949
const Attrs& Spacy::attrs()

src/spacy/token.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ namespace Spacy
223223
return Python::get_attr_value<double>(m_token, "prob");
224224
}
225225

226-
long Token::rank() const
226+
double Token::rank() const
227227
{
228-
return Python::get_attr_value<long>(m_token, "rank");
228+
return Python::get_attr_value<double>(m_token, "rank");
229229
}
230230

231231
double Token::sentiment() const

src/spacy/token.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace Spacy
6969
long pos() const;
7070
std::string pos_() const;
7171
double prob() const;
72-
long rank() const;
72+
double rank() const;
7373
double sentiment() const;
7474
long shape() const;
7575
std::string shape_() const;

tests/test_token.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)