From ddbc0c03605b8b5e511544bfee635c16b50bee89 Mon Sep 17 00:00:00 2001 From: Godfrey Duke Date: Tue, 22 Oct 2019 22:12:56 -0700 Subject: [PATCH] Python 2 to 3 code translation. --- README | 2 +- example.py | 8 ++++---- pysentencizer/__init__.py | 2 +- test.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README b/README index 7b7fd2e..fc03f2a 100644 --- a/README +++ b/README @@ -26,7 +26,7 @@ Here is a quick example. $ python >>> import pysentencizer >>> sentencizer = pysentencizer.Sentencizer() ->>> print sentencizer.sentencize("Testing.") +>>> print(sentencizer.sentencize("Testing.")) ['Testing'/sent_start/para_start/word/capital/verb/VBG, '.'/sent_end/para_end/punc] The script example.py demonstrates the ability to tokenize and then print diff --git a/example.py b/example.py index aa4de42..4fcf1f7 100755 --- a/example.py +++ b/example.py @@ -7,13 +7,13 @@ senticizer = pysentencizer.Sentencizer() tokens = senticizer.sentencize(input) -print tokens +print(tokens) for token in tokens: if token.isSentenceStart: - print "\n>>> ", + print("\n>>> ", end=' ') text = token.getRawText().replace("\n"," ").replace("\r","") sys.stdout.write(text) if token.isParaEnd: - print -print + print() +print() diff --git a/pysentencizer/__init__.py b/pysentencizer/__init__.py index bbb835e..cdf529c 100644 --- a/pysentencizer/__init__.py +++ b/pysentencizer/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from pysentencizer import * +from .pysentencizer import * diff --git a/test.py b/test.py index 25d92ab..5f76833 100755 --- a/test.py +++ b/test.py @@ -76,14 +76,14 @@ def timeSentencizeWarAndPeace(): return stop - start if __name__ == "__main__": - print "Running tests." + print("Running tests.") if len(sys.argv) > 1: if sys.argv[1] == "-p": TEST_PERFORMANCE = True else: - print "WARNING: Unknown option",sys.argv[1] + print("WARNING: Unknown option",sys.argv[1]) else: - print "Not testing performance. Use -p to run performance tests." + print("Not testing performance. Use -p to run performance tests.") doctest.testmod()