Open-source project
shibing624/similarity avatar
shibing624/similarity

shibing624/similarity: four granularities, six empty result sections, a jar from 2022

similarity: a text similarity calculation toolkit for Java, usable for text similarity computation, sentiment analysis and more tasks, ready to use out of the box.

1,583 stars343 forksJavaApache-2.0

At a glance

What is it?
similarity is a Java toolkit that scores word, phrase, sentence and paragraph pairs, each granularity with one recommended algorithm, plus HowNet sentiment and word2vec synonyms. The code samples are truncated and the documented dependency predates the branch by four years.
Who is it for?
similarity is a reasonable pick for Chinese text work that needs a cheap lexical scorer alongside a neural one, since every method is a static call with no model download and the corpora are published in plaintext. Weigh three things first.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 122 days ago.
What is it written in?
Mainly Java, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • shibing624/similarity1,583 ★ · -1
Star history
Repository2026-09-162026-11-15
shibing624/similarity1.6k1.6k

-1 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

One algorithm is recommended per text granularity

The feature list is organised by granularity, and each level carries exactly one recommendation in bold. For words it is cilin encoding, computed from the synonym word forest and reached at org.xm.Similarity.cilinSimilarity, with the Chinese semantic method, HowNet word similarity and literal edit distance listed unmarked as alternatives. For phrases it is the simple phrase method, which the text explains as counting shared characters and shared character positions. For sentences it is the part-of-speech and word-order method at org.xm.similarity.morphoSimilarity, which considers both identical literal text and the order it appears in, sitting alongside three edit distance variants including one spelled Gregor in both the feature list and the method name. For paragraphs it is cosine similarity at org.xm.similarity.text.CosineSimilarity, which tokenizes, weights by term frequency and part-of-speech weight, then compares with cosine. That level is where the choice stops being made for you: eight more methods sit under it, from Jaccard and Jaro through Jaro-Winkler, Manhattan distance, SimHash with Hamming distance and the Sorensen-Dice coefficient, none of them marked.

The same method name is given to the sentence and paragraph recommendations

The sentence-level recommendation and the paragraph-level recommendation are announced with one identical Chinese name, the part-of-speech and word-order method, while the two classes they point at are unrelated: org.xm.similarity.morphoSimilarity and org.xm.similarity.text.CosineSimilarity. A reader who searches the documentation for that name finds two different algorithms. The descriptions do separate them, since the paragraph one is explicitly about tokenizing and cosine weighting, but the heading text is shared. The same collision of naming and code shows up at the word level in reverse. The demo calls four methods, cilinSimilarity, pinyinSimilarity, conceptSimilarity and charBasedSimilarity, and pinyinSimilarity has no entry in the feature list at all, so a pinyin comparison is available in the test tree without being announced as a capability.

Six demo sections, and only one of them prints a number

The demonstrations are numbered one to six, covering word, phrase, sentence, paragraph, sentiment and synonyms. Five of them end with a result heading followed by nothing, so a reader is told a value exists and then given none. The sixth, the paragraph section, is the exception and the only place in the repository with published output:

shell
cos相似度分值:0.399143
edit相似度分值:0.0875

Two numbers for one pair of news paragraphs, cosine against edit distance, and they disagree by a factor of about four and a half. That paragraph section is also the only one with a stated size envelope, one paragraph being between 25 and 500 characters, which is the kind of constraint that would be useful in the other sections too. The Java snippets themselves are cut mid-statement: the word demo ends on a lone capital S after its first print, the sentence demo after two of its four scorers, and the paragraph demo after the second print call.

Installation is a JitPack coordinate, and Gradle gets a link

The Maven route needs two blocks, a repository entry pointing at jitpack.io and then the dependency itself:

xml
<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>
xml
<dependency>
  <groupId>com.github.shibing624</groupId>
  <artifactId>similarity</artifactId>
  <version>1.1.6</version>
</dependency>

The groupId is the com.github plus owner form, which is the signature of a jar built from the repository by JitPack rather than one pushed to Maven Central, so the build happens on first resolution rather than from a central index. The Gradle subsection offers no snippet at all, only a link to the JitPack build page for this repository, which leaves the Gradle reader to translate the XML above. The working example that follows covers both halves of the library in one class, a word similarity call and a HowNet tendency call:

java
import org.xm.Similarity;
import org.xm.tendency.word.HownetWordTendency;

public class demo {
    public static void main(String[] args) {
        double result = Similarity.cilinSimilarity("电动车", "自行车");
        System.out.println(result);

        String word = "混蛋";
        HownetWordTendency hownetWordTendency = new HownetWordTendency();
        result = hownetWordTendency.getTendency(word);
        System.out.println(word + "  词语情感趋势值:" + result);
    }
}

The published jar is from April 2022 and the branch moved in July 2026

Two tags exist: 1.1.4 published 2022-02-18, with an empty release name, and 1.1.6 published 2022-04-12. The README's dependency snippet pins 1.1.6, so the version every reader copies is the one from April 2022. The last recorded push on the default branch, which is master rather than main, is 2026-07-16, more than four years later. Nothing in the text bridges that gap: there is no snapshot coordinate, no unreleased note and no changelog pointer, so a caller pinning the documented version is four years behind the source tree no matter what the branch contains. The top-level listing is short, corpus/, data/, docs/, pom.xml, src/ and a CITATION.cff, which means the lexicons and corpora are expected to live in the repository rather than in a separate download.

The word2vec path needs a model the tree does not carry

The synonym section calls Word2vec.getHomoionym with a constant named RAW_CORPUS_SPLIT_MODEL and a count of ten, and the method name is misspelled the same way in the test class that exercises it. Nothing in the top-level listing is a model file, and the constant is never given a path, so the demo cannot be run from a fresh clone without supplying that model yourself. The text does say where it comes from: training runs through a separate Java word2vec project, the corpus used is the novel Demi-Gods and Semi-Devils, and users may train their own corpus or use Chinese Wikipedia for general-purpose vectors. The design notes list lazy model loading as one of four principles, next to low module coupling, plaintext dictionaries and fresh corpora, which is consistent with a model that is read on first use and never bundled. No model size, load time or vector dimension appears anywhere.

The sentiment section names a better implementation of itself

Word polarity comes from a HowNet sememe tree through org.xm.tendency.word.HownetWordTendency, returning positive tendency, negative tendency and overall tendency, and the demo asks about one positive word and one insult. In the same paragraph the text points elsewhere for text-level work, naming a separate classifier project and saying that deep neural network models and an SVM classifier do better. That is the project recommending a successor to its own second-most-advertised feature, and it does so without a version, a benchmark or a migration note. The checked Todo list closes the same way. All three items are ticked, keyword matching with TF-IDF and BM25, shallow semantic matching by summing word2vec or GloVe vectors into a sentence vector, and deep semantic models from DSSM through ARC-II plus BERT-era SentenceBERT and CoSENT, yet the feature list above announces none of the first two groups as available.

Editorial conclusion

similarity is a reasonable pick for Chinese text work that needs a cheap lexical scorer alongside a neural one, since every method is a static call with no model download and the corpora are published in plaintext. Weigh three things first. The dependency snippet everyone copies pins 1.1.6 from April 2022 while the master branch was pushed in July 2026, so the artifact predates the source. The word2vec path needs a trained model that the tree does not carry. And six of the seven demo sections end with a result heading and no output, so the only pair of published numbers in the repository is a cosine score of 0.399143 against 0.0875 for edit distance on one pair of paragraphs.

Frequently asked questions

Which word similarity method does shibing624/similarity recommend?

The cilin encoding method, called as org.xm.Similarity.cilinSimilarity and computed from the synonym word forest. Three more word-level methods are listed without a recommendation: the Chinese semantic method, HowNet word similarity and literal edit distance.

How is the similarity library added to a Maven build?

With a repository entry pointing at jitpack.io and the dependency com.github.shibing624:similarity:1.1.6. The Gradle subsection links to the JitPack build page instead of giving a snippet, so Gradle users translate that XML themselves.

What numbers does similarity publish for a paragraph comparison?

One pair, in the paragraph section: a cosine similarity of 0.399143 against 0.0875 for edit distance on the same two news paragraphs. A paragraph is defined as between 25 and 500 characters. The other five demo sections end with a result heading and no output.

Does the similarity repository ship a word2vec model?

Not at the top level. The demo passes a constant named RAW_CORPUS_SPLIT_MODEL to Word2vec.getHomoionym and the path is never given. Training runs through a separate Java word2vec project, the sample corpus is the novel Demi-Gods and Semi-Devils, and users may train their own corpus or use Chinese Wikipedia.

How old is the published similarity release?

The newest tag is 1.1.6, published 2022-04-12, after 1.1.4 from 2022-02-18. The README's own Maven snippet pins 1.1.6, while the last recorded push on the master branch is 2026-07-16.

Official sources

  1. License: Apache-2.0
  2. Project website
  3. README
  4. Releases
  5. shibing624/similarity on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/shibing624-similarity.svg)](https://hysenlabs.com/projects/shibing624-similarity)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/shibing624-similarity.svg)](https://hysenlabs.com/projects/shibing624-similarity)

Was this useful?