Test Cases of Syntax


In [1]:
import Syntax as sx
# Carmella is kind of your typical teen.
sentence = [["1790", "0", "0", "0", "0", "8", "S", "2", "Carmella", "Carmella", "Carmella", "NNP", 
             "PERSON", "nsubj", "false", "11"],
            ["1790", "0", "0", "1", "9", "11", "S", "2", "is", "is", "be", "VBZ", 
             "O", "cop", "false", "-1"],
            ["1790", "0", "0", "2", "12", "16", "S", "-1", "kind", "kind", "kind", "NN", 
             "O", "null", "false", "-1"],
            ["1790", "0", "0", "3", "17", "19", "S", "2", "of", "of", "of", "IN", 
             "O", "prep", "false", "-1"],
            ["1790", "0", "0", "4", "20", "24", "S", "6", "your", "your", "you", "PRP$", 
             "O", "poss", "false", "-1"],
            ["1790", "0", "0", "5", "25", "32", "S", "6", "typical", "typical", "typical", "JJ", 
             "O", "amod", "false", "-1"],
            ["1790", "0", "0", "6", "33", "37", "", "3", "teen", "teen", "teen", "NN", 
             "O", "pobj", "false", "-1"],
            ["1790", "0", "0", "7", "37", "38", "S", "2", ".", ".", ".", ".", 
             "O", "punct", "false", "-1"]]
syn = sx.SyntaxTree()
syn.creat(sentence)
print syn.extract_label(11)
print syn.extract_label_with_info(11)
print syn.extract_des(11)
print syn.extract_action(11)
print syn.extract_full_action(11)


['kind']
['be kind of']
['kind']
['kind']
['PERSON', 'kind']

In [2]:
sentence = [["1790", "0", "1", "8", "39", "42", "", "12", "She", "She", "she", "PRP", "O", "nsubj", "false", "11"],
["1790", "0", "1", "9", "42", "44", "S", "12", "'s", "'s", "be", "VBZ", "O", "cop", "false", "-1"],
["1790", "0", "1", "10", "45", "52", "SS", "12", "sixteen", "sixteen", "sixteen", "CD", "NUMBER", "num", "false", "-1"],
["1790", "0", "1", "11", "54", "57", "S", "12", "the", "the", "the", "DT", "O", "det", "false", "-1"],
["1790", "0", "1", "12", "58", "62", "S", "-1", "baby", "baby", "baby", "NN", "O", "null", "false", "-1"],
["1790", "0", "1", "13", "63", "65", "S", "12", "of", "of", "of", "IN", "O", "prep", "false", "-1"],
["1790", "0", "1", "14", "66", "69", "S", "15", "the", "the", "the", "DT", "O", "det", "false", "-1"],
["1790", "0", "1", "15", "70", "76", "S", "13", "family", "family", "family", "NN", "O", "pobj", "false", "-1"],
["1790", "0", "1", "16", "77", "81", "S", "12", "with", "with", "with", "IN", "O", "prep", "false", "-1"],
["1790", "0", "1", "17", "82", "84", "S", "20", "an", "an", "a", "DT", "O", "det", "false", "-1"],
["1790", "0", "1", "18", "85", "93", "S", "20", "annoying", "annoying", "annoying", "JJ", "O", "amod", "false", "-1"],
["1790", "0", "1", "19", "94", "97", "S", "20", "big", "big", "big", "JJ", "O", "amod", "false", "-1"],
["1790", "0", "1", "20", "98", "104", "S", "16", "sister", "sister", "sister", "NN", "O", "pobj", "false", "-1"],
["1790", "0", "1", "21", "105", "108", "S", "12", "and", "and", "and", "CC", "O", "cc", "false", "-1"],
["1790", "0", "1", "22", "109", "115", "SS", "12", "strict", "strict", "strict", "JJ", "O", "conj", "false", "-1"],
["1790", "0", "1", "23", "117", "121", "S", "22", "over", "over", "over", "IN", "O", "prep", "false", "-1"],
["1790", "0", "1", "24", "122", "132", "S", "25", "protective", "protective", "protective", "JJ", "O", "amod", "false", "-1"],
["1790", "0", "1", "25", "133", "140", "", "23", "parents", "parents", "parent", "NNS", "O", "pobj", "false", "-1"],
["1790", "0", "1", "26", "140", "141", "S", "12", ".", ".", ".", ".", "O", "punct", "false", "-1"]]

syn = sx.SyntaxTree()
syn.creat(sentence)
print syn.extract_label(11)
print syn.extract_label_with_info(11)
print syn.extract_des(11)
print syn.extract_action(11)
print syn.extract_full_action(11)


