asahi417 commited on
Commit
f52f829
1 Parent(s): 20f3e4a

fix readme

Browse files
Files changed (2) hide show
  1. README.md +4 -3
  2. stats.py +6 -3
README.md CHANGED
@@ -22,9 +22,10 @@ Please see [NELL paper](https://www.cs.cmu.edu/~tom/pubs/NELL_aaai15.pdf) to kno
22
 
23
  - Number of instances
24
 
25
- | | train | validation | test |
26
- |:----------------|--------:|-------------:|-------:|
27
- | number of pairs | 5498 | 878 | 1352 |
 
28
 
29
  - Number of pairs in each relation type
30
 
 
22
 
23
  - Number of instances
24
 
25
+ | | train | validation | test |
26
+ |:--------------------------------|--------:|-------------:|-------:|
27
+ | number of pairs | 5498 | 878 | 1352 |
28
+ | number of unique relation types | 32 | 4 | 6 |
29
 
30
  - Number of pairs in each relation type
31
 
stats.py CHANGED
@@ -7,19 +7,22 @@ from datasets import load_dataset
7
  def get_stats():
8
  relation = []
9
  entity = []
10
- size = {}
11
  data = load_dataset("relbert/nell")
12
  splits = data.keys()
13
  for split in splits:
14
  df = data[split].to_pandas()
15
- size[split] = len(df)
 
 
 
16
  relation.append(df.groupby('relation')['head'].count().to_dict())
17
  entity += [df.groupby('head_type')['head'].count().to_dict(), df.groupby('tail_type')['tail'].count().to_dict()]
18
  relation = pd.DataFrame(relation, index=[f"number of pairs ({s})" for s in splits]).T
19
  relation = relation.fillna(0).astype(int)
20
  entity = pd.DataFrame(entity, index=list(chain(*[[f"head ({s})", f"tail ({s})"] for s in splits]))).T
21
  entity = entity.fillna(0).astype(int)
22
- size = pd.DataFrame([size], index=["number of pairs"])
23
  return relation, entity, size
24
 
25
  df_relation, df_entity, df_size = get_stats()
 
7
  def get_stats():
8
  relation = []
9
  entity = []
10
+ size = []
11
  data = load_dataset("relbert/nell")
12
  splits = data.keys()
13
  for split in splits:
14
  df = data[split].to_pandas()
15
+ size.append({
16
+ "number of pairs": len(df),
17
+ "number of unique relation types": len(df["relation"].unique())
18
+ })
19
  relation.append(df.groupby('relation')['head'].count().to_dict())
20
  entity += [df.groupby('head_type')['head'].count().to_dict(), df.groupby('tail_type')['tail'].count().to_dict()]
21
  relation = pd.DataFrame(relation, index=[f"number of pairs ({s})" for s in splits]).T
22
  relation = relation.fillna(0).astype(int)
23
  entity = pd.DataFrame(entity, index=list(chain(*[[f"head ({s})", f"tail ({s})"] for s in splits]))).T
24
  entity = entity.fillna(0).astype(int)
25
+ size = pd.DataFrame(size, index=splits).T
26
  return relation, entity, size
27
 
28
  df_relation, df_entity, df_size = get_stats()