dennis-tra / alfred-dict.cc-workflow

🌍 Alfred 4/5 workflow to get translations from dict.cc
137 stars 4 forks source link

Translation for words present in both languages not working correctly #1

Open Ruko2010 opened 5 years ago

Ruko2010 commented 5 years ago

If you have an input word that is present in both languages, the result is not as expected. For Example: dict de en test should output the english translation of test. But it outputs the german ones first: image

If I switch both languages the result stays the same: dict en de test image

Is this an API issue of dict.cc, or a workflow problem?

natterstefan commented 4 years ago

Hi @Ruko2010, were you able to resolve this?

Ruko2010 commented 4 years ago

Sorry, I tried nothing. I was waiting for a response here, so no, no solution yet.

dennis-tra commented 3 years ago

Hi @Ruko2010,

sorry for the late reply. I didn't have notifications enabled for this repo and I'm not checking in that often. Now I'm watching all activity.

Unfortunately the order of languages you're specifying doesn't influence the output. It just indicates in which languages you're interested.

Under the hood the workflow just calls https://www.dict.cc/?s={your-word} and parses the HTML. The page has two columns and to display the results I'm using a simple heuristic. If the word you've entered appears more often in the left column then that's probably the source-language and you're interested in the right results (the target-language).

Now if you're opening https://www.dict.cc/?s=test you see that the left column contains more direct matches to the word test, so the right column will be printed bold as the result.

Is it possible to fix this? Definitely. I'm happy with the 80:20 approach of the simple heuristic, though.

If anyone is interested in improving this workflow I'm more than happy to accept contributions.

Best, Dennis