Datasets:

Languages:
English
Tags:
Not-For-All-Audiences
License:
Gaeros commited on
Commit
1081ee7
1 Parent(s): 61960a7

query_tags: errors when no matching tag is found

Browse files
Files changed (1) hide show
  1. query_tags.py +2 -9
query_tags.py CHANGED
@@ -26,17 +26,10 @@ def dothething(args):
26
  idx2tag = idx2tag[:N_vocab]
27
  tag_categories = tag_categories[:N_vocab]
28
 
29
- X /= np.linalg.norm(X, axis=1)[:, None]
30
- if args.first_pca and args.first_pca < X.shape[1]:
31
- pca = PCA(args.first_pca)
32
- Xt = pca.fit_transform(X)
33
- Xt /= np.linalg.norm(Xt, axis=1)[:, None]
34
- del X
35
- else:
36
- Xt = X
37
-
38
  sel_idxs = (tags2id.get(t, N_vocab) for t in args.tags)
39
  sel_idxs = np.array(sorted(i for i in sel_idxs if i < N_vocab))
 
 
40
  sel_tags = idx2tag[sel_idxs]
41
  print("Query tags:", " ".join(sel_tags))
42
 
 
26
  idx2tag = idx2tag[:N_vocab]
27
  tag_categories = tag_categories[:N_vocab]
28
 
 
 
 
 
 
 
 
 
 
29
  sel_idxs = (tags2id.get(t, N_vocab) for t in args.tags)
30
  sel_idxs = np.array(sorted(i for i in sel_idxs if i < N_vocab))
31
+ if len(sel_idxs) == 0:
32
+ raise SystemExit("None of the tags can be found. Please check spelling.")
33
  sel_tags = idx2tag[sel_idxs]
34
  print("Query tags:", " ".join(sel_tags))
35