Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call_frog hangs #3

Open
KnutJaegersberg opened this issue Oct 17, 2019 · 1 comment
Open

call_frog hangs #3

KnutJaegersberg opened this issue Oct 17, 2019 · 1 comment

Comments

@KnutJaegersberg
Copy link

Hi,
using the recent docker image, via

sudo docker run -p 9972:9972 -t -i proycon/lamachine
frog -S 9972

call_frog and do_call_frog hang indefinetely for me. then again, manually approaching the port via the command
telnet localhost 9972
works.
When fiddeling a bit, I found that a slight adjustment of the do_call_frog function helped me out:
I removed the dollar sign at ready and can programmatically use frog via this function, but not with call_frog.

do_call_frog
function(socket, text) {
write.socket(socket, text)
write.socket(socket, "\nEOT\n")
# read until 'READY' is found
output <- ""
while (!grepl("\nREADY\n", output)) {
output = paste(output, read.socket(socket), sep="")
}
output = gsub("READY\n", "", output)

# read output and label columns
con <- textConnection(output)
result = read.csv(con, sep='\t', quote = '', header=F)
close(con)

colnames(result) <- c("position", "word", "lemma", "morph", "pos", "prob",
                      "ner", "chunk", "parse1", "parse2")
result$majorpos = gsub("\\(.*", "", result$pos)

# assign sentence number by assigning number when position == 1 and filling down into NA cells using zoo::na.locf
result$sent[result$position == 1] = 1:sum(result$position == 1)
if(is.na(result$sent[1])) result$sent[1] = 1
result$sent = na.locf(result$sent)

result

}

it works for me using:
lapply(c("dit is een toets", "waarom heeft hij geen zin meer?"), FUN = do_call_frog, socket=make.socket(port = 9972)) %>% data.table::rbindlist()

Why is that? a few month ago I had no problems using frogr. not sure if I used it with the container though.

@hsselman
Copy link

Hey! I used docker run -p 8080:80 -t -i proycon/lamachine to start the docker. In R in use call_frog(tekst, host="localhost", port=8080) to call frog. Does this work for you, @KnutJaegersberg ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants