Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| MaltParser 1.6
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.maltparser
Class MaltParserService

    java.lang.Object
      org.maltparser.MaltParserService

    public class MaltParserService

extends Object

The purpose of MaltParserService is to easily write third-party programs that uses MaltParser. There are two ways to call the MaltParserService: 1. By running experiments, which allow other programs to train a parser model or parse with a parser model. IO-handling is done by MaltParser. 2. By first initialize a parser model and then call the method parse() with an array of tokens that MaltParser parses. IO-handling of the sentence is done by the third-party program. How to use MaltParserService, please see the examples provided in the directory 'examples/apiexamples/srcex'

Author:
  Johan Hall

Constructor Summary
`MaltParserService()` Creates a MaltParserService with the option container 0
`MaltParserService(int optionContainer)` Creates a MaltParserService with the specified option container.

Method Summary
`static String` | `getMaltJarPath()` Returns the path of malt.jar file
`int` | `getOptionContainer()` Returns the option container index
`void` | `initializeParserModel(String commandLine)` Initialize a parser model that later can by used to parse sentences.
`DependencyStructure` | `parse(String[] tokens)` Parses an array of tokens and returns a dependency structure.
`String[]` | `parseTokens(String[] tokens)` Same as parse(String[] tokens), but instead it returns an array of tokens with a head index and a dependency type at the end of string
`void` | `runExperiment(String commandLine)` Runs a MaltParser experiment.
`void` | `terminateParserModel()` Terminates the parser model.
`DependencyStructure` | `toDependencyStructure(String[] tokens)` Converts an array of tokens to a dependency structure
`DependencyStructure` | `toDependencyStructure(String[] tokens, String dataFormatFileName)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MaltParserService

    public MaltParserService()
                      throws MaltChainedException

  Creates a MaltParserService with the option container 0

  Throws:
    `MaltChainedException`

### MaltParserService

    public MaltParserService(int optionContainer)
                      throws MaltChainedException

  Creates a MaltParserService with the specified option container. To use different option containers allows the calling program to load several parser models or several experiments. The option management in MaltParser uses the singleton design pattern, which means that there can only be one instance of the option manager. To be able to have several parser models or experiments at same time please use different option containers.

  Parameters:
    `optionContainer` - an integer from 0 to max value of data type Integer
  Throws:
    `MaltChainedException`

Method Detail

### runExperiment

    public void runExperiment(String commandLine)
                       throws MaltChainedException

  Runs a MaltParser experiment. The experiment is controlled by a commandLine string, please see the documentation of MaltParser to see all available options.

  Parameters:
    `commandLine` - a commandLine string that controls the MaltParser.
  Throws:
    `MaltChainedException`

### initializeParserModel

    public void initializeParserModel(String commandLine)
                               throws MaltChainedException

  Initialize a parser model that later can by used to parse sentences. MaltParser is controlled by a commandLine string, please see the documentation of MaltParser to see all available options.

  Parameters:
    `commandLine` - a commandLine string that controls the MaltParser
  Throws:
    `MaltChainedException`

### parse

    public DependencyStructure parse(String[] tokens)
                              throws MaltChainedException

  Parses an array of tokens and returns a dependency structure. Note: To call this method requires that a parser model has been initialized by using the initializeParserModel().

  Parameters:
    `tokens` - an array of tokens
  Returns:
    a dependency structure
  Throws:
    `MaltChainedException`

### toDependencyStructure

    public DependencyStructure toDependencyStructure(String[] tokens)
                                              throws MaltChainedException

  Converts an array of tokens to a dependency structure

  Parameters:
    `tokens` - an array of tokens
  Returns:
    a dependency structure
  Throws:
    `MaltChainedException`

### toDependencyStructure

    public DependencyStructure toDependencyStructure(String[] tokens,
                                                     String dataFormatFileName)
                                              throws MaltChainedException

  Throws:
    `MaltChainedException`

### parseTokens

    public String[] parseTokens(String[] tokens)
                         throws MaltChainedException

  Same as parse(String[] tokens), but instead it returns an array of tokens with a head index and a dependency type at the end of string

  Parameters:
    `tokens` - an array of tokens to parse
  Returns:
    an array of tokens with a head index and a dependency type at the end of string
  Throws:
    `MaltChainedException`

### terminateParserModel

    public void terminateParserModel()
                              throws MaltChainedException

  Terminates the parser model.

  Throws:
    `MaltChainedException`

### getOptionContainer

    public int getOptionContainer()

  Returns the option container index

  Returns:
    the option container index

### getMaltJarPath

    public static String getMaltJarPath()

  Returns the path of malt.jar file

  Returns:
    the path of malt.jar file

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| MaltParser 1.6
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2007-2011 Johan Hall, Jens Nilsson and Joakim Nivre.