From 35bbbf4e80fc65851b37e1bb988d8d396f1b34cb Mon Sep 17 00:00:00 2001 From: Vincent Rasneur Date: Sat, 4 Nov 2017 17:18:36 +0100 Subject: [PATCH] update doc --- README.md | 6 ++++-- README.rst | 47 ++++++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 62168a9..6c9a827 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The binding supports Python 2.6, 2.7 and Python 3. It requires [Cython](http://c [Numpy](http://www.numpy.org/) is also a dependency, but is optional. `pyfasttext` has been tested successfully on Linux and Mac OS X. -It does not currently compile on Windows because the `cysignals` module does not support this platform. +*Warning*: `pyfasttext` does not currently compile on Windows because the `cysignals` module does not support this platform. Table of Contents ================= @@ -66,7 +66,9 @@ Table of Contents ## Installation -To compile `pyfasttext`, make sure you have a compiler with C++11 support. +To compile `pyfasttext`, make sure you have the following compiler: +* GCC (`g++`) with C++11 support. +* LLVM (`clang++`) with (at least) partial C++17 support. ### Simplest way to install pyfasttext: use pip diff --git a/README.rst b/README.rst index c7b374c..7e9d9d4 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,9 @@ Yet another Python binding for | `Numpy `__ is also a dependency, but is optional. -``pyfasttext`` has been tested successfully on Linux and Mac OS X. +| ``pyfasttext`` has been tested successfully on Linux and Mac OS X. +| *Warning*: ``pyfasttext`` does not currently compile on Windows + because the ``cysignals`` module does not support this platform. Table of Contents ================= @@ -108,8 +110,9 @@ Table of Contents Installation ------------ -To compile ``pyfasttext``, make sure you have a compiler with C++11 -support. +To compile ``pyfasttext``, make sure you have the following compiler: \* +GCC (``g++``) with C++11 support. \* LLVM (``clang++``) with (at least) +partial C++17 support. Simplest way to install pyfasttext: use pip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -395,22 +398,25 @@ If you have a list of strings (or an iterable object), use this: .. code:: python - >>> model.predict_proba(['first sentence', 'second sentence'], k=2) + >>> model.predict_proba(['first sentence\n', 'second sentence\n'], k=2) [[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)], [('LABEL2', 1.0), ('LABEL3', 1.953126549381068e-08)]] -If your test data is stored inside a file, use this: +If you want to test a single string, use this: .. code:: python - >>> model.predict_proba_file('/path/to/test.txt', k=2) - [[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)], [('LABEL2', 1.0), ('LABEL3', 1.953126549381068e-08)]] + >>> model.predict_proba_single('first sentence\n', k=2) + [('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)] -If you want to test a single string, use this: +**WARNING**: In order to get the same probabilities as the ``fastText`` +binary, you have to add a newline (``\n``) at the end of each string. + +If your test data is stored inside a file, use this: .. code:: python - >>> model.predict_proba_single('first sentence', k=2) - [('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)] + >>> model.predict_proba_file('/path/to/test.txt', k=2) + [[('LABEL1', 0.99609375), ('LABEL3', 1.953126549381068e-08)], [('LABEL2', 1.0), ('LABEL3', 1.953126549381068e-08)]] Normalized probabilities @@ -426,9 +432,9 @@ parameter in all the methods that output probabilities .. code:: python - >>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified', k=None)) + >>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified\n', k=None)) 0.9785203068801335 - >>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified', k=None, normalized=True)) + >>> sum(proba for label, proba in model.predict_proba_single('this is a sentence that needs to be classified\n', k=None, normalized=True)) 0.9999999999999898 Labels only @@ -438,22 +444,25 @@ If you have a list of strings (or an iterable object), use this: .. code:: python - >>> model.predict(['first sentence', 'second sentence'], k=2) + >>> model.predict(['first sentence\n', 'second sentence\n'], k=2) [['LABEL1', 'LABEL3'], ['LABEL2', 'LABEL3']] -If your test data is stored inside a file, use this: +If you want to test a single string, use this: .. code:: python - >>> model.predict_file('/path/to/test.txt', k=2) - [['LABEL1', 'LABEL3'], ['LABEL2', 'LABEL3']] + >>> model.predict_single('first sentence\n', k=2) + ['LABEL1', 'LABEL3'] -If you want to test a single string, use this: +**WARNING**: In order to get the same probabilities as the ``fastText`` +binary, you have to add a newline (``\n``) at the end of each string. + +If your test data is stored inside a file, use this: .. code:: python - >>> model.predict_single('first sentence', k=2) - ['LABEL1', 'LABEL3'] + >>> model.predict_file('/path/to/test.txt', k=2) + [['LABEL1', 'LABEL3'], ['LABEL2', 'LABEL3']] Quantization ^^^^^^^^^^^^