EntityIdentification
A MCP server that helps determine if two sets of data belong to the same entity by comparing both exact and semantic equality through text normalization and language model integration.
README
EntityIdentification
Identify whether two sets of data are from the same entity. 识别两组数据是否来自同一主体
This is a MCP (Model Context Protocol) server. 这是一个支持MCP协议的服务器。
Data Comparison Tool
This tool provides a comprehensive way to compare two sets of data, evaluating both exact and semantic equality of their values. It leverages text normalization and a language model to determine if the data originates from the same entity.
Features
- Text Normalization: Converts text to lowercase, removes punctuation, and normalizes whitespace.
- Value Comparison: Compares values directly and semantically (ignoring order for lists).
- JSON Traversal: Iterates through each key in the JSON objects and compares corresponding values.
- Language Model Integration: Uses a generative language model to assess semantic similarity and provide a final judgment on whether the data comes from the same entity.
Installation
To use this tool, ensure you have the necessary dependencies installed. You can install them using pip:
pip install genai
Usage
Functions
-
normalize_text(text):
- Normalizes the input text by converting it to lowercase, removing punctuation, and normalizing whitespace.
-
compare_values(val1, val2):
- Compares two values both exactly and semantically.
- If the values are lists, it ignores the order of elements for semantic comparison.
-
compare_json(json1, json2):
- Compares two JSON objects key by key.
- Uses
compare_valuesto evaluate each key's values. - Integrates a language model to assess semantic similarity and provides a final judgment.
Example
import json
import genai
import re
# Define your JSON objects
json1 = {
"name": "John Doe",
"address": "123 Main St, Anytown, USA",
"hobbies": ["reading", "hiking", "coding"]
}
json2 = {
"name": "john doe",
"address": "123 Main Street, Anytown, USA",
"hobbies": ["coding", "hiking", "reading"]
}
# Compare the JSON objects
comparison_results = compare_json(json1, json2)
# Generate final matching result
model1 = genai.GenerativeModel("gemini-2.0-flash-thinking-exp")
result_matching = model1.generate_content("综合这些信息,你认为可以判断两个数据来自同一主体吗?"+json.dumps(comparison_results, ensure_ascii=False, indent=4))
print(result_matching.text)
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
If you have any questions or suggestions, please contact me:
- Email: u3588064@connect.hku.hk
- GitHub: u3588064@connect.hku.hk。
Wechat
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.