I'm using Sentiment Stanford NLP library for sentiment analytics.
Now I want to generate a treebank from a sentence
input sentence: "Effective but too-tepid biopic"
output tree bank: (2 (3 (3 Effective) (2 but)) (1 (1 too-tepid) (2 biopic)))
Can anybody show me how to do it ?
Thank all.
So I had to push a bug fix for the SentimentPipeline.
If you get the latest code from GitHub and use that version: https://github.com/stanfordnlp/CoreNLP
you can issue this command:
java -Xmx8g edu.stanford.nlp.sentiment.SentimentPipeline -file example-sentences.txt -output PENNTREES
and you'll get output like this:
I really liked the movie.
(3 (2 I) (3 (2 really) (3 (3 (3 liked) (2 (2 the) (2 movie))) (2 .))))
I hated the movie.
(1 (2 I) (1 (1 (1 hated) (2 (2 the) (2 movie))) (2 .)))
Related
Here is my MIT Scheme code:
(display (name->package '(user)))
(newline)
(->environment (name->package '(user)))
(%exit)
This runs fine on MIT/GNU Scheme Release 9.1.1. Here is the output:
$ scheme --quiet --load foo.scm
#[package 13 (user)]
But when I run this with MIT/GNU Scheme Release 10.1.5, I get this error:
$ mit-scheme --quiet --load foo.scm
#[package 12 (user)]
;The object #[package 12 (user)], passed as an argument to ->environment, is not an environment.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.
2 error>
On debugging I get this,
2 error> (debug)
There are 7 subproblems on the stack.
Subproblem level: 0 (this is the lowest subproblem level)
Compiled code expression unknown
#[compiled-return-address 13 ("rep" #x2f) #xd8 #x95ed10]
There is no current environment.
There is no execution history for this subproblem.
You are now in the debugger. Type q to quit, ? for commands.
3 debug>
Why does this error occur in 10.1.5 but not in 9.1.1?
I recently decided to start playing with MIT Scheme by following along with the examples in SICP. I installed scheme from the Ubuntu repository.
sudo apt-get install mit-scheme
Given an input file that looks like this:
486
(+ 137 349)
(- 1000 334)
(* 5 99)
(/ 10 5)
(* 25 4 12)
I run scheme as follows.
scheme < Numbers.scm
It produces the following output.
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 2011 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Sunday February 7, 2016 at 10:35:34 AM
Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116
1 ]=> 486
;Value: 486
1 ]=> (+ 137 349)
;Value: 486
1 ]=> (- 1000 334)
;Value: 666
1 ]=> (* 5 99)
;Value: 495
1 ]=> (/ 10 5)
;Value: 2
1 ]=> (* 25 4 12)
;Value: 1200
1 ]=>
End of input stream reached.
Moriturus te saluto.
This output feels excessive, so I'm currently paring it down like so.
scheme < Numbers.scm | awk '/Value/ {print $2}
486
486
666
495
2
1200
Is there a native way to reduce the verbosity of scheme, so I can get something resembling the above output without resorting to an external process?
I have examined the output of scheme --help but did not find any obvious options.
Note that passing the filename as an argument does not appear to work in MIT-Scheme.
scheme Numbers.scm
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 2011 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Sunday February 7, 2016 at 10:35:34 AM
Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116
;Warning: Invalid keyword: "Numbers.scm"
;Warning: Unhandled command line options: ("Numbers.scm")
1 ]=>
Here you go:
scheme --quiet < Numbers.scm
Now this will suppress the REPL entirely except when errors occur so that what is not explicitly displayed will not be displayed. eg. evaluatiing (+ 2 3) returns 5, but does not print since you have not told it to print. You need to use procedures like display to get the information printed or go back to using a REPL which sole purpose is to display your results.
I was originally hoping you could do:
scheme --quiet --load Numbers.scm
But it does not exit after the file and adding --eval (exit) has the REPL ask if you want to quit.
EDIT
(define (displayln v)
(display v)
(newline)
v)
(displayln (+ 4 5))
; ==> 9, in addition you get the side effect that "9\n" is written to current output port
You could also perhaps make a macro to do this:
(define-syntax begin-display
(syntax-rules ()
((_ form ...) (begin (displayln form) ...))))
(begin-display
486
(+ 137 349)
(- 1000 334)
(* 5 99)
(/ 10 5)
(* 25 4 12))
; ==> 1200. In addition you get the side effect that "486\n486\n666\n49\n2\n1200\n" is written to current output port
As a workaround,
scheme < Numbers.scm | gawk '/^;Value: / { sub(/^;Value: /, ""); print }'
But maybe you'd run it as a script file rather than an stdin stream? Not sure about MIT Scheme invocation, something like
scheme Numbers.scm
Though this way you'll have to print out the results explicitly, with (display) or something, otherwise they'll go unnoticed.
This question already has answers here:
Can awk patterns match multiple lines?
(6 answers)
How to parse multi line records (with awk?)
(2 answers)
Closed 5 years ago.
In below test.log file I want to search only today's date with Message "Upload_Msg_testListeningFn"; if both the conditions match then redirect the output.
cat /tmp/test.log
===========================================================================
system Version [45.2.18] (FATAL ERROR INFORMATION)
File: [test003.cxx]
Line: [240]
Date: [19-01-2018 21:09:40]
User ID: [SYSTEM]
Message : [batman error: Upload_Msg_testListeningFn]
Error Code : [TEST0000057]
Outside FGH
Session Id: 6768678898:00:F
=======================================
Output should be:
Date: [19-01-2018 21:09:40]
Message : [batman error: Upload_Msg_testListeningFn]
I used awk but somewhere I am missing something
i used the below command for finding lines after particular date.
awk '/^Date/{c=3} c&&c--' /tmp/test.log
I want to save the particular result to the text/excel file through bash.
I tried below command it works fine, but I need only last result passed/failed, not the each step of execution.
I used below command to execute
$ bash eg.sh Behatscripts.txt > output.xls or
$ bash eg.sh Behatscripts.txt > output.txt
Below is the output console in my case, this whole thing is writing into the .txt/.xls file. But I need only last part that is:
1 scenario (1 passed)
3 steps (3 passed)
Executing the Script : eg.feature
----------------------------------------
#javascript
Feature: home page Validation
In order to check the home page of our site
As a website/normal user
I should be able to find some of the links/texts on the home page
Scenario: Validate the links in the header and footer # features\cap_english_home.feature:8
Given I am on the homepage # FeatureContext::iAmOnHomepage()
When I visit "/en" # FeatureContext::assertVisit()
Then I should see the following <links> # FeatureContext::iShouldSeeTheFollowingLinks()
| links |
| Dutch |
1 scenario (1 passed)
3 steps (3 passed)
0m14.744s
Give some suggestion to put condition to save only last part of the output console, thanks in advance.
This question already has answers here:
Inner join on two text files
(5 answers)
Closed 7 years ago.
I have two text files, one with the following content:
Brazil
China
USA
And another file with the following content:
Brazil 8 9 5 2
China 1 2 2 1
France 7 4 1 2
Italy 0 1 2 3
Spain 5 4 6 8
UK 8 5 4 1
USA 1 2 3 4
I would like to use some command that compares both files and returns
Brazil 8 9 5 2
China 1 2 2 1
USA 1 2 3 4
The command comm doesn't seem to work in cases like this. How could I solve it?
Edit: although this question is marked as duplicated, the solutions for the other question are not the same presented here.
Suppose you have nation names in file 1 and names and numbers in file 2 then
grep -wFf 1 2
should do the trick.