Skip to content

allendecid/Arabic_Parser_NLTK

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Arabic_Parser_NLTK

Arabic Parser Using Stanford API interface with python nltk

What is Paser ?

A natural language parser is a program that works out the grammatical structure of sentences, for instance, which groups of words go together (as “phrases”) and which words are the subject or object of a verb. Probabilistic parsers use knowledge of language gained from hand-parsed sentences to try to produce the most likely analysis of new sentences. These statistical parsers still make some mistakes, but commonly work rather well. Their development was one of the biggest breakthroughs in natural language processing in the 1990s.

What is nltk ?

NLTK is the most famous Python Natural Language Processing Toolkit, NLTK is a leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning.

Requirements

How to use ?

Once you have downloaded Stanford API, it's a little tricky but you can run the arabic parser successfuly.

code snippet example:

  • model_path: pretrained model you can find it in the stanford-arabic-corenlp-yyyy-mm-dd-models/edu/stanford/nlp/models/lexparser/arabicFactored.ser.gz

  • path_to_jar: path_to/stanford-parser-full-yyyy-mm-dd/stanford-parser.jar

  • path_to_models_jar: path_to/stanford-parser-full-yyyy-mm-dd/stanford-parser-xx.xx.xx-models.jar'

      from Parser import Parser
      parser = Parser(model_path=ar_model_path, path_to_jar=my_path_to_jar, path_to_models_jar=my_path_to_models_jar)
      result = parser.parse_sentence(u'ذهبت الى منزلى الذى كان بعيداً بعد الفجر')
      print(result)
      
      >>> [Tree('ROOT', [Tree('S', [Tree('VP', [Tree('VBD', ['ذهبت']), Tree('PP', [Tree('IN', ['الى']), Tree('NP'
      >>> [Tree('NN'['منزلى']), Tree('SBAR', [Tree('WHNP', [Tree('WP', ['الذى'])]), Tree('S', [Tree('VP', [Tree('VBD', ['كان']),
      >>> Tree('NP', [Tree('JJ', ['بعيدا'])]), Tree('NP', [Tree('NN', ['بعد']), Tree('NP', [Tree('DTNN'
      >>> ['الفجر'])])])])])])])])])])])]

Congrats !! you can friendly use the parser now

NOTES

Java is not required by nltk, however some third party software may be dependent on it. NLTK finds the java binary via the system PATH environment variable, or through JAVAHOME or JAVA_HOME. To search for java binaries (jar files), nltk checks the java CLASSPATH variable, however there are usually independent environment variables which are also searched for each dependency individually.

For Windows Users

  • you Java to set your HOMEPATH variable must be set in Environemt variables otherwise you will get many errors
    • Here how you can set it easily

Linux(Ubuntu) Users

  • you have to set your CLASSPATH variable must be set in Environemt variables otherwise you will get many errors
    • It is best to use the package manager to install java.
    • Here how you can set it easily for MacOSx or ubuntu

It's easy and available for everyone but usually installing third party software is boring and tricky and you can check if you want to know how nltk discover third party software

Here all Stanford official work with NLP group you can check it if you want to learn more Here NLTK official documentation

About

Arabic Parser Using Stanford API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%