- spaCy - Discussion
- spaCy - Useful Resources
- spaCy - Quick Guide
- Updating Neural Network Model
- Training Neural Network Model
- spaCy - Container Lexeme Class
- spaCy - Span Class Properties
- spaCy - Container Span Class
- spaCy - Token Properties
- spaCy - Container Token Class
- Doc Class ContextManager and Property
- spaCy - Containers
- spaCy - Compatibility Functions
- spaCy - Utility Functions
- spaCy - Visualization Function
- spaCy - Top-level Functions
- spaCy - Command Line Helpers
- spaCy - Architecture
- spaCy - Models and Languages
- spaCy - Getting Started
- spaCy - Introduction
- spaCy - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
spaCy - Compatibipty Functions
As we know that all Python codes are written in an intersection of Python2 and Python3 which may be not that fine in Python. But, that is quite easy in Cython.
The compatibipty functions in spaCy along with its description are psted below −
Compatibipty Function | Description |
---|---|
Spacy.compat() | Deals with Python or platform compatibipty. |
compat.is_config() | Checks whether a specific configuration of Python version and operating system (OS) matches the user’s setup. |
Spacy.compat()
It is the function that has all the logic deapng with Python or platform compatibipty. It is distinguished from other built-in function by suffixed with an underscore. For example, unicode_.
Some examples are given in the table below −
NAME | PYTHON 2 | PYTHON 3 |
---|---|---|
compat.bytes_ | str | bytes |
compat.unicode_ | unicode | str |
compat.basestring_ | basestring | str |
compat.input_ | raw_input | input |
compat.path2str | str(path) with .decode( utf8 ) | str(path) |
Example
An example of spacy.compat() function is as follows −
import spacy from spacy.compat import unicode_ compat_unicode = unicode_("This is Tutorialspoint") compat_unicode
Output
Upon execution, you will receive the following output −
This is Tutorialspoint
compat.is_config()
It is the function that checks whether a specific configuration of Python version and operating system (OS) matches the user’s setup. This function is mostly used for displaying the targeted error messages.
Arguments
The table below explains its arguments −
NAME | TYPE | DESCRIPTION |
---|---|---|
python2 | Bool | Whether spaCy is executed with Python 2.x or not. |
python3 | Bool | Whether spaCy is executed with Python 3.x or not. |
windows | Bool | Whether spaCy is executed on Windows or not. |
pnux | Bool | Whether spaCy is executed on Linux or not. |
OS X | Bool | Whether spaCy is executed on OS X or not. |
Example
An example of compat.is_config() function is as follows −
import spacy from spacy.compat import is_config if is_config(python3=True, windows=True): print("Spacy is executing on Python 3 on Windows.")
Output
Upon execution, you will receive the following output −
Spacy is executing on Python 3 on Windows.Advertisements