Skip to content

Commit

Permalink
fix failing tests and do minor python3 touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Dec 11, 2020
1 parent 9f523df commit 05ce294
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Project
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(spacy-cpp VERSION 1.03 LANGUAGES CXX)
project(spacy-cpp VERSION 1.04 LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 11)
if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp(u"This is a sentence.")
for token in doc:
print token.text + " [" + token.pos_ + "]"
print (token.text + " [" + token.pos_ + "]")
```


Expand Down
2 changes: 1 addition & 1 deletion src/spacy/nlp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Spacy
PyObjectPtr text(Python::get_object<std::string>(p_text));
std::vector<PyObjectPtr> args = std::vector<PyObjectPtr>({text});
PyObjectPtr doc(Python::call_method<PyObjectPtr>(m_nlp, args));
return Doc(doc);
return doc;
}

Vocab Nlp::vocab() const
Expand Down
6 changes: 3 additions & 3 deletions src/spacy/spacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Spacy
{
if (m_spacy.get() == nullptr)
{
throw std::runtime_error("No module named spacy. Try: pip install -U spacy");
throw std::runtime_error("No module named spacy. Try: pip3 install -U spacy");
}
}

Expand All @@ -41,9 +41,9 @@ namespace Spacy
if (nlp.get() == nullptr)
{
throw std::runtime_error("Can't find model '" + p_model + "'. "
"Try: python -m spacy download " + p_model);
"Try: python3 -m spacy download " + p_model);
}
return Nlp(nlp);
return nlp;
}

const Attrs& Spacy::attrs()
Expand Down
4 changes: 2 additions & 2 deletions src/spacy/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ namespace Spacy
return Python::get_attr_value<double>(m_token, "prob");
}

long Token::rank() const
double Token::rank() const
{
return Python::get_attr_value<long>(m_token, "rank");
return Python::get_attr_value<double>(m_token, "rank");
}

double Token::sentiment() const
Expand Down
2 changes: 1 addition & 1 deletion src/spacy/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace Spacy
long pos() const;
std::string pos_() const;
double prob() const;
long rank() const;
double rank() const;
double sentiment() const;
long shape() const;
std::string shape_() const;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ int main()
Spacy::Token back = doc.tokens().at(2);
unittest::ExpectEqual(std::string, give.tag_(), "VB");
unittest::ExpectEqual(std::string, it.tag_(), "PRP");
unittest::ExpectEqual(std::string, back.tag_(), "RP");
unittest::ExpectEqual(std::string, back.tag_(), "RB");
}

// Token::text
Expand Down

0 comments on commit 05ce294

Please sign in to comment.