jaimenms commited on
Commit
a3ed002
·
verified ·
1 Parent(s): 347b44c

text2ipc IPC 20260101 PT (a1f5879)

Browse files
README.md CHANGED
@@ -16,7 +16,7 @@ base_model:
16
  base_model_relation: merge
17
  ---
18
 
19
- # text2ipc 0.2.3: IPC 20260101 (PT) via intfloat/multilingual-e5-base
20
 
21
  Both models above are listed as base models so that they show in the model tree
22
  (the Hub only has "merge" as a relation for two models): the index in this
@@ -68,7 +68,7 @@ model when you enable it.
68
 
69
  ```bash
70
  pip install "text2ipc[st] @ git+https://github.com/Jaimenms/text2ipc"
71
- t2ipc download jaimenms/text2ipc-pt # or --revision v0.2.3 to pin this edition
72
  t2ipc classify "Aparelho para combate a incêndios com mangueira flexível" --lang PT --level group
73
  t2ipc classify "..." --lang PT --level group --rerank
74
  ```
 
16
  base_model_relation: merge
17
  ---
18
 
19
+ # text2ipc 0.2.4: IPC 20260101 (PT) via intfloat/multilingual-e5-base
20
 
21
  Both models above are listed as base models so that they show in the model tree
22
  (the Hub only has "merge" as a relation for two models): the index in this
 
68
 
69
  ```bash
70
  pip install "text2ipc[st] @ git+https://github.com/Jaimenms/text2ipc"
71
+ t2ipc download jaimenms/text2ipc-pt # or --revision v0.2.4 to pin this edition
72
  t2ipc classify "Aparelho para combate a incêndios com mangueira flexível" --lang PT --level group
73
  t2ipc classify "..." --lang PT --level group --rerank
74
  ```
text2ipc/__init__.py CHANGED
@@ -10,4 +10,4 @@ from .config import LEVELS
10
  from .search import Beam, Match, SearchParams, Weights
11
 
12
  __all__ = ["LEVELS", "Beam", "IpcClassifier", "Match", "SearchParams", "Weights", "classify"]
13
- __version__ = "0.2.3"
 
10
  from .search import Beam, Match, SearchParams, Weights
11
 
12
  __all__ = ["LEVELS", "Beam", "IpcClassifier", "Match", "SearchParams", "Weights", "classify"]
13
+ __version__ = "0.2.4"
text2ipc/web/export.py CHANGED
@@ -249,7 +249,8 @@ def export_web_demo(
249
 
250
 
251
  def load_examples(path: Path) -> list[dict]:
252
- """Title and abstract of each case; nothing else reaches the page."""
 
253
  out = []
254
  for line in Path(path).read_text(encoding="utf-8").splitlines():
255
  if not line.strip():
@@ -257,7 +258,13 @@ def load_examples(path: Path) -> list[dict]:
257
  c = json.loads(line)
258
  if not (c.get("title") and c.get("abstract")):
259
  raise ValueError(f"example {c.get('id')} needs both a title and an abstract")
260
- out.append({"title": c["title"], "abstract": c["abstract"]})
 
 
 
 
 
 
261
  return out
262
 
263
 
 
249
 
250
 
251
  def load_examples(path: Path) -> list[dict]:
252
+ """Language, title and abstract of each case; nothing else reaches the page. The page
253
+ shows the examples whose language matches the selected scheme."""
254
  out = []
255
  for line in Path(path).read_text(encoding="utf-8").splitlines():
256
  if not line.strip():
 
258
  c = json.loads(line)
259
  if not (c.get("title") and c.get("abstract")):
260
  raise ValueError(f"example {c.get('id')} needs both a title and an abstract")
261
+ out.append(
262
+ {
263
+ "lang": (c.get("lang") or "pt").upper(),
264
+ "title": c["title"],
265
+ "abstract": c["abstract"],
266
+ }
267
+ )
268
  return out
269
 
270
 
text2ipc/web/static/app.js CHANGED
@@ -637,9 +637,12 @@ async function loadExamples() {
637
  }
638
  }
639
 
 
640
  function renderExamples() {
641
  ui.examples.innerHTML = "";
642
- for (const ex of state.examples) {
 
 
643
  const b = document.createElement("button");
644
  b.type = "button";
645
  b.className = "chip";
@@ -674,7 +677,6 @@ async function main() {
674
  if (!m.reranker) ui.rerankLabel.hidden = true;
675
  else ui.rerankLabel.title = `${m.reranker.web_model} (${m.reranker.dtype}) re-judges the top ${m.reranker.candidates} when you click Classify; 280 MB once, then about a second per candidate`;
676
  await loadExamples();
677
- renderExamples();
678
 
679
  const params = new URLSearchParams(location.search);
680
  if (params.get("lang") && m.indexes.some((e) => e.lang === params.get("lang"))) {
@@ -684,9 +686,13 @@ async function main() {
684
  ui.level.value = params.get("level");
685
  }
686
  if (params.get("q")) ui.text.value = params.get("q");
 
687
 
688
  ui.run.addEventListener("click", classify);
689
- ui.lang.addEventListener("change", () => loadIndex(entryFor(ui.lang.value)).catch(fail));
 
 
 
690
  window.addEventListener("scroll", hideTip, { passive: true });
691
 
692
  try {
 
637
  }
638
  }
639
 
640
+ /** Example buttons in the language of the selected scheme (all of them as a fallback). */
641
  function renderExamples() {
642
  ui.examples.innerHTML = "";
643
+ const lang = (ui.lang.value || "").toUpperCase();
644
+ const matching = state.examples.filter((ex) => (ex.lang || "").toUpperCase() === lang);
645
+ for (const ex of matching.length ? matching : state.examples) {
646
  const b = document.createElement("button");
647
  b.type = "button";
648
  b.className = "chip";
 
677
  if (!m.reranker) ui.rerankLabel.hidden = true;
678
  else ui.rerankLabel.title = `${m.reranker.web_model} (${m.reranker.dtype}) re-judges the top ${m.reranker.candidates} when you click Classify; 280 MB once, then about a second per candidate`;
679
  await loadExamples();
 
680
 
681
  const params = new URLSearchParams(location.search);
682
  if (params.get("lang") && m.indexes.some((e) => e.lang === params.get("lang"))) {
 
686
  ui.level.value = params.get("level");
687
  }
688
  if (params.get("q")) ui.text.value = params.get("q");
689
+ renderExamples();
690
 
691
  ui.run.addEventListener("click", classify);
692
+ ui.lang.addEventListener("change", () => {
693
+ renderExamples();
694
+ loadIndex(entryFor(ui.lang.value)).catch(fail);
695
+ });
696
  window.addEventListener("scroll", hideTip, { passive: true });
697
 
698
  try {