Commit 74d4793b authored by Joel Oksanen's avatar Joel Oksanen

Cleaned up files in .gitremove

parent c516942e
<?xml version="1.0" ?>
<sentences>
<sentence>
<text>This is a great camera , i wanted the new panasonic lumix ... but this was just as great , excellent features and easy to use , touch screen is amazing</text>
<aspectTerms>
<aspectTerm from="16" polarity="positive" term="camera" to="22"/>
<aspectTerm from="101" polarity="positive" term="features" to="109"/>
<aspectTerm from="128" polarity="positive" term="touch screen" to="140"/>
</aspectTerms>
</sentence>
<sentence>
<text>I just got the 7D a few days ago, so I'm sure I'll be adding more to this review as I gain experience with the camera.</text>
<aspectTerms>
<aspectTerm from="15" polarity="neutral" term="7D" to="17"/>
<aspectTerm from="111" polarity="neutral" term="camera" to="117"/>
</aspectTerms>
</sentence>
<sentence>
<text>I purchased it as an upgrade to my Rebel Xsi, which I felt I had outgrown (I have TONS more to learn, I know...but I wanted a camera that had a lot more room for growth).</text>
<aspectTerms>
<aspectTerm from="35" polarity="neutral" term="Rebel Xsi" to="44"/>
<aspectTerm from="126" polarity="neutral" term="camera" to="132"/>
</aspectTerms>
</sentence>
<sentence>
<text>The Rebel served me well, but I'm excited about the possibilities I have with the 7D.</text>
<aspectTerms>
<aspectTerm from="4" polarity="positive" term="Rebel" to="9"/>
<aspectTerm from="82" polarity="positive" term="7D" to="84"/>
</aspectTerms>
</sentence>
<sentence>
<text>I should add, I'm an \\&quot;experienced amateur\\&quot;/semipro.</text>
</sentence>
<sentence>
<text>One of the features I really like so far is the ability to use the 7D as a master unit for an off camera flash.</text>
<aspectTerms>
<aspectTerm from="105" polarity="neutral" term="flash" to="110"/>
</aspectTerms>
</sentence>
<sentence>
<text>I have the 430 EXII, which I've been using for a year or two now, and I love it.</text>
<aspectTerms>
<aspectTerm from="11" polarity="positive" term="430 EXII" to="19"/>
</aspectTerms>
</sentence>
<sentence>
<text>But I'd love to try some backlit shots as well as other creative lighting techniques.</text>
</sentence>
<sentence>
<text>In just having this for a couple days, here's one shot I got: [...]
I'm excited to try out the focusing capabilities in a variety of situations and with different lenses.</text>
</sentence>
<sentence>
<text>I've already played around with fine tuning (\\&quot;microadjusting\\&quot;) the focusing for different lenses.</text>
<aspectTerms>
<aspectTerm from="94" polarity="neutral" term="lenses" to="100"/>
</aspectTerms>
</sentence>
<sentence>
<text>{See this article for more: [...]} I knew my 85 1.8 had been misbehaving for awhile when focusing, but I couldn't fix it (aside from manually focusing) on my Rebel.</text>
</sentence>
<sentence>
<text>Now I can.</text>
</sentence>
<sentence>
<text>Accurate focus is super important to me because I shoot wide apertures and usually tight shots...every centimeter is critical.</text>
</sentence>
<sentence>
<text>One thing I find slightly annoying is that the focusing spot is a rather large rectangle.</text>
<aspectTerms>
<aspectTerm from="47" polarity="negative" term="focusing spot" to="60"/>
</aspectTerms>
</sentence>
<sentence>
<text>I'd like it to be a dot.</text>
</sentence>
<sentence>
<text>You can turn Spot AF on in custom functions, which I did...it adds a smaller spot in the middle of the rectangle, but the rectangle is still there.</text>
</sentence>
<sentence>
<text>I'm sure it's just going to take some getting used to.</text>
</sentence>
<sentence>
<text>The camera feels much more rugged, heavy, and sturdy than the Rebel.</text>
<aspectTerms>
<aspectTerm from="4" polarity="positive" term="camera" to="10"/>
<aspectTerm from="62" polarity="negative" term="Rebel" to="67"/>
</aspectTerms>
</sentence>
<sentence>
<text>So far, I'm loving it and have been glued to my manual!</text>
<aspectTerms>
<aspectTerm from="48" polarity="neutral" term="manual" to="54"/>
</aspectTerms>
</sentence>
<sentence>
<text>I owned the DSC-W330 for about 10 months, and the pictures it took were \\&quot;adequate\\&quot;.</text>
<aspectTerms>
<aspectTerm from="12" polarity="neutral" term="DSC-W330" to="20"/>
<aspectTerm from="50" polarity="neutral" term="pictures" to="58"/>
</aspectTerms>
</sentence>
<sentence>
<text>It struggled with any form of moving shot, requiring absolute stillness to take a shot in focus, and even then it looked pretty mediocre when you zoomed in on any part of the image; every picture has a slightly \\&quot;fuzzy\\&quot; quality when you zoom in.</text>
<aspectTerms>
<aspectTerm from="188" polarity="negative" term="picture" to="195"/>
</aspectTerms>
</sentence>
<sentence>
<text>Macro shots are pretty terrible, focusing on one plane in front of the camera (and thus throwing everything else out of focus).</text>
<aspectTerms>
<aspectTerm from="0" polarity="negative" term="Macro shots" to="11"/>
<aspectTerm from="71" polarity="neutral" term="camera" to="77"/>
</aspectTerms>
</sentence>
<sentence>
<text>At a macro level, the camera may focus on a plane 2 inches in front of the screen, and everything projecting forward or back from that plane is going to be out of focus.</text>
</sentence>
<sentence>
<text>The automatic selection of what mode to shoot in was also a bit annoying at times, and I'd rather have that control to myself.</text>
</sentence>
<sentence>
<text>Finally, most damning of all, my DSC-W330 began having technical problems about a week ago; the lens would extend, then retract, then extend again when I turned it on, and then I could use the camera.</text>
<aspectTerms>
<aspectTerm from="33" polarity="negative" term="DSC-W330" to="41"/>
</aspectTerms>
</sentence>
<sentence>
<text>Today, however, the lens extended and retracted four times before a message saying \\&quot;Please turn the camera off and on again\\&quot; came up.</text>
</sentence>
<sentence>
<text>Doing this did not fix the problem, and after a bit of searching I'm discovering it's a fairly common problem for this camera to just flat-out die on you.</text>
<aspectTerms>
<aspectTerm from="119" polarity="negative" term="camera" to="125"/>
</aspectTerms>
</sentence>
<sentence>
<text>I bought this as a replacement for my previous Sony Cybershot W50 dying, and it looks like I'll be going with either a Panasonic or a Canon shortly.</text>
<aspectTerms>
<aspectTerm from="47" polarity="neutral" term="Sony Cybershot W50" to="65"/>
</aspectTerms>
</sentence>
<sentence>
<text>I'm not going to bother with asking for a refund or repair because it will most likely cost more than half the cost of the thing to fix, which is not worth it to me; I'd rather have a good camera.</text>
</sentence>
<sentence>
<text>For the guy who took it diving and it still works: Glad it worked for you.</text>
</sentence>
<sentence>
<text>I bought it for a trip to Hawaii with my kids and took it snorkeling on the last day we were there.</text>
</sentence>
<sentence>
<text>Within 5 minutes the screen stopped working, an hour later it was completely dead.</text>
<aspectTerms>
<aspectTerm from="21" polarity="negative" term="screen" to="27"/>
</aspectTerms>
</sentence>
<sentence>
<text>Somehow water got in it.</text>
</sentence>
<sentence>
<text>Like everyone else, I read the instructions, all the latches were properly closed, that wasn't even the compartment that got wet!</text>
<aspectTerms>
<aspectTerm from="31" polarity="neutral" term="instructions" to="43"/>
</aspectTerms>
</sentence>
<sentence>
<text>The other side of the camera is where the water seeped in.</text>
</sentence>
<sentence>
<text>I checked the battery and memory card were completely dry, THANK GOSH!</text>
<aspectTerms>
<aspectTerm from="14" polarity="neutral" term="battery" to="21"/>
<aspectTerm from="26" polarity="neutral" term="memory card" to="37"/>
</aspectTerms>
</sentence>
<sentence>
<text>So I didn't loose all my pics.</text>
<aspectTerms>
<aspectTerm from="25" polarity="neutral" term="pics" to="29"/>
</aspectTerms>
</sentence>
<sentence>
<text>Luckily enough the captain felt bad and gave us a free cheapy underwater camera for the rest of the trip.</text>
</sentence>
<sentence>
<text>I was so unhappy, it was such a disappointment!</text>
</sentence>
<sentence>
<text>Everything was good except when I forgot to put in the SD card and started recording a research session, I could not transfer the video off the internal memory.</text>
<aspectTerms>
<aspectTerm from="55" polarity="neutral" term="SD card" to="62"/>
<aspectTerm from="144" polarity="negative" term="internal memory" to="159"/>
</aspectTerms>
</sentence>
<sentence>
<text>:(</text>
</sentence>
<sentence>
<text>My son loves this camera.</text>
<aspectTerms>
<aspectTerm from="18" polarity="positive" term="camera" to="24"/>
</aspectTerms>
</sentence>
<sentence>
<text>He uses it for everything.</text>
</sentence>
<sentence>
<text>I wish he'd use it professionally because his pictures are so good.</text>
<aspectTerms>
<aspectTerm from="46" polarity="positive" term="pictures" to="54"/>
</aspectTerms>
</sentence>
<sentence>
<text>I FEEL THAT THIS CAMERA IS TOO CUMBERSON FOR ME, IT TAKES NICE PICS BUT THE FLASH DOES NOT PROVIDE ENOUGH LIGHT IN SOME SITUATIONS.</text>
<aspectTerms>
<aspectTerm from="17" polarity="conflict" term="CAMERA" to="23"/>
<aspectTerm from="63" polarity="positive" term="PICS" to="67"/>
<aspectTerm from="76" polarity="negative" term="FLASH" to="81"/>
</aspectTerms>
</sentence>
<sentence>
<text>A GOOD CAMERA FOR AMATEURS!</text>
<aspectTerms>
<aspectTerm from="7" polarity="positive" term="CAMERA" to="13"/>
</aspectTerms>
</sentence>
<sentence>
<text>This camera surprised me.</text>
<aspectTerms>
<aspectTerm from="5" polarity="neutral" term="camera" to="11"/>
</aspectTerms>
</sentence>
<sentence>
<text>I was hesitant to move to an SLR but after months of shopping around I settled on this one.</text>
</sentence>
<sentence>
<text>Upon using it on several trips in a variety of circumstances I am confident that I made the best purchase possible.</text>
</sentence>
<sentence>
<text>The APS functionality makes having the choice of 3 sizes truly fun and something cool to experiment with.</text>
<aspectTerms>
<aspectTerm from="4" polarity="positive" term="APS functionality" to="21"/>
</aspectTerms>
</sentence>
<sentence>
<text>The only drawback is that APS film and developing are slightly more expensive and the film is a little more difficult to find.</text>
<aspectTerms>
<aspectTerm from="26" polarity="negative" term="APS film" to="34"/>
</aspectTerms>
</sentence>
<sentence>
<text>I've been able to take pictures that I only thought possible by a professional.</text>
<aspectTerms>
<aspectTerm from="23" polarity="positive" term="pictures" to="31"/>
</aspectTerms>
</sentence>
<sentence>
<text>This camera is much lighter than I expected in one with some much functionality and fits ergonomically in the hand.</text>
<aspectTerms>
<aspectTerm from="5" polarity="positive" term="camera" to="11"/>
</aspectTerms>
</sentence>
<sentence>
<text>I can't wait to learn all of the factions it has, but while learning the automatic modes and simple functionality make it as easy too use as a point and shoot.</text>
</sentence>
<sentence>
<text>Need to do manual adjustments if you want video to be less than lousy (still not very good, though).</text>
<aspectTerms>
<aspectTerm from="42" polarity="negative" term="video" to="47"/>
</aspectTerms>
</sentence>
<sentence>
<text>Looks pretty bad on a large TV.</text>
</sentence>
<sentence>
<text>Camera pics are normal video camera quality; not worth using.</text>
<aspectTerms>
<aspectTerm from="7" polarity="negative" term="pics" to="11"/>
</aspectTerms>
</sentence>
<sentence>
<text>I'll try again in a few years with a hi def video camera when the prices hit close to what I paid for this model.</text>
</sentence>
<sentence>
<text>My ancient video cameras take better video (vhs-c and huge old Canon mini dv).</text>
</sentence>
<sentence>
<text>She loved the camera.</text>
<aspectTerms>
<aspectTerm from="14" polarity="positive" term="camera" to="20"/>
</aspectTerms>
</sentence>
<sentence>
<text>Taking her a bit to maneuver it but she is definitely enjoying her Christmas gift.</text>
</sentence>
<sentence>
<text>Good buy!</text>
</sentence>
<sentence>
<text>I used my GoPro once out of the box for 10 minutes and it worked fine.</text>
</sentence>
<sentence>
<text>A few weeks later I tried to turn it on before I went on a trip to Florida and it wouldn't turn on.</text>
</sentence>
<sentence>
<text>So I charged it that night.</text>
</sentence>
<sentence>
<text>The next morning, I pulled it off the charger and put it right in my bag without checking it.</text>
</sentence>
<sentence>
<text>Once I got to Florida, I tried turning it on and it wouldn't.</text>
</sentence>
<sentence>
<text>Nothing happened.</text>
</sentence>
<sentence>
<text>So I got back charged it for a long time.</text>
</sentence>
<sentence>
<text>When I turned it on, the display showed a bunch of wavy lines.</text>
<aspectTerms>
<aspectTerm from="25" polarity="negative" term="display" to="32"/>
</aspectTerms>
</sentence>
<sentence>
<text>It finally fixed itself but every time I try to press the video button, the camera turns off.</text>
</sentence>
<sentence>
<text>I got mines today and I when I opened it up I got the camera working and the moment I took a picture I couldn't stop, I'm in love !</text>
<aspectTerms>
<aspectTerm from="54" polarity="positive" term="camera" to="60"/>
</aspectTerms>
</sentence>
<sentence>
<text>This is a nice camera with great functions, however, do not expect same from the body built.</text>
<aspectTerms>
<aspectTerm from="15" polarity="conflict" term="camera" to="21"/>
<aspectTerm from="33" polarity="positive" term="functions" to="42"/>
<aspectTerm from="81" polarity="negative" term="body built" to="91"/>
</aspectTerms>
</sentence>
<sentence>
<text>It feels more plastic in contrast to previous models.</text>
</sentence>
<sentence>
<text>In addition, transition between builtin memory and additional memory (sd or ms) is not as user friendly as the other brands.</text>
<aspectTerms>
<aspectTerm from="13" polarity="negative" term="transition between builtin memory and additional memory" to="68"/>
</aspectTerms>
</sentence>
<sentence>
<text>Does it deserve to be priced for 800 bucks, no.</text>
</sentence>
<sentence>
<text>Fast shipping.</text>
<aspectTerms>
<aspectTerm from="5" polarity="positive" term="shipping" to="13"/>
</aspectTerms>
</sentence>
<sentence>
<text>Some problems with the shutter getting stuck at first.</text>
<aspectTerms>
<aspectTerm from="23" polarity="negative" term="shutter" to="30"/>
</aspectTerms>
</sentence>
<sentence>
<text>One of my friends bought this machine, and she brought it on her vacation to Hawaii.</text>
</sentence>
<sentence>
<text>She showed us what she recorded during the trip when she come back.</text>
</sentence>
<sentence>
<text>Thanks to this excellent camcorder, we also experience the great scence of Hawaii.</text>
<aspectTerms>
<aspectTerm from="25" polarity="positive" term="camcorder" to="34"/>
</aspectTerms>
</sentence>
</sentences>
\ No newline at end of file
from stanfordcorenlp import StanfordCoreNLP
from xml.etree.ElementTree import ElementTree, parse, tostring, Element, SubElement
from nltk.tree import ParentedTree as Tree
import re
from xml.dom import minidom
import os
filepath = 'Laptops_Test_Gold.xml'
output = 'SemEval_2014_Laptop_Test_with_labelled_parse_trees.xml'
nlp = StanfordCoreNLP(r'/Users/joeloksanen/stanford-corenlp-full-2018-10-05')
root = Element('data')
opinion_labels = ['negative', 'neutral', 'positive', 'conflict']
prepared_counts = {
'positive': 0,
'neutral': 0,
'negative': 0,
'conflict': 0
}
input = parse(filepath)
for sentence in input.getroot():
text = sentence.find('text').text
# replace all occurrences of two or more . with standardised ...
text = re.sub('[.][.]+', '...', text)
if not sentence.find('aspectTerms'):
continue
for aspect_term in sentence.find('aspectTerms'):
arg_from = int(aspect_term.attrib['from'])
arg_to = int(aspect_term.attrib['to'])
opinion = aspect_term.attrib['polarity']
# get corenlp tree with argument in place
parse_tree_str = nlp.parse(text[:arg_from] + 'ARG' + text[arg_to:])
# replace argument with ARG in tree
parse_tree = Tree.fromstring(parse_tree_str)
# for subtree in parse_tree.subtrees():
# if ' '.join(subtree.leaves()) == argument:
# for child in list(subtree):
# subtree.remove(child)
# subtree.insert(0, 'ARG')
labelled_parse_tree_str = str(parse_tree)
instance_node = SubElement(root, 'instance')
text_node = SubElement(instance_node, 'text')
text_node.text = text
opinion_node = SubElement(instance_node, 'opinion')
opinion_node.text = opinion
opinion_tree_node = SubElement(instance_node, 'tree')
opinion_tree_node.text = labelled_parse_tree_str
prepared_counts[opinion] += 1
xmlstr = minidom.parseString(tostring(root)).toprettyxml(indent=' ')
xmlstr = os.linesep.join([s for s in xmlstr.splitlines() if s.strip()])
with open(output, 'w') as f:
f.write(xmlstr)
print(prepared_counts)
import xml.etree.ElementTree as ET
from stanfordcorenlp import StanfordCoreNLP
import re
tree = ET.parse('EN_LAPT_SB1_TEST_.xml.gold')
reviews = tree.getroot()
nlp = StanfordCoreNLP(r'/Users/joeloksanen/stanford-corenlp-full-2018-10-05')
for review in reviews:
sentences = review[0]
assert sentences.tag == 'sentences'
for sentence in sentences:
opinions = sentence.find('Opinions')
if opinions is None:
continue
text_node = sentence.find('text')
# replace all occurrences of two or more . with standardised ...
text_node.text = re.sub('[.][.]+', '...', text_node.text)
parse_tree_str = nlp.parse(text_node.text)
parse_tree = ET.Element('tree')
parse_tree.text = parse_tree_str
sentence.append(parse_tree)
tree.write('ABSA16_Laptops_Test_with_parse_trees.xml')
from xml.etree.ElementTree import ElementTree, parse, Element, SubElement
from nltk.tokenize import word_tokenize
import string
from nltk.tree import ParentedTree as Tree
glossary = {
'laptop': ['computer', 'device', 'machine', 'price', 'cost', 'macbook', 'mac', 'pc', 'speed', 'it', 'this', 'product'],
'display': ['monitor', 'screen', 'touchscreen'],
'cpu': ['processor'],
'motherboard': [],
'hard disc': ['storage'],
'memory': ['ram'],
'battery': ['battery life'],
'power supply': ['charger', 'power supply cord', 'power adapter'],
'keyboard': ['keys', 'numpad'],
'mouse': ['mouse pad', 'touchpad'],
'fans cooling': ['fan', 'cooling', 'heat sink'],
'optical drives': ['cd players', 'dvd drive', 'disc drive', 'dvd burner'],
'ports': ['usb port', 'hdmi port', 'vga port', 'card reader', 'firewire port', 'sd card slot', 'dvi port', 'thunderbolt port'],
'graphics': ['graphics card', 'video card', 'graphics chip', 'gpu'],
'multimedia devices': ['sound', 'audio', 'microphone', 'camera', 'webcam', 'speakers', 'headphone'],
'hardware': [],
'os': ['os x', 'windows', 'linux', 'start menu', 'safe mode', 'boot manager', 'drag and drop feature'],
'software': ['office', 'iwork', 'word processor', 'microsoft word', 'powerpoint', 'browser', 'skype', 'iphoto', 'ilife', 'pages', 'keynote', 'antivirus program', 'firewall', 'games', 'facial recognition'],
'warranty': [],
'shipping': ['delivery'],
'support': ['service', 'customer service'],
'company': ['apple', 'hp', 'asus', 'toshiba', 'dell', 'compaq', 'acer', 'lenovo']
}
included_labels = ['NNP', 'NNPS', 'DT', 'CD', 'FW', 'PRP', '\'\'', '.']
noun_labels = ['NN', 'NNS']
def glossary_terms():
joint_terms = list(glossary.keys()) + [item for l in glossary.values() for item in l]
return ' '.join(joint_terms).split(' ')
def included_noun(t):
return (t.label() in noun_labels and
all(leaf.lower() in glossary_terms() for leaf in t.leaves()))
def get_np_tree(np):
children = []
for np_sub in reversed(np):
if type(np_sub) is Tree: