Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
asahi417 commited on
Commit
989839e
1 Parent(s): b82e694

fix readme

Browse files
Files changed (2) hide show
  1. check_stats.py +9 -0
  2. data/predicates.json +0 -0
check_stats.py CHANGED
@@ -8,6 +8,8 @@ parameters_min_e_freq = [1, 2, 3, 4]
8
  parameters_max_p_freq = [100, 50, 25, 10]
9
 
10
  stats = []
 
 
11
  for min_e_freq, max_p_freq in product(parameters_min_e_freq, parameters_max_p_freq):
12
 
13
  with open(f"data/t_rex.filter_unified.min_entity_{min_e_freq}_max_predicate_{max_p_freq}.train.jsonl") as f:
@@ -21,6 +23,7 @@ for min_e_freq, max_p_freq in product(parameters_min_e_freq, parameters_max_p_fr
21
  with open(f"data/t_rex.filter_unified.min_entity_{min_e_freq}_max_predicate_{max_p_freq}.jsonl") as f:
22
  full = [json.loads(i) for i in f.read().split('\n') if len(i) > 0]
23
  df_full = pd.DataFrame(full)
 
24
 
25
  stats.append({
26
  "data": f"filter_unified.min_entity_{min_e_freq}_max_predicate_{max_p_freq}",
@@ -48,6 +51,7 @@ print(df.to_markdown())
48
  with open(f"data/t_rex.filter_unified.test.jsonl") as f:
49
  test = [json.loads(i) for i in f.read().split('\n') if len(i) > 0]
50
  df_test = pd.DataFrame(test)
 
51
  df_test = pd.DataFrame([{
52
  "number of triples (test)": len(df_test),
53
  "number of unique predicates (test)": len(df_test['predicate'].unique()),
@@ -55,6 +59,7 @@ df_test = pd.DataFrame([{
55
  list(set(df_test['object'].unique().tolist() + df_test['subject'].unique().tolist()))
56
  )
57
  }])
 
58
  for c in df_test.columns:
59
  df_test.loc[:, c] = df_test[c].map('{:,d}'.format)
60
  print(df_test.to_markdown(index=False))
@@ -66,3 +71,7 @@ df.pop("number of unique predicates (all)")
66
  df.pop("number of unique entities (all)")
67
  df = df[sorted(df.columns)]
68
  df.to_csv("data/stats.csv")
 
 
 
 
 
8
  parameters_max_p_freq = [100, 50, 25, 10]
9
 
10
  stats = []
11
+ predicate = {}
12
+
13
  for min_e_freq, max_p_freq in product(parameters_min_e_freq, parameters_max_p_freq):
14
 
15
  with open(f"data/t_rex.filter_unified.min_entity_{min_e_freq}_max_predicate_{max_p_freq}.train.jsonl") as f:
 
23
  with open(f"data/t_rex.filter_unified.min_entity_{min_e_freq}_max_predicate_{max_p_freq}.jsonl") as f:
24
  full = [json.loads(i) for i in f.read().split('\n') if len(i) > 0]
25
  df_full = pd.DataFrame(full)
26
+ predicate[f"min_entity_{min_e_freq}_max_predicate_{max_p_freq}"] = df_full['predicate'].unique().tolist()
27
 
28
  stats.append({
29
  "data": f"filter_unified.min_entity_{min_e_freq}_max_predicate_{max_p_freq}",
 
51
  with open(f"data/t_rex.filter_unified.test.jsonl") as f:
52
  test = [json.loads(i) for i in f.read().split('\n') if len(i) > 0]
53
  df_test = pd.DataFrame(test)
54
+ predicate["test"] = df_test['predicate'].unique().tolist()
55
  df_test = pd.DataFrame([{
56
  "number of triples (test)": len(df_test),
57
  "number of unique predicates (test)": len(df_test['predicate'].unique()),
 
59
  list(set(df_test['object'].unique().tolist() + df_test['subject'].unique().tolist()))
60
  )
61
  }])
62
+
63
  for c in df_test.columns:
64
  df_test.loc[:, c] = df_test[c].map('{:,d}'.format)
65
  print(df_test.to_markdown(index=False))
 
71
  df.pop("number of unique entities (all)")
72
  df = df[sorted(df.columns)]
73
  df.to_csv("data/stats.csv")
74
+
75
+ # predicates in training vs test
76
+ with open("data/predicates.json", "w") as f:
77
+ json.dump(predicate, f)
data/predicates.json ADDED
The diff for this file is too large to render. See raw diff