Ejemplo n.º 1
0
 def test_e_spell_guessing_off(self):
     self.p = Parser(spell_guess=False)
     result = self.p.parse_sent("I love going to shoop.")
     self.assertEqual(result[0].words, [
         'LEFT-WALL', 'I.p', 'love.v', 'going.v', 'to.r', 'shoop[?].v', '.',
         'RIGHT-WALL'
     ])
Ejemplo n.º 2
0
 def test_d_morphology(self):
     self.p = Parser(lang='ru', display_morphology=True)
     self.assertEqual(
         self.p.parse_sent('вверху плыли редкие облачка.')[0].words, [
             'LEFT-WALL', 'вверху.e', 'плы.=', '=ли.vnndpp', 'ре.=',
             '=дкие.api', 'облачк.=', '=а.ndnpi', '.', 'RIGHT-WALL'
         ])
Ejemplo n.º 3
0
 def test_d_spell_guessing_on(self):
     self.p = Parser(spell_guess=True)
     result = self.p.parse_sent("I love going to shoop.")
     resultx = result[0] if result else []
     for resultx in result:
         if resultx.words[5] == 'shop[~].v':
             break
     self.assertEqual(resultx.words if resultx else [], [
         'LEFT-WALL', 'I.p', 'love.v', 'going.v', 'to.r', 'shop[~].v', '.',
         'RIGHT-WALL'
     ])
Ejemplo n.º 4
0
 def test_that_parser_can_be_destroyed_when_linkages_still_exist(self):
     """
     If the parser is deleted before the associated swig objects
     are, there will be bad pointer dereferences (as the swig
     objects will be pointing into freed memory).  This test ensures
     that parsers can be created and deleted without regard for
     the existence of PYTHON Linkage objects
     """
     p = Parser()
     linkages = p.parse_sent('This is a sentence.')
     del p
Ejemplo n.º 5
0
 def setUp(self):
     self.p = Parser(lang='ru')
Ejemplo n.º 6
0
 def setUp(self):
     self.p = Parser(lang='lt')
Ejemplo n.º 7
0
 def setUp(self):
     self.p = Parser(lang='de')
Ejemplo n.º 8
0
 def setUp(self):
     self.p = Parser(lang='en')
Ejemplo n.º 9
0
 def setUp(self):
     self.p = Parser()
Ejemplo n.º 10
0
 def test_specifying_options_when_instantiating_parser(self):
     p = Parser(linkage_limit=10)
     self.assertEqual(
         clg.parse_options_get_linkage_limit(p.parse_options._po), 10)
Ejemplo n.º 11
0
#! /usr/bin/env python
# -*- coding: utf8 -*-
#
# Link Grammar example usage
#
# May need to set the PYTHONPATH to get this to work:
# PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/dist-packages/link-grammar
# or something similar ...
#
from linkgrammar import Parser, Linkage, ParseOptions, Link

po = ParseOptions()

# English is the default language
p = Parser()
linkages = p.parse_sent("This is a test.")
print "English: found ", len(linkages), "linkages"
for linkage in linkages:
    print linkage.diagram

# Russian
p = Parser(lang='ru')
linkages = p.parse_sent("это большой тест.")
print "Russian: found ", len(linkages), "linkages"
for linkage in linkages:
    print linkage.diagram

# Turkish
p = Parser(lang='tr')
linkages = p.parse_sent("çok şişman adam geldi")
print "Turkish: found ", len(linkages), "linkages"