flushing vislcg3 in python subprocess

11 views
Skip to first unread message

Robert Reynolds

unread,
Mar 25, 2019, 1:41:19 PM3/25/19
to Constraint Grammar
Hey all!

This might be more of a python question than a vislcg3 question, but I couldn't find an answer on Google.

I'm using the following to disambiguate a custom Text object in python:

```python
            p = Popen(['vislcg3', '-g', gram_path],
                      stdin=PIPE,
                      stdout=PIPE,
                      universal_newlines=True)
            output = p.communicate(input=self.CG_str())[0]
```

...where self.CG_str() gives a cg3-style stream representation, ending with a newline ('\n').

With the current approach, I get everything except the last token and its readings. Any ideas how to get the last token to flush?

Tino Didriksen

unread,
Mar 25, 2019, 1:43:52 PM3/25/19
to Constraint Grammar
Try throwing https://visl.sdu.dk/cg3/chunked/streamcmds.html#cmd-flush at it. A line of only:
<STREAMCMD:FLUSH>

-- Tino Didriksen

Robert Reynolds

unread,
Mar 25, 2019, 1:53:02 PM3/25/19
to Constraint Grammar
Making the CG_str() end with '\n<STREAMCMD:FLUSH>\n' didn't change the result.

Robert Reynolds

unread,
Mar 26, 2019, 5:58:23 PM3/26/19
to Constraint Grammar
Tino, in the following am I using the stream command correctly? So far, every way I've tried it does not make a difference. The only way I've been able to get this to work is by adding a dummy token to the end of the stream, but that seems like a dangerous hack.

"<Мы>"
"мы" Pron Pers Pl1 Nom <W:0.0>
"<нашли>"
"наслать" V Perf IV Imp Sg2 <W:3.916015625>
"наслать" V Perf TV Imp Sg2 <W:3.916015625>
"найти" V Perf IV Pst MFN Pl <W:5.638671875>
"найти" V Perf TV Pst MFN Pl <W:5.638671875>
"<то>"
"тот" Det Dem Neu AnIn Sg Acc <W:0.0>
"тот" Det Dem Neu AnIn Sg Nom <W:0.0>
"тот" Pron Dem Neu AnIn Sg Acc <W:0.0>
"тот" Pron Dem Neu AnIn Sg Nom <W:0.0>
"то" Pron Dem Neu Inan Sg Acc <W:5.0556640625>
"то" Pron Dem Neu Inan Sg Nom <W:5.0556640625>
"то" CC <W:5.9150390625>
"то" CS <W:5.9150390625>
"<,>"
"," CLB <W:0.0>
"<что>"
"что¹" Pron Interr Neu Inan Sg Acc <W:0.0>
"что¹" Pron Interr Neu Inan Sg Nom <W:0.0>
"что¹" Pron Rel Neu Inan Sg Acc <W:0.0>
"что¹" Pron Rel Neu Inan Sg Nom <W:0.0>
"что²" CS <W:6.7958984375>
"<искали>"
"искать" V Impf IV Pst MFN Pl <W:5.3779296875>
"искать" V Impf TV Pst MFN Pl <W:5.3779296875>
"<.>"
"." CLB <W:0.0>
<STREAMCMD:FLUSH>
Reply all
Reply to author
Forward
0 new messages