Git Product home page Git Product logo

libime-history-merge's Introduction

libime-history-merge

libime-history-merge is a simple CLI for inspecting, merging and editing libime pinyin histories from multiple machines.

Usage

Inspecting Your History Data

Your fcitx5 pinyin input method history typically resides at ~/.local/share/fcitx5/pinyin/user.history. To inspect it, supply its path to libime-history-merge:

$ libime-history-merge ~/.local/share/fcitx5/pinyin/user.history

A pager will be invoked for you to inspect your input history in plain text, passing a -n|--no-pager flag or redirecting output will suppress the pager.

NOTE

You can check the dumped plain text history data's integrity by comparing it with the libime_history tool provided by libime:

$ libime_history ~/.local/share/fcitx5/pinyin/user.history >/tmp/text1
$ libime-history-merge ~/.local/share/fcitx5/pinyin/user.history >/tmp/text2
$ diff /tmp/text1 /tmp/text2 && echo $?
  0

Compiling from Plain Text

libime-history-merge is able to compile a plain-text file into a history blob. An example:

$ # Dump the history content as plain text to ./history.txt
$ cp ~/.local/share/fcitx5/pinyin/user.history original.history
$ libime-history-merge original.history >history.txt
$
$ # Show the history content in plain text
$ cat history.txt
$
$ # Compile the plain-text history back to the binary form and save as ./compiled.history
$ libime-history-merge history.txt -o compiled.history
$
$ # Check integrity
$ diff original.history compiled.history && echo $?
  0

Editing Your History Data

libime-history-merge also allows you to edit your history entries. To achive so, simply supply the -e|--edit flag:

$ libime-history-merge user.history --edit --output ./out.history

An editor (possibly specified by the VISUAL or EDITOR environment variable) will open up with the history content in plain text. It is then possible to delete/insert history entries. After saving and quiting the editor, libime-history-merge will compile the plain text history back to a libime-compatible form and save it to the specified output path (./out.history in this case).

Merging History Data from Multiple Machines

Balanced Merge

Pass the -o|--output option to specify saving path:

$ libime-history-merge \
    machine1.history machine2.history machine3.history \
    -o merged.history
$ libime-history-merge merged.history  # Inspect the merged history

libime-history-merge will mix the input histories uniformly.

Weighted Merge

It's also possible to do a weighted merge by passing the weights via the -w|--weights option:

$ libime-history-merge \
    A.history B.history C.history \
    -w 2,5,3 \
    -o merged.history
$ libime-history-merge merged.history  # Inspect the merged history

libime-history-merge will mix the input histories with the specified priority, in this case, the first 10 entries of the merged history will be:

B[0]
C[0]
B[0]
C[0]
A[0]
B[1]
C[1]
B[1]
C[1]
A[1]

where X[k] stands for the k-th entry from X.history.

NOTE

A balanced merge in the previous example is equiavalent to specifying identical weights to each input history, e.g. -w 3,3,3.

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.