コード例 #1
0
 def test_svo_14(self):
     tok = nlp("the boy raced the girl who had a hat that had spots.")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('the boy', 'raced',
                        'the girl'), ('who', 'had',
                                      'a hat'), ('a hat', 'had', 'spots')})
コード例 #2
0
 def test_svo_1(self):
     tok = nlp("the annoying person that was my boyfriend hit me")
     svos = findSVOs(tok)
     printDeps(tok)  # just show what printDeps() does
     self.assertTrue(
         set(svos) == {('the annoying person', 'was',
                        'my boyfriend'), ('the annoying person', 'hit',
                                          'me')})
コード例 #3
0
 def test_svo_11(self):
     tok = nlp(
         "because he hit me and also made me so angry I wanted to kill him with a hammer."
     )
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', 'hit', 'me'), ('I', 'kill', 'him')})
コード例 #4
0
 def test_svo_2(self):
     tok = 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."
     )
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('I', '!have', 'other financial assistance available'
                        ), ('he', '!provide', 'support')})
コード例 #5
0
 def test_svo_6(self):
     tok = nlp(
         "I have no other financial assistance available, and he certainly won't provide support."
     )
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('I', '!have', 'other financial assistance available'
                        ), ('he', '!provide', 'support')})
コード例 #6
0
 def test_svo_13(self):
     tok = nlp("he and his brother shot me and my sister")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', 'shot', 'me'), (
             'he', 'shot',
             'my sister'), ('his brother', 'shot',
                            'me'), ('his brother', 'shot', 'my sister')})
コード例 #7
0
 def test_svo_8(self):
     tok = nlp("he is an evil man that hurt my child and sister")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', 'is',
                        'an evil man'), (
                            'an evil man', 'hurt',
                            'my child'), ('an evil man', 'hurt', 'sister')})
コード例 #8
0
 def test_svo_25(self):
     tok = 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."
     )
     # printDeps(tok)
     svos = findSVOs(tok)
     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_7(self):
     tok = nlp("he did not kill me")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(set(svos) == {('he', '!kill', 'me')})
コード例 #10
0
 def test_svo_24(self):
     tok = nlp("lessons were taken by me")
     # printDeps(tok)
     svos = findSVOs(tok)
     self.assertTrue(set(svos) == {('me', 'take', 'lessons')})
コード例 #11
0
 def test_svo_4(self):
     tok = nlp("They ate the pizza with anchovies.")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(set(svos) == {('They', 'ate', 'the pizza')})
コード例 #12
0
 def test_svo_16(self):
     tok = nlp("he didn't spit on me")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(set(svos) == {('he', '!spit', 'me')})
コード例 #13
0
 def test_svo_3(self):
     tok = nlp("I don't have other assistance")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(set(svos) == {('I', '!have', 'other assistance')})
コード例 #14
0
 def test_svo_21(self):
     tok = nlp("he didn't spit on me nor my child")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(
         set(svos) == {('he', '!spit', 'me'), ('he', '!spit', 'my child')})
コード例 #15
0
 def test_svo_22(self):
     tok = nlp("he beat and hurt me")
     # printDeps(tok)
     svos = findSVOs(tok)
     self.assertTrue(
         set(svos) == {('he', 'beat', 'me'), ('he', 'hurt', 'me')})
コード例 #16
0
 def test_svo_23(self):
     tok = nlp("I was beaten by him")
     # printDeps(tok)
     svos = findSVOs(tok)
     self.assertTrue(set(svos) == {('him', 'beat', 'I')})
コード例 #17
0
 def test_svo_9(self):
     tok = nlp(
         "he told me i would die alone with nothing but my career someday")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(set(svos) == {('he', 'told', 'me')})
コード例 #18
0
from svoext.subject_verb_object_extract import findSVOs, nlp

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."

tokens1 = nlp(str1)
svos1 = findSVOs(tokens1)
print("\n1")
print(str1)
print(svos1)

tokens2 = nlp(str2)
svos2 = findSVOs(tokens2)
print("\n2")
print(str2)
print(svos2)

tokens3 = nlp(str3)
svos3 = findSVOs(tokens3)
print("\n3")
print(str3)
print(svos3)
コード例 #19
0
 def test_svo_10(self):
     tok = nlp("I wanted to kill him with a hammer.")
     svos = findSVOs(tok)
     # printDeps(tok)
     self.assertTrue(set(svos) == {('I', 'kill', 'him')})