Coder Social home page Coder Social logo

Cannot catch the typing about linggle_alfred HOT 10 CLOSED

0dd avatar 0dd commented on June 12, 2024
Cannot catch the typing

from linggle_alfred.

Comments (10)

liqilei avatar liqilei commented on June 12, 2024 1

Many thanks for your reply.

Indeed, this issues was caused by the python version incompatibility.

Based on your helpful suggestion, I managed to solve this problem by setting the workflow interpreter to my python2 env.

Regards
image

from linggle_alfred.

0dd avatar 0dd commented on June 12, 2024

I have python2 in build and requests already
Screen Shot 2019-08-29 at 1 28 54 PM

from linggle_alfred.

SXKDZ avatar SXKDZ commented on June 12, 2024

I implement this plugin in Python 3. It seems that the program exits when you type the commands. Would you please just upgrade your Python and try again?

from linggle_alfred.

0dd avatar 0dd commented on June 12, 2024

I believe I have installed python3 also, it still did not work as expect.

Another thing is about I query the json directly bymy own python program, it also do not work well either
Screen Shot 2019-09-05 at 12 06 09 AM
Screen Shot 2019-09-05 at 12 03 07 AM

Is there any other thing that I need to consider about?

from linggle_alfred.

SXKDZ avatar SXKDZ commented on June 12, 2024

I believe the two outputs are consistent with the behavior when you type the two words in Linggle website. It seems that feeding a single word to Linggle receives no results so you may need to query some more complex phrases. BTW, when you input a single word like that, can your Alfred show a "Visit Linggle" bar? If it doesn't, I suspect that there must be something wrong with Alfred itself as the Python script runs as expected...

from linggle_alfred.

liqilei avatar liqilei commented on June 12, 2024

Hi, I also meet the same issue. Please can I ask if you have found any solution for this problem.

from linggle_alfred.

SXKDZ avatar SXKDZ commented on June 12, 2024

Hi, I also meet the same issue. Please can I ask if you have found any solution for this problem.

Have you tried the newest commit version?

from linggle_alfred.

liqilei avatar liqilei commented on June 12, 2024

Thanks for your reply.
I'm using the latest version (v1.2).
My Alfred version is 4.3.4 [1229].
My python version is 3.8.4 with the requests version of 2.25.1.
Also, I attach the screenshots for the issue and my config.
WX20210629-161852@2x
WX20210629-161904@2x

from linggle_alfred.

SXKDZ avatar SXKDZ commented on June 12, 2024

Thanks for your reply.
I'm using the latest version (v1.2).
My Alfred version is 4.3.4 [1229].
My python version is 3.8.4 with the requests version of 2.25.1.
Also, I attach the screenshots for the issue and my config.
WX20210629-161852@2x
WX20210629-161904@2x

Thanks for your detailed information! From your screenshot I guess that the python script you run exits abnormally.
I find that I have made a mistake in my reply to 0dd. The Alfred workflow Python framework only works for Python 2. Therefore, you have to make sure in your environment python links to Python 2.

You can manually test the core functionality using the following snippet:

import sys
import json
import time
import requests

if __name__ == '__main__':
    s = requests.Session()

    query = 'apple'
    query_load = requests.utils.quote(query)

    answer = s.get('https://linggle.com/api/ngram/{}'.format(query_load)).json()
    if len(answer['ngrams']) == 0:
        print('No results!')
    else:
        total = 0
        for item in answer['ngrams']:
            total += item[1]
        
        for item in answer['ngrams'][:20]:
            phrase = item[0]
            subtitle = '{:.2f}% | {}'.format(float(item[1]) * 100 / total, item[1])
            print(query, subtitle)

which should give output like

('apple', '100.00% | 6878789')

from linggle_alfred.

SXKDZ avatar SXKDZ commented on June 12, 2024

Many thanks for your reply.

Indeed, this issues was caused by the python version incompatibility.

Based on your helpful suggestion, I managed to solve this problem by setting the workflow interpreter to my python2 env.

Regards
image

Happy to see you have resolved the problem!

from linggle_alfred.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.