['baby']
['the baby of']
['baby']
['baby']
['PERSON', 'baby']

In [3]:
sentence = [["1790", "1", "17", "241", "1102", "1103", "S", "243", "I", "I", "I", "PRP", "O", "nsubj", "false", "11"],
["1790", "1", "17", "242", "1104", "1106", "S", "243", "do", "do", "do", "VBP", "O", "aux", "false", "-1"],
["1790", "1", "17", "243", "1107", "1111", "S", "250", "know", "know", "know", "VB", "O", "parataxis", "false", "-1"],
["1790", "1", "17", "244", "1112", "1116", "S", "247", "that", "that", "that", "IN", "O", "complm", "false", "-1"],
["1790", "1", "17", "245", "1117", "1118", "S", "247", "I", "I", "I", "PRP", "O", "nsubj", "false", "11"],
["1790", "1", "17", "246", "1119", "1121", "S", "247", "am", "am", "be", "VBP", "O", "cop", "false", "-1"],
["1790", "1", "17", "247", "1122", "1126", "", "243", "evil", "evil", "evil", "JJ", "O", "ccomp", "false", "-1"],
["1790", "1", "17", "248", "1126", "1127", "S", "243", ",", ",", ",", ",", "O", "punct", "false", "-1"],
["1790", "1", "17", "249", "1128", "1140", "", "250", "mhuahahahaaa", "mhuahahahaaa", "mhuahahahaaa", "JJ", "O", "amod", "false", "-1"],
["1790", "1", "17", "250", "1140", "1143", "S", "235", "!!!", "!!!", "!!!", "NN", "O", "conj", "false", "-1"]]
syn = sx.SyntaxTree()
syn.creat(sentence)
print syn.extract_label(11)
print syn.extract_label_with_info(11)
print syn.extract_des(11)
print syn.extract_action(11)
print syn.extract_full_action(11)


['evil']
['be evil ,']
['evil']
[]
[]

In [4]:
sentence = [["1790", "2", "215", "4654", "20920", "20921", "S", "4659", "I", "I", "I", "PRP", "O", "nsubj", "false", "11"],
["1790", "2", "215", "4655", "20922", "20925", "S", "4659", "was", "was", "be", "VBD", "O", "cop", "false", "-1"],
["1790", "2", "215", "4656", "20926", "20929", "S", "4659", "the", "the", "the", "DT", "O", "det", "false", "-1"],
["1790", "2", "215", "4657", "20930", "20934", "S", "4658", "most", "most", "most", "RBS", "O", "advmod", "false", "-1"],
["1790", "2", "215", "4658", "20935", "20944", "S", "4659", "beautiful", "beautiful", "beautiful", "JJ", "O", "amod", "false", "-1"],
["1790", "2", "215", "4659", "20945", "20953", "S", "4663", "creature", "creature", "creature", "NN", "O", "dobj", "false", "-1"],
["1790", "2", "215", "4660", "20954", "20956", "S", "4663", "he", "he", "he", "PRP", "O", "nsubj", "false", "5"],
["1790", "2", "215", "4661", "20957", "20960", "S", "4663", "had", "had", "have", "VBD", "O", "aux", "false", "-1"],
["1790", "2", "215", "4662", "20961", "20965", "S", "4663", "ever", "ever", "ever", "RB", "O", "advmod", "false", "-1"],
["1790", "2", "215", "4663", "20966", "20970", "", "4641", "seen", "seen", "see", "VBN", "O", "rcmod", "false", "-1"],
["1790", "2", "215", "4664", "20970", "20971", "S", "4629", ".", ".", ".", ".", "O", "punct", "false", "-1"]]
syn = sx.SyntaxTree()
syn.creat(sentence)
print syn.extract_label(11)
print syn.extract_label_with_info(11)
print syn.extract_des(11)
print syn.extract_action(11)
print syn.extract_full_action(11)


[]
[]
['creature']
[]
[]

