Code Monkey home page Code Monkey logo

full-cloud-pinyin's Introduction

Peek 2024-01-04 20-32

Full Cloud Pinyin is an input method that uses Google Input Tools as the backend. It uses fcitx5-bridge so you can type pinyin with excellent prediction on Linux with Fcitx5. Historically, a version made with IBus is also available here.

Why?

I want an input method that provides good prediction. The pinyin came close but compared Google Input Tools, it still has room to improve. So why not bridge Google Input Tools to Linux desktop? To do this, we need two parts:

  1. fcitx5-bridge that allows talking to Fcitx5 on your Linux desktop (see above links).
  2. a input method that takes your keyboard input to Google Input Tools and gets the candidates back (this project).

Features

For Pinyin:

  • Self-made phrase support
  • Caching support (so for a given pinyin, it only access the Internet the first time you type it)

For Nepali:

  • Caching support (no self-made phrase support becasue Google Input Tools lacks this feature for Nepali)

Installation

Go to releases and see instruction there. If you are using Ubuntu that has outdated glibc, you might need to compile from source. To do that:

  1. Ensure you can build fcitx5-bridge.
  2. Read release.nu and install Nushell (you do not need to set it as your default shell). Run release.nu to build and follow instructions in releases.

full-cloud-pinyin's People

Contributors

qingxiang-jia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

full-cloud-pinyin's Issues

Offline usage

Google Input Tools was available on windows as separate offline client. Is there any way we can leverage that to use it without internet and integrate with this project?

Pressing SHIFT should not terminate input session

We used to use SHIFT to turn on and off the input method. But handling it along with using SHIFT to enter uppercase letter making it hard to handle. So we now use CTRL to do it. But now if you press CTRL, nothing happens and if you press SHIFT, the input session terminates.

It should be:

  • Pressing SHIFT: no effect.
  • Pressing CTRL: input session terminates.

Build error in latest changes

parallels@ubuntu-linux-22-04-desktop:~/projects/full-cloud-pinyin$ cargo build 
   Compiling fcp v0.1.0 (/home/parallels/projects/full-cloud-pinyin)
error[E0659]: `zmq` is ambiguous
  --> src/main.rs:3:5
   |
3  | use zmq::Server;
   |     ^^^ ambiguous name
   |
   = note: ambiguous because of multiple potential import sources
   = note: `zmq` could refer to a crate passed with `--extern`
   = help: use `::zmq` to refer to this crate unambiguously
note: `zmq` could also refer to the module defined here
  --> src/main.rs:14:1
   |
14 | pub mod zmq;
   | ^^^^^^^^^^^^
   = help: use `crate::zmq` to refer to this module unambiguously

For more information about this error, try `rustc --explain E0659`.
error: could not compile `fcp` (bin "fcp") due to previous error

Crash when typing too fast

This is for the Fcitx 5 based full cloud pinyin. When I type too fast, it crashes. The stack trace is:

Fcitx 5.0.19 -- Get Signal No.: 11
Date: try "date -d @1666271367" if you are using GNU date ***
ProcessID: 7764
fcitx5(+0x12d9c)[0x55a39f4c4d9c]
/usr/lib/libc.so.6(+0x38a00)[0x7ff5a297aa00]
/usr/lib/libFcitx5Core.so.7(_ZN5fcitx20UserInterfaceManager5flushEv+0x7e)[0x7ff5a2f0f2be]
/usr/lib/libFcitx5Core.so.7(_ZNK5fcitx8Instance9postEventERNS_5EventE+0x3c8)[0x7ff5a2ebd578]
/usr/lib/libFcitx5Core.so.7(_ZN5fcitx12InputContext8keyEventERNS_8KeyEventE+0xa6)[0x7ff5a2edfbb6]
/usr/lib/fcitx5/libdbusfrontend.so(+0x12cca)[0x7ff5a1338cca]
/usr/lib/fcitx5/libdbusfrontend.so(+0x133d4)[0x7ff5a13393d4]
/usr/lib/libFcitx5Utils.so.2(+0x3e2ea)[0x7ff5a2dfe2ea]
/usr/lib/libsystemd.so.0(+0x36d6d)[0x7ff5a284bd6d]
/usr/lib/libsystemd.so.0(+0x460b3)[0x7ff5a285b0b3]
/usr/lib/libsystemd.so.0(+0x4dfe8)[0x7ff5a2862fe8]
/usr/lib/libsystemd.so.0(+0x799ab)[0x7ff5a288e9ab]
/usr/lib/libsystemd.so.0(sd_event_dispatch+0x116)[0x7ff5a2898ff6]
/usr/lib/libsystemd.so.0(sd_event_run+0x119)[0x7ff5a2899279]
/usr/lib/libsystemd.so.0(sd_event_loop+0x60)[0x7ff5a2899450]
/usr/lib/libFcitx5Utils.so.2(_ZN5fcitx9EventLoop4execEv+0x16)[0x7ff5a2dfceb6]
/usr/lib/libFcitx5Core.so.7(_ZN5fcitx8Instance4execEv+0x57)[0x7ff5a2ec00e7]
fcitx5(+0x10fa0)[0x55a39f4c2fa0]
/usr/lib/libc.so.6(+0x23290)[0x7ff5a2965290]
/usr/lib/libc.so.6(__libc_start_main+0x8a)[0x7ff5a296534a]
fcitx5(+0x12375)[0x55a39f4c4375]
fish: Job 1, 'fcitx5' terminated by signal SIGSEGV (Address boundary error)

I couldn't figure out why. So I asked the author of Fcitx 5. He helped me (really appreciate!) and here his analysis:

  1. We don't need to use immediate when calling InputContext::updateUserInterface (I did so to solve the candidate not updated to latest issue)
  2. We shouldn't not call any functions from fcitx instance.
  3. call_async here is just multi-threading (can be seen from stacktrace below).
    ==146789==    by 0x4DE62F2: execute_native_thread_routine (thread.cc:82)
    ==146789==    by 0x50D58FC: start_thread (pthread_create.c:442)
    ==146789==    by 0x5156C73: clone (clone.S:100)
    

If we need to call anything on fictx instance, call it on the main thread using: https://codedocs.xyz/fcitx/fcitx5/classfcitx_1_1EventDispatcher.html

Also, from https://en.cppreference.com/w/cpp/thread/async,
The function template async runs the function f asynchronously (potentially in a separate thread which might be a part of a thread pool) and returns a std::future that will eventually hold the result of that function call.

[Refactor] Pipeline architecture

So far, except for determining English/Pinyin mode, we put all logic together. It's a lot to keep in mind during development. We want to separate concerns. Currently, the plan is to do something similar to this:

New Architecture drawio(1)

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.