From 8b96a3f0569db9da265d32b222303acfc78bf1ef Mon Sep 17 00:00:00 2001
From: Gus
-
-
+
+
@@ -35,6 +35,7 @@
+
😭 [GraphRAG](https://arxiv.org/pdf/2404.16130) is good and powerful, but the official [implementation](https://github.com/microsoft/graphrag/tree/main) is difficult/painful to **read or hack**.
😊 This project provides a **smaller, faster, cleaner GraphRAG**, while remaining the core functionality(see [benchmark](#benchmark) and [issues](#Issues) ).
From 70bbb67ef12fb4efdd7ab0943a84af39f719128b Mon Sep 17 00:00:00 2001
From: knightmarehs Customize Chunking
+`nano-graphrag` allow you to customize your own chunking method, check out the [example](./examples/using_custom_chunking_method.py).
+
+Switch to the built-in text splitter chunking method:
+
+```python
+from nano_graphrag._op import chunking_by_seperators
+
+GraphRAG(...,chunk_func=chunking_by_seperators,...)
+```
+
+LLM Function
diff --git a/tests/test_splitter.py b/tests/test_splitter.py
index 551de01..c20fbe6 100644
--- a/tests/test_splitter.py
+++ b/tests/test_splitter.py
@@ -1,22 +1,26 @@
import unittest
from typing import List
-
-from nano_graphrag._spliter import SeparatorSplitter
+import tiktoken
+from nano_graphrag._splitter import SeparatorSplitter
+from nano_graphrag._op import chunking_by_seperators
# Assuming the SeparatorSplitter class is already imported
+
class TestSeparatorSplitter(unittest.TestCase):
def setUp(self):
- self.tokenize = lambda text: [ord(c) for c in text] # Simple tokenizer for testing
- self.detokenize = lambda tokens: ''.join(chr(t) for t in tokens)
+ self.tokenize = lambda text: [
+ ord(c) for c in text
+ ] # Simple tokenizer for testing
+ self.detokenize = lambda tokens: "".join(chr(t) for t in tokens)
def test_split_with_custom_separator(self):
splitter = SeparatorSplitter(
- separators=[self.tokenize('\n'), self.tokenize('.')],
+ separators=[self.tokenize("\n"), self.tokenize(".")],
chunk_size=19,
chunk_overlap=0,
- keep_separator="end"
+ keep_separator="end",
)
text = "This is a test.\nAnother test."
tokens = self.tokenize(text)
@@ -30,24 +34,17 @@ def test_split_with_custom_separator(self):
def test_chunk_size_limit(self):
splitter = SeparatorSplitter(
- chunk_size=5,
- chunk_overlap=0,
- separators=[self.tokenize("\n")]
+ chunk_size=5, chunk_overlap=0, separators=[self.tokenize("\n")]
)
text = "1234567890"
tokens = self.tokenize(text)
- expected = [
- self.tokenize("12345"),
- self.tokenize("67890")
- ]
+ expected = [self.tokenize("12345"), self.tokenize("67890")]
result = splitter.split_tokens(tokens)
self.assertEqual(result, expected)
def test_chunk_overlap(self):
splitter = SeparatorSplitter(
- chunk_size=5,
- chunk_overlap=2,
- separators=[self.tokenize("\n")]
+ chunk_size=5, chunk_overlap=2, separators=[self.tokenize("\n")]
)
text = "1234567890"
tokens = self.tokenize(text)
@@ -59,5 +56,17 @@ def test_chunk_overlap(self):
result = splitter.split_tokens(tokens)
self.assertEqual(result, expected)
-if __name__ == '__main__':
- unittest.main()
\ No newline at end of file
+ def test_chunking_by_seperators(self):
+ encoder = tiktoken.encoding_for_model("gpt-4o")
+ text = "This is a test.\nAnother test."
+ tokens_list = [encoder.encode(text)]
+ doc_keys = ["doc1"]
+ results = chunking_by_seperators(tokens_list, doc_keys, encoder)
+ assert len(results) == 1
+ assert results[0]["chunk_order_index"] == 0
+ assert results[0]["full_doc_id"] == "doc1"
+ assert results[0]["content"] == text
+
+
+if __name__ == "__main__":
+ unittest.main()
From 7374c4f336b3e210567069016cd7f78fd52fad60 Mon Sep 17 00:00:00 2001
From: Gus Customize Chunking
+
+
`nano-graphrag` allow you to customize your own chunking method, check out the [example](./examples/using_custom_chunking_method.py).
Switch to the built-in text splitter chunking method:
From 9b5d0d13f614cc92420a85d298f459cc6944b40c Mon Sep 17 00:00:00 2001
From: Gus \n",
+ "
\n",
" \n",
"
\n"
],
"text/plain": [
- "\n",
" \n",
" \n",
" \n",
" \n",
- " input_text \n",
- " example_entities \n",
- " example_relationships \n",
- " pred_entities \n",
- " pred_relationships \n",
- " entity_recall_metric \n",
+ " input_text \n",
+ " example_entities \n",
+ " example_relationships \n",
+ " pred_entities \n",
+ " pred_relationships \n",
+ " entity_recall_metric \n",
" \n",
- " \n",
+ " 0 \n",
- " As students from Marjory Stoneman Douglas High School confront lawmakers with demands to restrict sales of assault rifles, there were warnings by the president of... \n",
- " context=[Entity(entity_name='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', entity_type='ORGANIZATION', description='A high school in Florida where a mass shooting occurred.', importance_score=0.9), Entity(entity_name='NIKOLAS CRUZ', entity_type='PERSON', description='The gunman who carried out... \n",
- " context=[Relationship(src_id='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', tgt_id='NIKOLAS CRUZ', description='Nikolas Cruz carried out a mass shooting at Marjory Stoneman Douglas High School.', weight=0.9, order=1), Relationship(src_id='NIKOLAS CRUZ', tgt_id='FLORIDA',... \n",
- " context=[Entity(entity_name='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', entity_type='ORGANIZATION', description='A high school in Florida where a mass shooting occurred.', importance_score=0.9), Entity(entity_name='NIKOLAS CRUZ', entity_type='PERSON', description='The gunman who carried out... \n",
- " context=[Relationship(src_id='NIKOLAS CRUZ', tgt_id='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', description='Nikolas Cruz carried out a mass shooting at Marjory Stoneman Douglas High School.', weight=0.9, order=1), Relationship(src_id='LAURENZO PRADO', tgt_id='MARJORY... \n",
- " ✔️ [0.8055555555555556] \n",
+ " 0 \n",
+ " As students from Marjory Stoneman Douglas High School confront lawmakers with demands to restrict sales of assault rifles, there were warnings by the president of... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where students confronted lawmakers about restricting sales of assault rifles.', 'importance_score':... \n",
+ " [{'src_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'tgt_id': 'FLORIDA', 'description': 'Students from Marjory Stoneman Douglas High School are located in the state of Florida.', 'weight': 0.9,... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where students confronted lawmakers about assault rifle sales.', 'importance_score': 0.9}, {'entity_name':... \n",
+ " [{'src_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'tgt_id': 'FLORIDA', 'description': 'Marjory Stoneman Douglas High School is located in Florida.', 'weight': 0.9, 'order': 1}, {'src_id': 'LAURENZO PRADO',... \n",
+ " ✔️ [0.6666666666666666] \n",
+ " \n",
+ " \n",
+ " 1 \n",
+ " From ferrying people to and from their place of work to transporting nuclear waste and coal, railways are not only an integral part of 21st... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels whose clients include Deutsche Bahn and French rail operator SNCF.', 'importance_score': 0.9}, {'entity_name': 'DEUTSCHE... \n",
+ " [{'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description': 'Railnova provides technology solutions to Deutsche Bahn.', 'weight': 0.9, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'SNCF', 'description': 'Railnova provides technology... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels whose clients include Deutsche Bahn and French rail operator SNCF.', 'importance_score': 0.9}, {'entity_name': 'DEUTSCHE... \n",
+ " [{'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description': 'Railnova provides technology solutions to Deutsche Bahn.', 'weight': 0.8, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'SNCF', 'description': 'Railnova provides technology... \n",
+ " ✔️ [0.8888888888888888] \n",
+ " \n",
+ " \n",
" 2 \n",
+ " Jan 22 (Reuters) - Shanghai Stock Exchange Filing * SHOWS BLOCK TRADE OF YONGHUI SUPERSTORES Co LTd's 166.3 MILLION SHARES INVOLVING 1.63 BILLION YUAN ($254.68... \n",
+ " [{'entity_name': 'YONGHUI SUPERSTORES CO LTD', 'entity_type': 'ORGANIZATION', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'importance_score': 1.0}, {'entity_name':... \n",
+ " [{'src_id': 'YONGHUI SUPERSTORES CO LTD', 'tgt_id': '166.3 MILLION SHARES', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'weight':... \n",
+ " [{'entity_name': 'SHANGHAI STOCK EXCHANGE', 'entity_type': 'ORGANIZATION', 'description': 'The Shanghai Stock Exchange is a stock exchange located in Shanghai, China.', 'importance_score': 0.9}, {'entity_name': 'YONGHUI SUPERSTORES CO... \n",
+ " [{'src_id': 'SHANGHAI STOCK EXCHANGE', 'tgt_id': 'YONGHUI SUPERSTORES CO LTD', 'description': 'The Shanghai Stock Exchange filed a block trade involving YONGHUI SUPERSTORES Co Ltd.', 'weight': 0.9,... \n",
+ " ✔️ [0.8] \n",
" \n",
- " \n",
" 1 \n",
- " From ferrying people to and from their place of work to transporting nuclear waste and coal, railways are not only an integral part of 21st... \n",
- " context=[Entity(entity_name='RAILWAYS', entity_type='VEHICLE', description='Transportation system used for ferrying people and transporting nuclear waste and coal.', importance_score=0.9), Entity(entity_name='BELGIUM', entity_type='LOCATION', description='Country where a business is looking to innovate... \n",
- " context=[Relationship(src_id='RAILNOVA', tgt_id='BRUSSELS', description='Railnova is based in Brussels.', weight=0.9, order=1), Relationship(src_id='RAILNOVA', tgt_id='DEUTSCHE BAHN', description='Railnova serves Deutsche Bahn as a client.', weight=0.8, order=1), Relationship(src_id='RAILNOVA', tgt_id='SNCF', description='Railnova serves... \n",
- " context=[Entity(entity_name='RAILWAYS', entity_type='VEHICLE', description='A mode of transportation that involves trains running on tracks, used for various purposes including passenger and cargo transport.', importance_score=0.9), Entity(entity_name='BELGIUM', entity_type='LOCATION', description='A... \n",
- " context=[Relationship(src_id='RAILNOVA', tgt_id='DEUTSCHE BAHN', description='Railnova provides innovative technology solutions to Deutsche Bahn, a German railway company.', weight=0.8, order=1), Relationship(src_id='RAILNOVA', tgt_id='SNCF', description='Railnova offers its technology services to... \n",
- " ✔️ [0.8095238095238095] \n",
+ " 3 \n",
+ " LONDON (Reuters) - Britain’s economy was weaker than previously thought in 2017, official data showed on Thursday, leaving the country lagging further behind the global... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy was weaker than previously thought in 2017.', 'importance_score': 0.9}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.9, 'order': 1}, {'src_id': 'BANK OF ENGLAND', 'tgt_id': 'INTEREST RATES',... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy is discussed in the text.', 'importance_score': 1.0}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The political and... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.9, 'order': 1}, {'src_id': 'BRITAIN', 'tgt_id': 'BANK OF ENGLAND', 'description':... \n",
+ " ✔️ [1.0] \n",
" \n",
- " \n",
" \n",
"2 \n",
- " Jan 22 (Reuters) - Shanghai Stock Exchange Filing * SHOWS BLOCK TRADE OF YONGHUI SUPERSTORES Co LTd's 166.3 MILLION SHARES INVOLVING 1.63 BILLION YUAN ($254.68... \n",
- " context=[Entity(entity_name='YONGHUI SUPERSTORES', entity_type='ORGANIZATION', description='A company involved in a block trade of its shares.', importance_score=0.9), Entity(entity_name='SHANGHAI STOCK EXCHANGE', entity_type='ORGANIZATION', description='The stock exchange where the block trade... \n",
- " context=[Relationship(src_id='YONGHUI SUPERSTORES', tgt_id='SHANGHAI STOCK EXCHANGE', description=\"YONGHUI SUPERSTORES' shares were traded on the SHANGHAI STOCK EXCHANGE.\", weight=0.9, order=1), Relationship(src_id='YONGHUI SUPERSTORES', tgt_id='166.3 MILLION SHARES', description='YONGHUI SUPERSTORES was... \n",
- " context=[Entity(entity_name='YONGHUI SUPERSTORES', entity_type='ORGANIZATION', description='A company involved in a block trade of its shares.', importance_score=0.9), Entity(entity_name='SHANGHAI STOCK EXCHANGE', entity_type='ORGANIZATION', description='The stock exchange where the block trade... \n",
- " context=[Relationship(src_id='YONGHUI SUPERSTORES', tgt_id='166.3 MILLION SHARES', description='YONGHUI SUPERSTORES was involved in a block trade of 166.3 million shares.', weight=0.9, order=1), Relationship(src_id='166.3 MILLION SHARES', tgt_id='1.63 BILLION YUAN',... \n",
- " ✔️ [0.7272727272727273] \n",
+ " 4 \n",
+ " Trump taps White House doctor as new VA secretary 2 Hours Ago CNBC's Kayla Tausche reports President Trump has tapped White House physician Rear Admiral... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'President Trump who tapped Ronny Jackson as new VA secretary.', 'importance_score': 1.0}, {'entity_name': 'WHITE HOUSE', 'entity_type': 'ORGANIZATION', 'description': 'The White... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'RONNY JACKSON', 'description': 'President Trump taps Ronny Jackson as new VA secretary.', 'weight': 1.0, 'order': 1}, {'src_id': 'RONNY JACKSON', 'tgt_id': 'VA', 'description':... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'President Trump who tapped Ronny Jackson.', 'importance_score': 0.9}, {'entity_name': 'WHITE HOUSE', 'entity_type': 'ORGANIZATION', 'description': 'The White House where Ronny Jackson... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'RONNY JACKSON', 'description': 'Trump taps Ronny Jackson.', 'weight': 0.9, 'order': 1}, {'src_id': 'RONNY JACKSON', 'tgt_id': 'DEPARTMENT OF VETERANS AFFAIRS', 'description': 'Ronny Jackson... \n",
+ " ✔️ [0.8571428571428571] \n",
" \n",
+ "
\n",
" \n",
"
\n"
],
"text/plain": [
- "\n",
" \n",
" \n",
" \n",
" \n",
- " input_text \n",
- " example_entities \n",
- " example_relationships \n",
- " pred_entities \n",
- " pred_relationships \n",
- " relationship_similarity_metric \n",
+ " input_text \n",
+ " example_entities \n",
+ " example_relationships \n",
+ " pred_entities \n",
+ " pred_relationships \n",
+ " relationships_similarity_metric \n",
" \n",
- " \n",
+ " 0 \n",
- " As students from Marjory Stoneman Douglas High School confront lawmakers with demands to restrict sales of assault rifles, there were warnings by the president of... \n",
- " context=[Entity(entity_name='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', entity_type='ORGANIZATION', description='A high school in Florida where a mass shooting occurred.', importance_score=0.9), Entity(entity_name='NIKOLAS CRUZ', entity_type='PERSON', description='The gunman who carried out... \n",
- " context=[Relationship(src_id='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', tgt_id='NIKOLAS CRUZ', description='Nikolas Cruz carried out a mass shooting at Marjory Stoneman Douglas High School.', weight=0.9, order=1), Relationship(src_id='NIKOLAS CRUZ', tgt_id='FLORIDA',... \n",
- " context=[Entity(entity_name='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', entity_type='ORGANIZATION', description='A high school in Florida where a mass shooting occurred.', importance_score=0.9), Entity(entity_name='NIKOLAS CRUZ', entity_type='PERSON', description='The gunman who carried out... \n",
- " context=[Relationship(src_id='NIKOLAS CRUZ', tgt_id='MARJORY STONEMAN DOUGLAS HIGH SCHOOL', description='Nikolas Cruz carried out a mass shooting at Marjory Stoneman Douglas High School.', weight=0.9, order=1), Relationship(src_id='LAURENZO PRADO', tgt_id='MARJORY... \n",
- " ✔️ [0.946203351020813] \n",
+ " 0 \n",
+ " As students from Marjory Stoneman Douglas High School confront lawmakers with demands to restrict sales of assault rifles, there were warnings by the president of... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where students confronted lawmakers about restricting sales of assault rifles.', 'importance_score':... \n",
+ " [{'src_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'tgt_id': 'FLORIDA', 'description': 'Students from Marjory Stoneman Douglas High School are located in the state of Florida.', 'weight': 0.9,... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where students confronted lawmakers about assault rifle sales.', 'importance_score': 0.9}, {'entity_name':... \n",
+ " [{'src_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'tgt_id': 'FLORIDA', 'description': 'Marjory Stoneman Douglas High School is located in Florida.', 'weight': 0.9, 'order': 1}, {'src_id': 'LAURENZO PRADO',... \n",
+ " ✔️ [0.45] \n",
+ " \n",
+ " \n",
+ " 1 \n",
+ " From ferrying people to and from their place of work to transporting nuclear waste and coal, railways are not only an integral part of 21st... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels whose clients include Deutsche Bahn and French rail operator SNCF.', 'importance_score': 0.9}, {'entity_name': 'DEUTSCHE... \n",
+ " [{'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description': 'Railnova provides technology solutions to Deutsche Bahn.', 'weight': 0.9, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'SNCF', 'description': 'Railnova provides technology... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels whose clients include Deutsche Bahn and French rail operator SNCF.', 'importance_score': 0.9}, {'entity_name': 'DEUTSCHE... \n",
+ " [{'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description': 'Railnova provides technology solutions to Deutsche Bahn.', 'weight': 0.8, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'SNCF', 'description': 'Railnova provides technology... \n",
+ " ✔️ [0.75] \n",
+ " \n",
+ " \n",
" 2 \n",
+ " Jan 22 (Reuters) - Shanghai Stock Exchange Filing * SHOWS BLOCK TRADE OF YONGHUI SUPERSTORES Co LTd's 166.3 MILLION SHARES INVOLVING 1.63 BILLION YUAN ($254.68... \n",
+ " [{'entity_name': 'YONGHUI SUPERSTORES CO LTD', 'entity_type': 'ORGANIZATION', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'importance_score': 1.0}, {'entity_name':... \n",
+ " [{'src_id': 'YONGHUI SUPERSTORES CO LTD', 'tgt_id': '166.3 MILLION SHARES', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'weight':... \n",
+ " [{'entity_name': 'SHANGHAI STOCK EXCHANGE', 'entity_type': 'ORGANIZATION', 'description': 'The Shanghai Stock Exchange is a stock exchange located in Shanghai, China.', 'importance_score': 0.9}, {'entity_name': 'YONGHUI SUPERSTORES CO... \n",
+ " [{'src_id': 'SHANGHAI STOCK EXCHANGE', 'tgt_id': 'YONGHUI SUPERSTORES CO LTD', 'description': 'The Shanghai Stock Exchange filed a block trade involving YONGHUI SUPERSTORES Co Ltd.', 'weight': 0.9,... \n",
+ " ✔️ [0.8] \n",
" \n",
- " \n",
" 1 \n",
- " From ferrying people to and from their place of work to transporting nuclear waste and coal, railways are not only an integral part of 21st... \n",
- " context=[Entity(entity_name='RAILWAYS', entity_type='VEHICLE', description='Transportation system used for ferrying people and transporting nuclear waste and coal.', importance_score=0.9), Entity(entity_name='BELGIUM', entity_type='LOCATION', description='Country where a business is looking to innovate... \n",
- " context=[Relationship(src_id='RAILNOVA', tgt_id='BRUSSELS', description='Railnova is based in Brussels.', weight=0.9, order=1), Relationship(src_id='RAILNOVA', tgt_id='DEUTSCHE BAHN', description='Railnova serves Deutsche Bahn as a client.', weight=0.8, order=1), Relationship(src_id='RAILNOVA', tgt_id='SNCF', description='Railnova serves... \n",
- " context=[Entity(entity_name='RAILWAYS', entity_type='VEHICLE', description='A mode of transportation that involves trains running on tracks, used for various purposes including passenger and cargo transport.', importance_score=0.9), Entity(entity_name='BELGIUM', entity_type='LOCATION', description='A... \n",
- " context=[Relationship(src_id='RAILNOVA', tgt_id='DEUTSCHE BAHN', description='Railnova provides innovative technology solutions to Deutsche Bahn, a German railway company.', weight=0.8, order=1), Relationship(src_id='RAILNOVA', tgt_id='SNCF', description='Railnova offers its technology services to... \n",
- " ✔️ [0.9310485124588013] \n",
+ " 3 \n",
+ " LONDON (Reuters) - Britain’s economy was weaker than previously thought in 2017, official data showed on Thursday, leaving the country lagging further behind the global... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy was weaker than previously thought in 2017.', 'importance_score': 0.9}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.9, 'order': 1}, {'src_id': 'BANK OF ENGLAND', 'tgt_id': 'INTEREST RATES',... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy is discussed in the text.', 'importance_score': 1.0}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The political and... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.9, 'order': 1}, {'src_id': 'BRITAIN', 'tgt_id': 'BANK OF ENGLAND', 'description':... \n",
+ " ✔️ [0.2] \n",
" \n",
- " \n",
" \n",
"2 \n",
- " Jan 22 (Reuters) - Shanghai Stock Exchange Filing * SHOWS BLOCK TRADE OF YONGHUI SUPERSTORES Co LTd's 166.3 MILLION SHARES INVOLVING 1.63 BILLION YUAN ($254.68... \n",
- " context=[Entity(entity_name='YONGHUI SUPERSTORES', entity_type='ORGANIZATION', description='A company involved in a block trade of its shares.', importance_score=0.9), Entity(entity_name='SHANGHAI STOCK EXCHANGE', entity_type='ORGANIZATION', description='The stock exchange where the block trade... \n",
- " context=[Relationship(src_id='YONGHUI SUPERSTORES', tgt_id='SHANGHAI STOCK EXCHANGE', description=\"YONGHUI SUPERSTORES' shares were traded on the SHANGHAI STOCK EXCHANGE.\", weight=0.9, order=1), Relationship(src_id='YONGHUI SUPERSTORES', tgt_id='166.3 MILLION SHARES', description='YONGHUI SUPERSTORES was... \n",
- " context=[Entity(entity_name='YONGHUI SUPERSTORES', entity_type='ORGANIZATION', description='A company involved in a block trade of its shares.', importance_score=0.9), Entity(entity_name='SHANGHAI STOCK EXCHANGE', entity_type='ORGANIZATION', description='The stock exchange where the block trade... \n",
- " context=[Relationship(src_id='YONGHUI SUPERSTORES', tgt_id='166.3 MILLION SHARES', description='YONGHUI SUPERSTORES was involved in a block trade of 166.3 million shares.', weight=0.9, order=1), Relationship(src_id='166.3 MILLION SHARES', tgt_id='1.63 BILLION YUAN',... \n",
- " ✔️ [0.9334976673126221] \n",
+ " 4 \n",
+ " Trump taps White House doctor as new VA secretary 2 Hours Ago CNBC's Kayla Tausche reports President Trump has tapped White House physician Rear Admiral... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'President Trump who tapped Ronny Jackson as new VA secretary.', 'importance_score': 1.0}, {'entity_name': 'WHITE HOUSE', 'entity_type': 'ORGANIZATION', 'description': 'The White... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'RONNY JACKSON', 'description': 'President Trump taps Ronny Jackson as new VA secretary.', 'weight': 1.0, 'order': 1}, {'src_id': 'RONNY JACKSON', 'tgt_id': 'VA', 'description':... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'President Trump who tapped Ronny Jackson.', 'importance_score': 0.9}, {'entity_name': 'WHITE HOUSE', 'entity_type': 'ORGANIZATION', 'description': 'The White House where Ronny Jackson... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'RONNY JACKSON', 'description': 'Trump taps Ronny Jackson.', 'weight': 0.9, 'order': 1}, {'src_id': 'RONNY JACKSON', 'tgt_id': 'DEPARTMENT OF VETERANS AFFAIRS', 'description': 'Ronny Jackson... \n",
+ " ✔️ [0.65] \n",
" \n",
+ " \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " input_text \n",
+ " example_entities \n",
+ " example_relationships \n",
+ " pred_entities \n",
+ " pred_relationships \n",
+ " entity_recall_metric \n",
+ " \n",
+ " \n",
+ " 0 \n",
+ " As students from Marjory Stoneman Douglas High School confront lawmakers with demands to restrict sales of assault rifles, there were warnings by the president of... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where students confronted lawmakers about restricting sales of assault rifles.', 'importance_score':... \n",
+ " [{'src_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'tgt_id': 'FLORIDA', 'description': 'Students from Marjory Stoneman Douglas High School are located in the state of Florida.', 'weight': 0.9,... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where a mass shooting occurred, leading to demands for restricting assault... \n",
+ " [{'src_id': 'NIKOLAS CRUZ', 'tgt_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'description': 'Nikolas Cruz carried out a mass shooting at Marjory Stoneman Douglas High School.', 'weight': 0.9,... \n",
+ " ✔️ [1.0] \n",
+ " \n",
+ " \n",
+ " 1 \n",
+ " From ferrying people to and from their place of work to transporting nuclear waste and coal, railways are not only an integral part of 21st... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels whose clients include Deutsche Bahn and French rail operator SNCF.', 'importance_score': 0.9}, {'entity_name': 'DEUTSCHE... \n",
+ " [{'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description': 'Railnova provides technology solutions to Deutsche Bahn.', 'weight': 0.9, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'SNCF', 'description': 'Railnova provides technology... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels that offers solutions to improve train operations.', 'importance_score': 0.9}, {'entity_name': 'CHRISTIAN SPRAUER', 'entity_type': 'PERSON',... \n",
+ " [{'src_id': 'CHRISTIAN SPRAUER', 'tgt_id': 'RAILNOVA', 'description': 'Christian Sprauer is the CEO and founder of Railnova.', 'weight': 0.9, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description':... \n",
+ " ✔️ [0.8888888888888888] \n",
+ " \n",
+ " \n",
+ " 2 \n",
+ " Jan 22 (Reuters) - Shanghai Stock Exchange Filing * SHOWS BLOCK TRADE OF YONGHUI SUPERSTORES Co LTd's 166.3 MILLION SHARES INVOLVING 1.63 BILLION YUAN ($254.68... \n",
+ " [{'entity_name': 'YONGHUI SUPERSTORES CO LTD', 'entity_type': 'ORGANIZATION', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'importance_score': 1.0}, {'entity_name':... \n",
+ " [{'src_id': 'YONGHUI SUPERSTORES CO LTD', 'tgt_id': '166.3 MILLION SHARES', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'weight':... \n",
+ " [{'entity_name': 'SHANGHAI STOCK EXCHANGE', 'entity_type': 'ORGANIZATION', 'description': \"A stock exchange where the block trade of YONGHUI SUPERSTORES Co Ltd's shares took place.\", 'importance_score': 0.8}, {'entity_name':... \n",
+ " [{'src_id': 'SHANGHAI STOCK EXCHANGE', 'tgt_id': 'YONGHUI SUPERSTORES CO LTD', 'description': \"The block trade of YONGHUI SUPERSTORES Co Ltd's shares took place at the Shanghai Stock... \n",
+ " ✔️ [0.8] \n",
+ " \n",
+ " \n",
+ " 3 \n",
+ " LONDON (Reuters) - Britain’s economy was weaker than previously thought in 2017, official data showed on Thursday, leaving the country lagging further behind the global... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy was weaker than previously thought in 2017.', 'importance_score': 0.9}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.9, 'order': 1}, {'src_id': 'BANK OF ENGLAND', 'tgt_id': 'INTEREST RATES',... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy was weaker than previously thought in 2017.', 'importance_score': 0.9}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.8, 'order': 1}, {'src_id': 'BRITAIN', 'tgt_id': 'BANK OF ENGLAND', 'description':... \n",
+ " ✔️ [1.0] \n",
+ " \n",
+ " \n",
+ " \n",
+ "4 \n",
+ " Trump taps White House doctor as new VA secretary 2 Hours Ago CNBC's Kayla Tausche reports President Trump has tapped White House physician Rear Admiral... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'President Trump who tapped Ronny Jackson as new VA secretary.', 'importance_score': 1.0}, {'entity_name': 'WHITE HOUSE', 'entity_type': 'ORGANIZATION', 'description': 'The White... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'RONNY JACKSON', 'description': 'President Trump taps Ronny Jackson as new VA secretary.', 'weight': 1.0, 'order': 1}, {'src_id': 'RONNY JACKSON', 'tgt_id': 'VA', 'description':... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'The President who tapped Rear Admiral Ronny Jackson as the new VA secretary.', 'importance_score': 0.9}, {'entity_name': 'REAR ADMIRAL RONNY JACKSON',... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'REAR ADMIRAL RONNY JACKSON', 'description': 'President Trump tapped Rear Admiral Ronny Jackson to run the Department of Veterans Affairs.', 'weight': 0.9, 'order':... \n",
+ " ✔️ [0.5714285714285714] \n",
+ " \n",
+ " \n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ " input_text \n",
+ " example_entities \n",
+ " example_relationships \n",
+ " pred_entities \n",
+ " pred_relationships \n",
+ " relationships_similarity_metric \n",
+ " \n",
+ " \n",
+ " 0 \n",
+ " As students from Marjory Stoneman Douglas High School confront lawmakers with demands to restrict sales of assault rifles, there were warnings by the president of... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where students confronted lawmakers about restricting sales of assault rifles.', 'importance_score':... \n",
+ " [{'src_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'tgt_id': 'FLORIDA', 'description': 'Students from Marjory Stoneman Douglas High School are located in the state of Florida.', 'weight': 0.9,... \n",
+ " [{'entity_name': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'entity_type': 'ORGANIZATION', 'description': 'A high school in Florida where a mass shooting occurred, leading to demands for restricting assault... \n",
+ " [{'src_id': 'NIKOLAS CRUZ', 'tgt_id': 'MARJORY STONEMAN DOUGLAS HIGH SCHOOL', 'description': 'Nikolas Cruz carried out a mass shooting at Marjory Stoneman Douglas High School.', 'weight': 0.9,... \n",
+ " ✔️ [0.4] \n",
+ " \n",
+ " \n",
+ " 1 \n",
+ " From ferrying people to and from their place of work to transporting nuclear waste and coal, railways are not only an integral part of 21st... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels whose clients include Deutsche Bahn and French rail operator SNCF.', 'importance_score': 0.9}, {'entity_name': 'DEUTSCHE... \n",
+ " [{'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description': 'Railnova provides technology solutions to Deutsche Bahn.', 'weight': 0.9, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'SNCF', 'description': 'Railnova provides technology... \n",
+ " [{'entity_name': 'RAILNOVA', 'entity_type': 'ORGANIZATION', 'description': 'A technology company based in Brussels that offers solutions to improve train operations.', 'importance_score': 0.9}, {'entity_name': 'CHRISTIAN SPRAUER', 'entity_type': 'PERSON',... \n",
+ " [{'src_id': 'CHRISTIAN SPRAUER', 'tgt_id': 'RAILNOVA', 'description': 'Christian Sprauer is the CEO and founder of Railnova.', 'weight': 0.9, 'order': 1}, {'src_id': 'RAILNOVA', 'tgt_id': 'DEUTSCHE BAHN', 'description':... \n",
+ " ✔️ [0.85] \n",
+ " \n",
+ " \n",
+ " 2 \n",
+ " Jan 22 (Reuters) - Shanghai Stock Exchange Filing * SHOWS BLOCK TRADE OF YONGHUI SUPERSTORES Co LTd's 166.3 MILLION SHARES INVOLVING 1.63 BILLION YUAN ($254.68... \n",
+ " [{'entity_name': 'YONGHUI SUPERSTORES CO LTD', 'entity_type': 'ORGANIZATION', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'importance_score': 1.0}, {'entity_name':... \n",
+ " [{'src_id': 'YONGHUI SUPERSTORES CO LTD', 'tgt_id': '166.3 MILLION SHARES', 'description': 'YONGHUI SUPERSTORES Co LTd is involved in a block trade of 166.3 million shares.', 'weight':... \n",
+ " [{'entity_name': 'SHANGHAI STOCK EXCHANGE', 'entity_type': 'ORGANIZATION', 'description': \"A stock exchange where the block trade of YONGHUI SUPERSTORES Co Ltd's shares took place.\", 'importance_score': 0.8}, {'entity_name':... \n",
+ " [{'src_id': 'SHANGHAI STOCK EXCHANGE', 'tgt_id': 'YONGHUI SUPERSTORES CO LTD', 'description': \"The block trade of YONGHUI SUPERSTORES Co Ltd's shares took place at the Shanghai Stock... \n",
+ " ✔️ [0.3] \n",
+ " \n",
+ " \n",
+ " 3 \n",
+ " LONDON (Reuters) - Britain’s economy was weaker than previously thought in 2017, official data showed on Thursday, leaving the country lagging further behind the global... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy was weaker than previously thought in 2017.', 'importance_score': 0.9}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.9, 'order': 1}, {'src_id': 'BANK OF ENGLAND', 'tgt_id': 'INTEREST RATES',... \n",
+ " [{'entity_name': 'BRITAIN', 'entity_type': 'LOCATION', 'description': 'The country whose economy was weaker than previously thought in 2017.', 'importance_score': 0.9}, {'entity_name': 'EUROPEAN UNION', 'entity_type': 'ORGANIZATION', 'description': 'The... \n",
+ " [{'src_id': 'BRITAIN', 'tgt_id': 'EUROPEAN UNION', 'description': 'Britain is preparing to leave the European Union.', 'weight': 0.8, 'order': 1}, {'src_id': 'BRITAIN', 'tgt_id': 'BANK OF ENGLAND', 'description':... \n",
+ " ✔️ [0.4] \n",
+ " \n",
+ " \n",
+ " \n",
+ "4 \n",
+ " Trump taps White House doctor as new VA secretary 2 Hours Ago CNBC's Kayla Tausche reports President Trump has tapped White House physician Rear Admiral... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'President Trump who tapped Ronny Jackson as new VA secretary.', 'importance_score': 1.0}, {'entity_name': 'WHITE HOUSE', 'entity_type': 'ORGANIZATION', 'description': 'The White... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'RONNY JACKSON', 'description': 'President Trump taps Ronny Jackson as new VA secretary.', 'weight': 1.0, 'order': 1}, {'src_id': 'RONNY JACKSON', 'tgt_id': 'VA', 'description':... \n",
+ " [{'entity_name': 'TRUMP', 'entity_type': 'PERSON', 'description': 'The President who tapped Rear Admiral Ronny Jackson as the new VA secretary.', 'importance_score': 0.9}, {'entity_name': 'REAR ADMIRAL RONNY JACKSON',... \n",
+ " [{'src_id': 'TRUMP', 'tgt_id': 'REAR ADMIRAL RONNY JACKSON', 'description': 'President Trump tapped Rear Admiral Ronny Jackson to run the Department of Veterans Affairs.', 'weight': 0.9, 'order':... \n",
+ " ✔️ [0.65] \n",
+ "