In [5]:
sentence = [["1839", "2", "108", "2323", "10798", "10801", "S", "2327", "Max", "Max", "max", "NN", "PERSON", "nsubj", "true", "11"],
["1839", "2", "108", "2324", "10802", "10805", "", "2327", "was", "was", "be", "VBD", "O", "cop", "true", "-1"],
["1839", "2", "108", "2325", "10805", "10808", "S", "2327", "n't", "n't", "not", "RB", "O", "neg", "true", "-1"],
["1839", "2", "108", "2326", "10809", "10821", "S", "2327", "particularly", "particularly", "particularly", "RB", "O", "advmod", "true", "-1"],
["1839", "2", "108", "2327", "10822", "10826", "S", "-1", "fond", "fond", "fond", "JJ", "O", "null", "true", "-1"],
["1839", "2", "108", "2328", "10827", "10829", "S", "2327", "of", "of", "of", "IN", "O", "prep", "true", "-1"],
["1839", "2", "108", "2329", "10830", "10836", "S", "2328", "having", "having", "have", "VBG", "O", "pcomp", "true", "-1"],
["1839", "2", "108", "2330", "10837", "10839", "S", "2331", "to", "to", "to", "TO", "O", "aux", "true", "-1"],
["1839", "2", "108", "2331", "10840", "10844", "S", "2329", "hold", "hold", "hold", "VB", "O", "xcomp", "true", "-1"],
["1839", "2", "108", "2332", "10845", "10849", "S", "2331", "onto", "onto", "onto", "IN", "O", "prep", "true", "-1"],
["1839", "2", "108", "2333", "10850", "10851", "S", "2334", "a", "a", "a", "DT", "O", "det", "true", "-1"],
["1839", "2", "108", "2334", "10852", "10859", "", "2332", "vampire", "vampire", "vampire", "NN", "O", "pobj", "true", "-1"],
["1839", "2", "108", "2335", "10859", "10860", "S", "2327", ",", ",", ",", ",", "O", "punct", "true", "-1"],
["1839", "2", "108", "2336", "10861", "10864", "S", "2327", "but", "but", "but", "CC", "O", "cc", "true", "-1"],
["1839", "2", "108", "2337", "10865", "10867", "S", "2341", "if", "if", "if", "IN", "O", "mark", "true", "-1"],
["1839", "2", "108", "2338", "10868", "10870", "S", "2341", "he", "he", "he", "PRP", "O", "nsubj", "true", "1"],
["1839", "2", "108", "2339", "10871", "10874", "S", "2341", "was", "was", "be", "VBD", "O", "cop", "true", "-1"],
["1839", "2", "108", "2340", "10875", "10876", "S", "2341", "a", "a", "a", "DT", "O", "det", "true", "-1"],
["1839", "2", "108", "2341", "10877", "10880", "", "2348", "bat", "bat", "bat", "NN", "O", "advcl", "true", "-1"],
["1839", "2", "108", "2342", "10880", "10881", "S", "2348", ",", ",", ",", ",", "O", "punct", "true", "-1"],
["1839", "2", "108", "2343", "10882", "10884", "S", "2348", "it", "it", "it", "PRP", "O", "nsubj", "true", "-1"],
["1839", "2", "108", "2344", "10885", "10890", "", "2348", "could", "could", "could", "MD", "O", "aux", "true", "-1"],
["1839", "2", "108", "2345", "10890", "10893", "S", "2348", "n't", "n't", "not", "RB", "O", "neg", "true", "-1"],
["1839", "2", "108", "2346", "10894", "10896", "S", "2348", "be", "be", "be", "VB", "O", "cop", "true", "-1"],
["1839", "2", "108", "2347", "10897", "10900", "S", "2348", "too", "too", "too", "RB", "O", "advmod", "true", "-1"],
["1839", "2", "108", "2348", "10901", "10904", "", "2327", "bad", "bad", "bad", "JJ", "O", "conj", "true", "-1"],
["1839", "2", "108", "2349", "10904", "10905", "S", "2327", ".", ".", ".", ".", "O", "punct", "true", "-1"]]

syn = sx.SyntaxTree()
syn.creat(sentence)
print syn.extract_label(11)
print syn.extract_label_with_info(11)
print syn.extract_des(11)
print syn.extract_action(11)
print syn.extract_full_action(11)


['not fond']
['particularly not fond of']
['fond', 'particularly']
['fond']
['PERSON', 'not', 'particularly', 'fond']

