All Projects → livingbio → syntaxnet_wrapper

livingbio / syntaxnet_wrapper

Licence: MIT license
A Python Wrapper for Google SyntaxNet

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to syntaxnet wrapper

Crycompare
Python wrapper for CryptoCompare public API
Stars: ✭ 70 (+105.88%)
Mutual labels:  python-wrapper
Zenpy
Python wrapper for the Zendesk API
Stars: ✭ 222 (+552.94%)
Mutual labels:  python-wrapper
syntaxnet
Syntaxnet Parsey McParseface wrapper for POS tagging and dependency parsing
Stars: ✭ 77 (+126.47%)
Mutual labels:  syntaxnet
Pylibfreenect2
A python interface for libfreenect2
Stars: ✭ 117 (+244.12%)
Mutual labels:  python-wrapper
Pydp
A python wrapper for https://github.com/google/differential-privacy
Stars: ✭ 178 (+423.53%)
Mutual labels:  python-wrapper
Image2text
📋 Python wrapper to grab text from images and save as text files using Tesseract Engine
Stars: ✭ 243 (+614.71%)
Mutual labels:  python-wrapper
Python Documentcloud
A deprecated Python wrapper for the DocumentCloud API
Stars: ✭ 60 (+76.47%)
Mutual labels:  python-wrapper
gpyfft
python wrapper for the OpenCL FFT library clFFT
Stars: ✭ 52 (+52.94%)
Mutual labels:  python-wrapper
Fbrecog
An unofficial python wrapper for the Facebook face recognition endpoint
Stars: ✭ 184 (+441.18%)
Mutual labels:  python-wrapper
MemePolice bot
This is a bot for r/PewdiepieSubmissions. Moderate harmful submissions by applying OCR on graphical content
Stars: ✭ 26 (-23.53%)
Mutual labels:  python-wrapper
Py Solc
Python wrapper around the solc Solidity compiler.
Stars: ✭ 126 (+270.59%)
Mutual labels:  python-wrapper
Webexteamssdk
Work with the Webex Teams APIs in native Python!
Stars: ✭ 168 (+394.12%)
Mutual labels:  python-wrapper
python-sutime
Python wrapper for Stanford CoreNLP's SUTime
Stars: ✭ 143 (+320.59%)
Mutual labels:  python-wrapper
Python Duckling
Python wrapper for wit.ai's Duckling Clojure library
Stars: ✭ 114 (+235.29%)
Mutual labels:  python-wrapper
psycopgr
A Python wrapper of pgRouting for routing from nodes to nodes on real map.
Stars: ✭ 24 (-29.41%)
Mutual labels:  python-wrapper
Domonit
A Deadly Simple Docker Monitoring Wrapper For Docker API
Stars: ✭ 67 (+97.06%)
Mutual labels:  python-wrapper
Tosdatabridge
A collection of resources for pulling real-time streaming data off of TDAmeritrade's ThinkOrSwim(TOS) platform; providing C, C++, Java and Python interfaces.
Stars: ✭ 229 (+573.53%)
Mutual labels:  python-wrapper
PySiddhi
Python wrapper for Siddhi engine
Stars: ✭ 22 (-35.29%)
Mutual labels:  python-wrapper
pyduktape
Embed the Duktape JS interpreter in Python
Stars: ✭ 77 (+126.47%)
Mutual labels:  python-wrapper
spdlog-python
python wrapper around C++ spdlog ([email protected]:gabime/spdlog.git)
Stars: ✭ 46 (+35.29%)
Mutual labels:  python-wrapper

A Python Wrapper for Google SyntaxNet

Installation

Prerequisites

Install OpenJDK8.

add-apt-repository -y ppa:openjdk-r/ppa
apt-get -y update
apt-get -y install openjdk-8-jdk

Install bazel and include bazel in $PATH.

Note: Only bazel 0.4.3 is runnable. bazel 0.4.4 may cause errors.

wget https://github.com/bazelbuild/bazel/releases/download/0.4.3/bazel-0.4.3-installer-linux-x86_64.sh
chmod +x bazel-0.4.3-installer-linux-x86_64.sh
./bazel-0.4.3-installer-linux-x86_64.sh --user
rm bazel-0.4.3-installer-linux-x86_64.sh
export PATH="$PATH:$HOME/bin"

Install system package dependencies.

apt-get -y install swig unzip

Install Python packages

Note: Current version of syntaxnet must be used with tensorflow r1.0.

pip install tensorflow protobuf asciitree mock

Start Installing

pip install git+ssh://[email protected]/livingbio/syntaxnet_wrapper.git#egg=syntaxnet_wrapper

If installation failed...

Execute test.sh, you should see following outputs:

1       Bob     _       PROPN   NNP     Number=Sing|fPOS=PROPN++NNP     2       nsubj   _       _
2       brought _       VERB    VBD     Mood=Ind|Tense=Past|VerbForm=Fin|fPOS=VERB++VBD 0       ROOT    _ _
3       the     _       DET     DT      Definite=Def|PronType=Art|fPOS=DET++DT  4       det     _       _
4       pizza   _       NOUN    NN      Number=Sing|fPOS=NOUN++NN       2       dobj    _       _
5       to      _       ADP     IN      fPOS=ADP++IN    6       case    _       _
6       Alice.  _       PROPN   NNP     Number=Sing|fPOS=PROPN++NNP     2       nmod    _       _

1       球      _       PROPN   NNP     fPOS=PROPN++NNP 4       nsubj   _       _
2       從      _       ADP     IN      fPOS=ADP++IN    3       case    _       _
3       天上    _       NOUN    NN      fPOS=NOUN++NN   4       nmod    _       _
4       掉      _       VERB    VV      fPOS=VERB++VV   0       ROOT    _       _
5       下來    _       VERB    VV      fPOS=VERB++VV   4       mark    _       _

球 從天 上 掉 下 來

If the outputs are correct, problems are caused by the wrapper. If the outputs are wrong, compilation of syntaxnet may be failed.

Usage

from syntaxnet_wrapper import tagger, parser

print tagger['en'].query('this is a good day', returnRaw=True)
# 1       this    _       DET     DT      _       0       _       _       _
# 2       is      _       VERB    VBZ     _       0       _       _       _
# 3       a       _       DET     DT      _       0       _       _       _
# 4       good    _       ADJ     JJ      _       0       _       _       _
# 5       day     _       NOUN    NN      _       0       _       _       _
tagger['en'].query('this is a good day')  # in default, return splitted text

print parser['en'].query('Alice drove down the street in her car', returnRaw=True)
# 1       Alice   _       NOUN    NNP     _       2       nsubj   _       _
# 2       drove   _       VERB    VBD     _       0       ROOT    _       _
# 3       down    _       ADP     IN      _       2       prep    _       _
# 4       the     _       DET     DT      _       5       det     _       _
# 5       street  _       NOUN    NN      _       3       pobj    _       _
# 6       in      _       ADP     IN      _       2       prep    _       _
# 7       her     _       PRON    PRP$    _       8       poss    _       _
# 8       car     _       NOUN    NN      _       6       pobj    _       _

# use Chinese model
print tagger['zh'].query(u'今天 天氣 很 好', returnRaw=True)
# 1       今天    _       NOUN    NN      fPOS=NOUN++NN   0       _       _       _
# 2       天氣    _       NOUN    NN      fPOS=NOUN++NN   0       _       _       _
# 3       很      _       ADV     RB      fPOS=ADV++RB    0       _       _       _
# 4       好      _       ADJ     JJ      fPOS=ADJ++JJ    0       _       _       _

print parser['zh'].query(u'今天 天氣 很 好', returnRaw=True)
# 1       今天    _       NOUN    NN      fPOS=NOUN++NN   4       nmod:tmod       _       _
# 2       天氣    _       NOUN    NN      fPOS=NOUN++NN   4       nsubj   _       _
# 3       很      _       ADV     RB      fPOS=ADV++RB    4       advmod  _       _
# 4       好      _       ADJ     JJ      fPOS=ADJ++JJ    0       ROOT    _       _

Language Selection

The default model is 'English-Parsey'. This is announced by Google on May, 2016. Other models, includes 'English', are trained by Universal Dependencies, announced by Google on August, 2016.

from syntaxnet_wrapper import language_code_to_model_name
language_code_to_model_name
# {'ar': 'Arabic',
#  'bg': 'Bulgarian',
#  'ca': 'Catalan',
#  'cs': 'Czech',
#  'da': 'Danish',
#  'de': 'German',
#  'el': 'Greek',
#  'en': 'English-Parsey',
#  'en-uni': 'English',
#  'es': 'Spanish',
#  'et': 'Estonian',
#  'eu': 'Basque',
#  'fa': 'Persian',
#  'fi': 'Finnish',
#  'fr': 'French',
#  'ga': 'Irish',
#  'gl': 'Galician',
#  'hi': 'Hindi',
#  'hr': 'Croatian',
#  'hu': 'Hungarian',
#  'id': 'Indonesian',
#  'it': 'Italian',
#  'iw': 'Hebrew',
#  'kk': 'Kazakh',
#  'la': 'Latin',
#  'lv': 'Latvian',
#  'nl': 'Dutch',
#  'no': 'Norwegian',
#  'pl': 'Polish',
#  'pt': 'Portuguese',
#  'ro': 'Romanian',
#  'ru': 'Russian',
#  'sl': 'Slovenian',
#  'sv': 'Swedish',
#  'ta': 'Tamil',
#  'tr': 'Turkish',
#  'zh': 'Chinese',
#  'zh-cn': 'Chinese',
#  'zh-tw': 'Chinese'}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].