Пример #1
0
 def test_svo_14(self):
     svos = findSVOs(
         nlp, "the boy raced the girl who had a hat that had spots.")
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('the boy', 'raced',
                        'the girl'), ('who', 'had',
                                      'a hat'), ('a hat', 'had', 'spots')})
Пример #2
0
 def test_svo_13(self):
     svos = findSVOs(nlp, "he and his brother shot me and my sister")
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', 'shot', 'me'), (
             'he', 'shot',
             'my sister'), ('his brother', 'shot',
                            'me'), ('his brother', 'shot', 'my sister')})
Пример #3
0
 def test_svo_11(self):
     svos = findSVOs(
         nlp,
         "because he hit me and also made me so angry I wanted to kill him with a hammer."
     )
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', 'hit', 'me'), ('I', 'kill', 'him')})
Пример #4
0
 def test_svo_1(self):
     print("i am here")
     svos = findSVOs(nlp,
                     "the annoying person that was my boyfriend hit me")
     self.assertTrue(
         set(svos) == {('the annoying person', 'was',
                        'my boyfriend'), ('the annoying person', 'hit',
                                          'me')})
Пример #5
0
 def test_svo_8(self):
     svos = findSVOs(nlp, "he is an evil man that hurt my child and sister")
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', 'is',
                        'an evil man'), (
                            'an evil man', 'hurt',
                            'my child'), ('an evil man', 'hurt', 'sister')})
Пример #6
0
 def test_svo_2(self):
     svos = findSVOs(
         nlp,
         "making $12 an hour? where am i going to go? I have no other financial assistance available and he certainly won't provide support."
     )
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('I', '!have', 'other financial assistance available'
                        ), ('he', '!provide', 'support')})
Пример #7
0
 def test_svo_6(self):
     svos = findSVOs(
         nlp,
         "I have no other financial assistance available, and he certainly won't provide support."
     )
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('I', '!have', 'other financial assistance available'
                        ), ('he', '!provide', 'support')})
Пример #8
0
 def test_svo_25(self):
     # printDeps(tok)
     svos = findSVOs(
         nlp,
         "Seated in Mission Control, Chris Kraft neared the end of a tedious Friday afternoon as he monitored a seemingly interminable ground test of the Apollo 1 spacecraft."
     )
     self.assertTrue(
         set(svos) ==
         {('Chris Kraft', 'neared',
           'the end of a tedious Friday afternoon'),
          ('he', 'monitored',
           'a interminable ground test of the Apollo spacecraft')})
Пример #9
0
 def test_svo_24(self):
     # printDeps(tok)
     svos = findSVOs(nlp, "lessons were taken by me")
     self.assertTrue(set(svos) == {('me', 'take', 'lessons')})
Пример #10
0
 def test_svo_16(self):
     svos = findSVOs(nlp, "he didn't spit on me")
     # printDeps(tok)
     self.assertTrue(set(svos) == {('he', '!spit', 'me')})
Пример #11
0
 def test_svo_7(self):
     svos = findSVOs(nlp, "he did not kill me")
     # printDeps(tok)
     self.assertTrue(set(svos) == {('he', '!kill', 'me')})
Пример #12
0
 def test_svo_3(self):
     svos = findSVOs(nlp, "I don't have other assistance")
     # printDeps(tok)
     self.assertTrue(set(svos) == {('I', '!have', 'other assistance')})
Пример #13
0
 def test_svo_4(self):
     svos = findSVOs(nlp, "They ate the pizza with anchovies.")
     # printDeps(tok)
     self.assertTrue(set(svos) == {('They', 'ate', 'the pizza')})
Пример #14
0
 def test_svo_21(self):
     svos = findSVOs(nlp, "he didn't spit on me nor my child")
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', '!spit', 'me'), ('he', '!spit', 'my child')})
Пример #15
0
 def test_svo_22(self):
     # printDeps(tok)
     svos = findSVOs(nlp, "he beat and hurt me")
     self.assertTrue(
         set(svos) == {('he', 'beat', 'me'), ('he', 'hurt', 'me')})
Пример #16
0
from svo_extraction.subject_verb_object_extract import findSVOs, get_spacy_nlp_sm_model

str1 = "Then there’s a development setback on top of that that pushes you even further back."
str2 = "And that goes with that we’re going to do things differently, but we haven’t done that yet."
str3 = "Seated in Mission Control, Chris Kraft neared the end of a tedious Friday afternoon as he monitored a " \
       "seemingly interminable ground test of the Apollo 1 spacecraft."

nlp = get_spacy_nlp_sm_model()
svos = findSVOs(nlp, str1, removepunctuation=True, uncontracttext=True)
print(svos)

svos = findSVOs(nlp, str2, removepunctuation=True, uncontracttext=True)
print(svos)

svos = findSVOs(nlp, str3, removepunctuation=True, uncontracttext=True)
print(svos)

print("*" * 20)

svos = findSVOs(nlp, str1, removepunctuation=False, uncontracttext=False)
print(svos)

svos = findSVOs(nlp, str2, removepunctuation=False, uncontracttext=False)
print(svos)

svos = findSVOs(nlp, str3, removepunctuation=False, uncontracttext=False)
print(svos)
Пример #17
0
 def test_svo_9(self):
     svos = findSVOs(
         nlp,
         "he told me i would die alone with nothing but my career someday")
     # printDeps(tok)
     self.assertTrue(set(svos) == {('he', 'told', 'me')})
Пример #18
0
 def test_svo_23(self):
     # printDeps(tok)
     svos = findSVOs(nlp, "I was beaten by him")
     self.assertTrue(set(svos) == {('him', 'beat', 'I')})
Пример #19
0
 def test_svo_10(self):
     svos = findSVOs(nlp, "I wanted to kill him with a hammer.")
     # printDeps(tok)
     self.assertTrue(set(svos) == {('I', 'kill', 'him')})
Пример #20
0
from svo_extraction.subject_verb_object_extract import findSVOs, get_spacy_nlp_sm_model
from svo_extraction.graph import SVONetwork
import spacy

nlp = spacy.load('en_core_web_md')
text = "The bee-eaters are near passerine birds of the family Meropidae, containing three genera and twenty-seven species. Most species are found in Africa and Asia, with a few in southern Europe, Australia, and New Guinea. They are characterised by richly coloured plumage and slender bodies, and usually by elongated central tail feathers. All have long down-turned bills and medium to long wings, which may be pointed or round. They predominantly eat flying insects, caught on the wing from an open perch. Most bee-eaters are gregarious, forming colonies and nesting in burrows. The eggs are white, with typically five to the clutch. Most species are monogamous, and both parents care for the young, sometimes with assistance from related birds in the colony. Bee-eaters may be killed by raptors; their nests are raided by rodents and snakes, and they can carry various parasites. Some species are adversely affected by human activity or"
svos = findSVOs(nlp, text, removepunctuation=True, uncontracttext=True)
print(svos)
net = SVONetwork(svos)
#mygraph = net.createSVOGraph(direction="indirect", save_image=True, name_image="myimage.png")
#mygraph = net.createSVOGraph(direction="direct", save_image=True, name_image="myimage.png")
mygraph = net.createSVOGraph(direction="direct",
                             save_image=False,
                             display_grap=True)