In [6]:
sentence = [["1096", "2", "228", "3361", "14997", "14998", "S", "3364", "I", "I", "I", "PRP", "O", "nsubj", "true", "11"],
["1096", "2", "228", "3362", "14999", "15001", "S", "3364", "am", "am", "be", "VBP", "O", "cop", "true", "-1"],
["1096", "2", "228", "3363", "15002", "15006", "S", "3364", "very", "very", "very", "RB", "O", "advmod", "true", "-1"],
["1096", "2", "228", "3364", "15007", "15011", "S", "-1", "glad", "glad", "glad", "JJ", "O", "null", "true", "-1"],
["1096", "2", "228", "3365", "15012", "15015", "S", "3364", "for", "for", "for", "IN", "O", "prep", "true", "-1"],
["1096", "2", "228", "3366", "15016", "15019", "S", "3367", "the", "the", "the", "DT", "O", "det", "true", "-1"],
["1096", "2", "228", "3367", "15020", "15025", "S", "3365", "power", "power", "power", "NN", "O", "pobj", "true", "-1"],
["1096", "2", "228", "3368", "15026", "15028", "S", "3369", "to", "to", "to", "TO", "O", "aux", "true", "-1"],
["1096", "2", "228", "3369", "15029", "15036", "S", "3367", "control", "control", "control", "VB", "O", "infmod", "true", "-1"],
["1096", "2", "228", "3370", "15037", "15042", "S", "3371", "human", "human", "human", "JJ", "O", "amod", "true", "-1"],
["1096", "2", "228", "3371", "15043", "15051", "S", "3369", "memories", "memories", "memory", "NNS", "O", "dobj", "true", "-1"],
["1096", "2", "228", "3372", "15052", "15054", "S", "3369", "at", "at", "at", "IN", "O", "prep", "true", "-1"],
["1096", "2", "228", "3373", "15055", "15058", "S", "3374", "the", "the", "the", "DT", "O", "det", "true", "-1"],
["1096", "2", "228", "3374", "15059", "15065", "", "3372", "moment", "moment", "moment", "NN", "O", "pobj", "true", "-1"],
["1096", "2", "228", "3375", "15065", "15066", "", "3364", ".", ".", ".", ".", "O", "punct", "true", "-1"],
["1096", "2", "228", "3376", "15066", "15067", "SS", "3364", "”", "''", "''", "''", "O", "punct", "true", "-1"]]

syn = sx.SyntaxTree()
syn.creat(sentence)
print syn.extract_label(11)
print syn.extract_label_with_info(11)
print syn.extract_des(11)
print syn.extract_action(11)
print syn.extract_full_action(11)


['glad']
['very glad for']
['glad', 'very']
['glad']
['PERSON', 'very', 'glad']

In [8]:
sentence = [["1096", "2", "236", "3457", "15434", "15441", "S", "3462", "Because", "Because", "because", "IN", "O", "mark", "false", "-1"],
["1096", "2", "236", "3458", "15442", "15445", "", "3462", "she", "she", "she", "PRP", "O", "nsubj", "false", "11"],
["1096", "2", "236", "3459", "15445", "15447", "S", "3462", "’s", "'s", "be", "VBZ", "O", "cop", "false", "-1"],
["1096", "2", "236", "3460", "15448", "15449", "S", "3462", "a", "a", "a", "DT", "O", "det", "false", "-1"],
["1096", "2", "236", "3461", "15450", "15458", "S", "3462", "stubborn", "stubborn", "stubborn", "JJ", "O", "amod", "false", "-1"],
["1096", "2", "236", "3462", "15459", "15464", "", "3465", "idiot", "idiot", "idiot", "NN", "O", "advcl", "false", "-1"],
["1096", "2", "236", "3463", "15464", "15465", "S", "3465", ",", ",", ",", ",", "O", "punct", "false", "-1"],
["1096", "2", "236", "3464", "15466", "15467", "S", "3465", "I", "I", "I", "PRP", "O", "nsubj", "false", "-1"],
["1096", "2", "236", "3465", "15468", "15473", "S", "-1", "heard", "heard", "hear", "VBD", "O", "null", "false", "-1"],
["1096", "2", "236", "3466", "15474", "15479", "S", "3467", "Daren", "Daren", "Daren", "NNP", "PERSON", "nsubj", "false", "0"],
["1096", "2", "236", "3467", "15480", "15485", "", "3465", "think", "think", "think", "VB", "O", "ccomp", "false", "-1"],
["1096", "2", "236", "3468", "15485", "15486", "S", "3465", ".", ".", ".", ".", "O", "punct", "false", "-1"]]

syn = sx.SyntaxTree()
syn.creat(sentence)
print syn.extract_label(11)
print syn.extract_label_with_info(11)
print syn.extract_des(11)
print syn.extract_action(11)
print syn.extract_full_action(11)
print syn.storyID
print syn.chapterID
print syn.sentenceID


['stubborn idiot']
['a stubborn idiot ,']
['idiot']
[]
[]
1096
2
236

A New Function to Extract Features for LTR

Besides the phrases, features are extracted to build LTR models.

Story_ID --> Story Category

Chapter_ID --> Position of the Chapter

Sentence_ID --> Position of the Sentence

Frequency1 --> Frequency in present story

Frequency2 --> Frequency in all stories

Frequency3 --> Frequency in all summaires

Preword_Embedding --> word2vec of the word before

Following_Embedding --> word2vec of the word after

Word_Embedding --> word2vec of present word


In [ ]: