chriskonnertz/DeepLy

CurlHttpClient.php -> calllApi($url, array $payload, $method)

scribnermj opened this issue ยท 5 comments

I'm doing my testing on a localhost machine using the demo_translate.php front end.
I've added a var_dump command at the end of the callApi function to help me understand the calls being made and how they are processed.

curl_close($curl);
var_dump($rawResponseData);
return $rawResponseData;

I am seeing a separate api call on every line input in the html text box. Even on empty lines.
I'm not a programmer by trade, not an api expert. I'm just wondering why so many calls like this? Can the entire text be sent as an array of lines with the 'to' and 'from' params set?

Update: At first it appeared like it might be something perhaps unintentional but appears the logic is as you have designed. I think just for my long term application I would try to split the text myself, if necessary and send the entire thing with one call.

Hello,

you are absolutely right.

You are on the feature-keep-line-breaks branch, right? This is a feature branch which means I use it to implement a new feature and once it has been implemented I will merge this branch into the master branch. But currently it is still a work in progress.

That's why the feature is listed in the to-do-issue ( #1 ):

Keep line breaks (state: work in progress)

And it also has its own issue to track the progress in greater detail: #1
There is an entry dealing with the topic that you have described:

Avoid individual split-sentence calls for all lines

So this is one of the open tasks and I will (try to) implement it in the near feature. However, thank you for pointing this out. This is an important improvement.

Can the entire text be sent as an array of lines with the 'to' and 'from' params set?

I do not exactly know yet how to implement this.

@scribnermj I have made some more commits to the branch https://github.com/chriskonnertz/DeepLy/tree/feature-keep-line-breaks

The "split text" API calls are now bundled to a single call.

(The code needs to be refactored but that can happen later.)

That's awesome! Can't wait to give it a try!

If you update and test it, please let me know if it works as you expect.