Deploy 67f193d from GitHub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .dockerignoreAdded+16
- DockerfileAdded+36
- LICENSEAdded+21
- README.md+35-5
- app/__init__.pyAdded
- app/data.pyAdded+185
- app/main.pyAdded+167
- app/models.pyAdded+82
- app/retrieval.pyAdded+131
- app/static/app.jsAdded+121
- app/static/index.htmlAdded+45
- app/static/style.cssAdded+135
- artifacts/classifier.joblibAdded+3
- artifacts/selection.jsonAdded+19
- data/ToS/Labels/9gag.txtAdded+139
- data/ToS/Labels/Academia.txtAdded+193
- data/ToS/Labels/Airbnb.txtAdded+391
- data/ToS/Labels/Amazon.txtAdded+132
- data/ToS/Labels/Atlas.txtAdded+60
- data/ToS/Labels/Betterpoints_UK.txtAdded+113
- data/ToS/Labels/Booking.txtAdded+128
- data/ToS/Labels/Crowdtangle.txtAdded+78
- data/ToS/Labels/Deliveroo.txtAdded+143
- data/ToS/Labels/Dropbox.txtAdded+121
- data/ToS/Labels/Duolingo.txtAdded+140
- data/ToS/Labels/Endomondo.txtAdded+498
- data/ToS/Labels/Evernote.txtAdded+236
- data/ToS/Labels/Facebook.txtAdded+146
- data/ToS/Labels/Fitbit.txtAdded+158
- data/ToS/Labels/Google.txtAdded+93
- data/ToS/Labels/Headspace.txtAdded+372
- data/ToS/Labels/Instagram.txtAdded+158
- data/ToS/Labels/LindenLab.txtAdded+344
- data/ToS/Labels/LinkedIn.txtAdded+194
- data/ToS/Labels/Masquerade.txtAdded+130
- data/ToS/Labels/Microsoft.txtAdded+548
- data/ToS/Labels/Moves-app.txtAdded+75
- data/ToS/Labels/Netflix.txtAdded+86
- data/ToS/Labels/Nintendo.txtAdded+188
- data/ToS/Labels/Oculus.txtAdded+240
- data/ToS/Labels/Onavo.txtAdded+147
- data/ToS/Labels/PokemonGo.txtAdded+212
- data/ToS/Labels/Rovio.txtAdded+99
- data/ToS/Labels/Skype.txtAdded+455
- data/ToS/Labels/Skyscanner.txtAdded+83
- data/ToS/Labels/Snap.txtAdded+168
- data/ToS/Labels/Spotify.txtAdded+293
- data/ToS/Labels/Supercell.txtAdded+141
- data/ToS/Labels/Syncme.txtAdded+115
- data/ToS/Labels/Tinder.txtAdded+195
12345678910111213141516.venv**/__pycache__.pytest_tmp.pytest_cacheartifacts/*!artifacts/selection.json!artifacts/classifier.joblibresultsnotebooksreporttests*.log*.docxdata/ToS/OriginalTaggedDocumentsdata/ToS/Postagsdata/ToS/Trees123456789101112131415161718192021222324252627282930313233343536# CLAIR (Clause Intelligence and Retrieval) single-service image: FastAPI + the retrieval backend frozen by the dev evaluation.# The corpus index (and, for dense backends, the pinned model) is built at image# build time, so the container never downloads anything at runtime.FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /srv
# Install dependencies first (cached layer). Dense extras only if a dense backend was selected.COPY requirements.txt requirements-dense.txt ./COPY artifacts/selection.json artifacts/selection.jsonRUN pip install -r requirements.txt \ && if ! grep -q '"selected": "bm25"' artifacts/selection.json; then pip install -r requirements-dense.txt; fi
COPY data/ data/COPY app/ app/COPY scripts/build_index.py scripts/build_index.py# Deterministic index build for the selected backend only (downloads the pinned model revision if dense).RUN python scripts/build_index.py --methods selected
# Validated classifier artifact (optional; the API serves search without it).COPY artifacts/classifier.joblib artifacts/classifier.joblib
ENV HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1# Hugging Face Spaces runs containers as UID 1000; the explicit UID keeps that consistent.RUN useradd --create-home --uid 1000 appuser && chown -R appuser /srvUSER appuser
EXPOSE 8000HEALTHCHECK --interval=30s --timeout=5s --start-period=60s \ CMD python -c "import urllib.request,sys; sys.exit(urllib.request.urlopen('http://127.0.0.1:8000/ready').status != 200)"CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]123456789101112131415161718192021MIT License
Copyright (c) 2026 Miguel Meneses
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.12345234567891011121013141516171819202122232425262728293031323334353637383940---title: Clairemoji: 💻colorFrom: yellowcolorTo: purpletitle: CLAIRemoji: ⚖️colorFrom: indigocolorTo: bluesdk: dockerapp_port: 8000pinned: falselicense: mitshort_description: Search Terms-of-Service clauses and flag unfair ones---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference# CLAIR: Clause Intelligence and Retrieval
Describe a Terms-of-Service clause in your own words, and CLAIR finds similar sentences in**50 real Terms of Service** (9,414 sentences from the CLAUDETTE corpus). Every result showsthe contract it came from. An optional classifier (TF-IDF + logistic regression) flags clausesas *potentially unfair*.
- **UI:** this page- **API docs:** `/docs` (OpenAPI), with the endpoints `POST /search`, `POST /classify`, `GET /ready` and `GET /health`- **Source code, evaluation and technical report:** <https://github.com/mvprm/clair>
The served backend is BM25. It was chosen over MiniLM and CONTRACTS-BERT by a pre-registeredselection rule plus a production gate, evaluated on contract-disjoint splits. See the GitHubrepository for the full method and results.
> The classifier predicts the CLAUDETTE dataset's annotations. **It is not legal advice or a> legal determination.** Search scores rank results and are not probabilities.
This Space is deployed automatically from the GitHub repository's `main` branch.The free hardware sleeps when the Space is idle, so the first request may take up to a minute.
## Data
CLAUDETTE corpus: M. Lippi, P. Pałka, G. Contissa, F. Lagioia, H.-W. Micklitz, G. Sartor, P. Torroni.*CLAUDETTE: an Automated Detector of Potentially Unfair Clauses in Online Terms of Service.*Artificial Intelligence and Law, 2019. [arXiv:1805.01217](https://arxiv.org/abs/1805.01217)
The code is released under the MIT License. The data remains under its original terms.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185"""Corpus loading, validation, conservative normalization and duplicate grouping.
The CLAUDETTE ToS corpus stores one sentence per line (PTB-tokenized, lowercased)in ``Sentences/<contract>.txt`` with line-aligned label files:``Labels/`` holds the binary potentially-unfair flag (1 / -1) and``Labels_<CAT>/`` one binary file per unfair-clause category."""
from __future__ import annotations
import hashlibimport loggingimport refrom dataclasses import dataclass, fieldfrom pathlib import Path
log = logging.getLogger(__name__)
PREPROCESSING_VERSION = "1.0"CATEGORIES = ["A", "CH", "CR", "J", "LAW", "LTD", "TER", "USE"]CATEGORY_NAMES = { "A": "Arbitration", "CH": "Unilateral change", "CR": "Content removal", "J": "Jurisdiction", "LAW": "Choice of law", "LTD": "Limitation of liability", "TER": "Unilateral termination", "USE": "Contract by using",}
# PTB bracket / quote tokens -> plain characters._PTB_TOKENS = { "-lrb-": "(", "-rrb-": ")", "-lsb-": "[", "-rsb-": "]", "-lcb-": "{", "-rcb-": "}", "``": '"', "''": '"',}_PTB_RE = re.compile("|".join(re.escape(t) for t in _PTB_TOKENS), flags=re.IGNORECASE)# Re-attach PTB-split contractions; "n't" is kept so negation is preserved._CONTRACTION_RE = re.compile(r"(\w) (n't|'s|'re|'ve|'ll|'d|'m)\b")_SPACE_BEFORE_PUNCT_RE = re.compile(r" ([,.;:!?%)\]}])")_SPACE_AFTER_OPEN_RE = re.compile(r"([(\[{]) ")_WS_RE = re.compile(r"\s+")
def normalize(text: str) -> str: """Conservative normalization shared by the corpus and incoming queries.
Undoes PTB artifacts, lowercases and collapses whitespace. No stemming, stop-word removal or token deletion: negations and qualifiers survive. """ t = _PTB_RE.sub(lambda m: _PTB_TOKENS[m.group(0).lower()], text) t = t.replace("“", '"').replace("”", '"').replace("’", "'").replace("‘", "'") t = _WS_RE.sub(" ", t).strip().lower() t = _CONTRACTION_RE.sub(r"\1\2", t) t = _SPACE_BEFORE_PUNCT_RE.sub(r"\1", t) t = _SPACE_AFTER_OPEN_RE.sub(r"\1", t) return t
@dataclassclass Occurrence: contract: str position: int # 0-based line index in the source contract original: str # sentence exactly as stored in the corpus file unfair: bool categories: list[str]
@dataclassclass SentenceGroup: """All occurrences of one exact normalized sentence."""
group_id: str text: str occurrences: list[Occurrence] = field(default_factory=list)
@property def categories(self) -> list[str]: return sorted({c for o in self.occurrences for c in o.categories})
@property def unfair(self) -> bool: return any(o.unfair for o in self.occurrences)
@property def contracts(self) -> set[str]: return {o.contract for o in self.occurrences}
def to_dict(self) -> dict: return { "group_id": self.group_id, "text": self.text, "categories": self.categories, "unfair": self.unfair, "occurrences": [o.__dict__ for o in self.occurrences], }
@classmethod def from_dict(cls, d: dict) -> "SentenceGroup": return cls(d["group_id"], d["text"], [Occurrence(**o) for o in d["occurrences"]])
def _read_lines(path: Path) -> list[str]: # Files are UTF-8; fail loudly on encoding problems instead of guessing. return path.read_text(encoding="utf-8").splitlines()
def load_occurrences(data_dir: Path) -> list[Occurrence]: """Read every contract, validating sentence/label alignment and label values.""" data_dir = Path(data_dir) sentence_dir = data_dir / "Sentences" contracts = sorted(p.stem for p in sentence_dir.glob("*.txt")) if not contracts: raise FileNotFoundError(f"No sentence files in {sentence_dir}")
occurrences: list[Occurrence] = [] for contract in contracts: sentences = _read_lines(sentence_dir / f"{contract}.txt") unfair = _read_lines(data_dir / "Labels" / f"{contract}.txt") cat_labels = {c: _read_lines(data_dir / f"Labels_{c}" / f"{contract}.txt") for c in CATEGORIES}
for name, labels in [("Labels", unfair), *((f"Labels_{c}", v) for c, v in cat_labels.items())]: if len(labels) != len(sentences): raise ValueError(f"{contract}: {name} has {len(labels)} rows, Sentences has {len(sentences)}") bad = {v.strip() for v in labels} - {"1", "-1"} if bad: raise ValueError(f"{contract}: unexpected values {bad} in {name}")
for i, sentence in enumerate(sentences): cats = [c for c in CATEGORIES if cat_labels[c][i].strip() == "1"] is_unfair = unfair[i].strip() == "1" if is_unfair != bool(cats): log.warning("%s:%d unfair flag disagrees with category labels", contract, i) occurrences.append(Occurrence(contract, i, sentence.strip(), is_unfair, cats)) return occurrences
def group_id_for(text: str) -> str: return "s_" + hashlib.sha1(text.encode("utf-8")).hexdigest()[:12]
def group_duplicates(occurrences: list[Occurrence]) -> tuple[list[SentenceGroup], list[dict]]: """Group exact normalized duplicates; return groups plus annotation conflicts.
Blank sentences are dropped. Groups are ordered by first occurrence, which makes indices deterministic for a fixed input. """ groups: dict[str, SentenceGroup] = {} for occ in occurrences: text = normalize(occ.original) if not text: continue g = groups.get(text) if g is None: g = groups[text] = SentenceGroup(group_id_for(text), text) g.occurrences.append(occ)
conflicts = [] for g in groups.values(): labelings = {(o.unfair, tuple(o.categories)) for o in g.occurrences} if len(labelings) > 1: conflicts.append({ "group_id": g.group_id, "text": g.text, "labelings": [ {"contract": o.contract, "position": o.position, "unfair": o.unfair, "categories": o.categories} for o in g.occurrences ], }) if conflicts: log.warning("%d duplicate groups carry conflicting annotations (kept, labels unioned)", len(conflicts)) return list(groups.values()), conflicts
def fingerprint(data_dir: Path) -> str: """SHA-256 over all sentence and label files (path + content).""" data_dir = Path(data_dir) h = hashlib.sha256() for sub in ["Sentences", "Labels", *(f"Labels_{c}" for c in CATEGORIES)]: for p in sorted((data_dir / sub).glob("*.txt")): h.update(f"{sub}/{p.name}".encode()) h.update(p.read_bytes()) return h.hexdigest()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167"""CLAIR (Clause Intelligence and Retrieval): FastAPI service for semantic sentencesearch over the CLAUDETTE Terms-of-Service corpus.
The backend frozen by the development evaluation (artifacts/selection.json) isloaded once at startup. The optional unfair-clause classifier is loaded if itsartifact exists; its absence never blocks search."""
from __future__ import annotations
import loggingimport osfrom contextlib import asynccontextmanagerfrom pathlib import Path
from fastapi import FastAPI, HTTPExceptionfrom fastapi.responses import FileResponse, JSONResponsefrom fastapi.staticfiles import StaticFilesfrom pydantic import BaseModel, Field, field_validator
from app.data import normalizefrom app.models import ARTIFACTS_DIR, load_backend, load_corpus, selected_methodfrom app.retrieval import format_results, rank
log = logging.getLogger("uvicorn.error")STATIC_DIR = Path(__file__).resolve().parent / "static"MAX_QUERY_CHARS = 2000MAX_K = 50
state: dict = {"ready": False}
@asynccontextmanagerasync def lifespan(_: FastAPI): artifacts = Path(os.environ.get("ARTIFACTS_DIR", ARTIFACTS_DIR)) method = os.environ.get("SEARCH_METHOD", selected_method(artifacts)) state["groups"] = load_corpus(artifacts) state["backend"] = load_backend(method, state["groups"], artifacts) state["method"] = method state["classifier"] = None clf_path = artifacts / "classifier.joblib" if clf_path.exists(): try: import joblib state["classifier"] = joblib.load(clf_path) except Exception: # classifier is optional: log and keep serving search log.exception("Could not load classifier from %s", clf_path) state["ready"] = True log.info("Ready: %s backend over %d sentence groups; classifier=%s", method, len(state["groups"]), state["classifier"] is not None) yield state.clear() state["ready"] = False
app = FastAPI( title="CLAIR — Clause Intelligence and Retrieval", description="Retrieve functionally or topically similar Terms-of-Service clauses and flag " "potentially unfair ones. " "Scores are ranking scores (BM25 or cosine similarity), not probabilities.", version="1.0.0", lifespan=lifespan,)
class _TextIn(BaseModel): @staticmethod def _non_blank(v: str) -> str: v = v.strip() if not v: raise ValueError("must not be blank") return v
class SearchRequest(_TextIn): query: str = Field(..., max_length=MAX_QUERY_CHARS, examples=["We may terminate your account at any time."]) k: int = Field(10, ge=1, le=MAX_K, strict=True)
_check = field_validator("query")(_TextIn._non_blank)
class ClassifyRequest(_TextIn): text: str = Field(..., max_length=MAX_QUERY_CHARS, examples=["We may terminate your account at any time."])
_check = field_validator("text")(_TextIn._non_blank)
class Occurrence(BaseModel): contract: str position: int original: str
class SearchHit(BaseModel): rank: int group_id: str text: str score: float method: str occurrences: list[Occurrence]
class SearchResponse(BaseModel): query: str method: str k: int score_note: str = "Scores rank results within one method; they are not probabilities." results: list[SearchHit]
class ClassifyResponse(BaseModel): text: str potentially_unfair: bool probability: float threshold: float note: str = ("Predicts the dataset's 'potentially unfair' annotation (CLAUDETTE); " "it is not a legal determination.")
@app.get("/health")def health() -> dict: return {"status": "ok"}
@app.get("/ready")def ready(): if not state.get("ready"): return JSONResponse(status_code=503, content={"ready": False}) return { "ready": True, "method": state["method"], "corpus_groups": len(state["groups"]), "classifier": state["classifier"] is not None, }
def _require_ready() -> None: if not state.get("ready"): raise HTTPException(status_code=503, detail="Service is not ready")
@app.post("/search", response_model=SearchResponse)def search(req: SearchRequest) -> SearchResponse: _require_ready() backend = state["backend"] scores = backend.scores(req.query) hits = format_results(state["groups"], scores, rank(scores, req.k), backend.method) return SearchResponse(query=req.query, method=backend.method, k=req.k, results=hits)
@app.post("/classify", response_model=ClassifyResponse)def classify(req: ClassifyRequest) -> ClassifyResponse: _require_ready() clf = state["classifier"] if clf is None: raise HTTPException(status_code=503, detail="Classifier artifact not available") prob = float(clf["pipeline"].predict_proba([normalize(req.text)])[0, 1]) return ClassifyResponse(text=req.text, potentially_unfair=prob >= clf["threshold"], probability=round(prob, 4), threshold=round(clf["threshold"], 4))
@app.get("/", include_in_schema=False)def index() -> FileResponse: return FileResponse(STATIC_DIR / "index.html")
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182"""Model / index registry and loading of persisted artifacts."""
from __future__ import annotations
import jsonfrom pathlib import Path
import numpy as np
from app.data import SentenceGroupfrom app.retrieval import BM25Backend, DenseBackend, MeanPoolingEncoder
ARTIFACTS_DIR = Path(__file__).resolve().parent.parent / "artifacts"
# Pinned Hugging Face revisions (commit SHAs) so builds are reproducible.DENSE_MODELS = { "minilm": { "hf_id": "sentence-transformers/all-MiniLM-L6-v2", "revision": "1110a243fdf4706b3f48f1d95db1a4f5529b4d41", "max_length": 256, }, "contracts_bert": { "hf_id": "nlpaueb/bert-base-uncased-contracts", "revision": "f918d2e0cf491ba2c5fcf9f82d5e9603b8c5f3ea", "max_length": 256, },}METHODS = ["bm25", *DENSE_MODELS]
def model_dir(method: str, artifacts_dir: Path = ARTIFACTS_DIR) -> Path: return artifacts_dir / "models" / method
def embeddings_path(method: str, artifacts_dir: Path = ARTIFACTS_DIR) -> Path: return artifacts_dir / f"embeddings_{method}.npy"
def download_model(method: str, artifacts_dir: Path = ARTIFACTS_DIR) -> Path: from huggingface_hub import snapshot_download
spec = DENSE_MODELS[method] target = model_dir(method, artifacts_dir) snapshot_download( spec["hf_id"], revision=spec["revision"], local_dir=target, allow_patterns=["*.json", "vocab.txt", "model.safetensors", "pytorch_model.bin"] if method == "contracts_bert" else ["*.json", "vocab.txt", "model.safetensors"], ) return target
def load_encoder(method: str, artifacts_dir: Path = ARTIFACTS_DIR) -> MeanPoolingEncoder: path = model_dir(method, artifacts_dir) if not path.exists(): raise FileNotFoundError(f"Model for {method!r} not found at {path}; run scripts/build_index.py") return MeanPoolingEncoder(str(path), max_length=DENSE_MODELS[method]["max_length"])
def load_corpus(artifacts_dir: Path = ARTIFACTS_DIR) -> list[SentenceGroup]: data = json.loads((artifacts_dir / "corpus.json").read_text(encoding="utf-8")) return [SentenceGroup.from_dict(d) for d in data]
def load_backend(method: str, groups: list[SentenceGroup], artifacts_dir: Path = ARTIFACTS_DIR): texts = [g.text for g in groups] if method == "bm25": # Term statistics are rebuilt deterministically from the persisted corpus (<1 s). return BM25Backend(texts) if method not in DENSE_MODELS: raise ValueError(f"Unknown method {method!r}; expected one of {METHODS}") embeddings = np.load(embeddings_path(method, artifacts_dir)) if embeddings.shape[0] != len(groups): raise ValueError(f"{method} embeddings have {embeddings.shape[0]} rows, corpus has {len(groups)}") return DenseBackend(method, load_encoder(method, artifacts_dir), embeddings)
def selected_method(artifacts_dir: Path = ARTIFACTS_DIR) -> str: """Backend frozen by the development evaluation (falls back to BM25 before selection).""" path = artifacts_dir / "selection.json" if path.exists(): return json.loads(path.read_text(encoding="utf-8"))["selected"] return "bm25"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131"""Retrieval backends: exact BM25 (sparse) and exact cosine search over dense embeddings.
Every backend exposes ``scores(query) -> np.ndarray`` over the indexed groups, soranking, exclusion and result formatting are shared and identical across methods."""
from __future__ import annotations
import refrom collections import Counter
import numpy as npfrom scipy import sparse
from app.data import SentenceGroup, normalize
_TOKEN_RE = re.compile(r"\w+")
def tokenize(text: str) -> list[str]: return _TOKEN_RE.findall(normalize(text))
class BM25Backend: """Okapi BM25 with Lucene-style non-negative IDF, scored exactly via a sparse matrix."""
method = "bm25"
def __init__(self, texts: list[str], k1: float = 1.5, b: float = 0.75): docs = [tokenize(t) for t in texts] self.vocab: dict[str, int] = {} rows, cols, tfs = [], [], [] for i, doc in enumerate(docs): for term, tf in Counter(doc).items(): rows.append(i) cols.append(self.vocab.setdefault(term, len(self.vocab))) tfs.append(tf) n_docs = len(docs) tf = sparse.csr_matrix((tfs, (rows, cols)), shape=(n_docs, len(self.vocab)), dtype=np.float64) doc_len = np.array([len(d) for d in docs], dtype=np.float64) df = np.bincount(cols, minlength=len(self.vocab)) self.idf = np.log1p((n_docs - df + 0.5) / (df + 0.5)) # Precompute the saturated term weight for every (doc, term) pair. tf = tf.tocoo() norm = k1 * (1 - b + b * doc_len[tf.row] / doc_len.mean()) weights = tf.data * (k1 + 1) / (tf.data + norm) self.matrix = sparse.csc_matrix((weights, (tf.row, tf.col)), shape=tf.shape)
def scores(self, query: str) -> np.ndarray: q = np.zeros(len(self.vocab)) for term, count in Counter(tokenize(query)).items(): j = self.vocab.get(term) if j is not None: q[j] = count * self.idf[j] return np.asarray(self.matrix @ q).ravel()
class MeanPoolingEncoder: """Transformer encoder with attention-mask-aware mean pooling + L2 normalization.
This is the pooling configuration of all-MiniLM-L6-v2 and the pooling policy the plan prescribes for CONTRACTS-BERT, so both dense models share one code path. """
def __init__(self, model_path: str, max_length: int = 256, batch_size: int = 64): import torch from transformers import AutoModel, AutoTokenizer
self._torch = torch self.tokenizer = AutoTokenizer.from_pretrained(model_path) self.model = AutoModel.from_pretrained(model_path).eval() self.max_length = max_length self.batch_size = batch_size
def encode(self, texts: list[str]) -> np.ndarray: torch = self._torch # Batch texts of similar length together to minimise padding; restore order after. order = np.argsort([len(t) for t in texts], kind="stable") out = np.empty((len(texts), self.model.config.hidden_size), dtype=np.float32) with torch.inference_mode(): for start in range(0, len(texts), self.batch_size): idx = order[start:start + self.batch_size] batch = self.tokenizer( [texts[i] for i in idx], padding=True, truncation=True, max_length=self.max_length, return_tensors="pt", ) hidden = self.model(**batch).last_hidden_state mask = batch["attention_mask"].unsqueeze(-1).to(hidden.dtype) pooled = (hidden * mask).sum(1) / mask.sum(1).clamp(min=1e-9) out[idx] = torch.nn.functional.normalize(pooled, p=2, dim=1).numpy() return out
class DenseBackend: """Exact cosine search: embeddings are unit-norm, so cosine is a dot product."""
def __init__(self, method: str, encoder: MeanPoolingEncoder, embeddings: np.ndarray): self.method = method self.encoder = encoder self.embeddings = embeddings
def scores(self, query: str) -> np.ndarray: q = self.encoder.encode([normalize(query)])[0] return self.embeddings @ q
def rank(scores: np.ndarray, k: int, eligible: np.ndarray | None = None) -> np.ndarray: """Top-k indices by descending score; ties broken by ascending index (stable).""" s = scores.astype(np.float64, copy=True) if eligible is not None: s[~eligible] = -np.inf order = np.lexsort((np.arange(len(s)), -s)) order = order[np.isfinite(s[order])] return order[:k]
def format_results(groups: list[SentenceGroup], scores: np.ndarray, indices: np.ndarray, method: str) -> list[dict]: return [ { "rank": r + 1, "group_id": groups[i].group_id, "text": groups[i].text, "score": round(float(scores[i]), 6), "method": method, "occurrences": [ {"contract": o.contract, "position": o.position, "original": o.original} for o in groups[i].occurrences ], } for r, i in enumerate(indices) ]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121const $ = (id) => document.getElementById(id);const form = $("search-form");const query = $("query");
function showError(message) { $("error").textContent = message; $("error").hidden = !message;}
async function post(path, body) { const res = await fetch(path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }); const data = await res.json().catch(() => ({})); if (!res.ok) { const detail = Array.isArray(data.detail) ? data.detail.map((d) => `${d.loc.at(-1)}: ${d.msg}`).join("; ") : data.detail || res.statusText; throw new Error(detail); } return data;}
function sources(occurrences) { const shown = occurrences.slice(0, 3).map((o) => `${o.contract} #${o.position + 1}`); if (occurrences.length > 3) shown.push(`+${occurrences.length - 3} more`); return shown.join(", ");}
function renderResults(data) { const box = $("results"); box.replaceChildren(); const summary = document.createElement("p"); summary.className = "summary"; summary.textContent = `Top ${data.results.length} by ${data.method}`; box.append(summary); if (!data.results.length) { const p = document.createElement("p"); p.className = "empty"; p.textContent = "No matching sentences."; box.append(p); return; } for (const hit of data.results) { const card = document.createElement("article"); card.className = "card"; card.innerHTML = ` <span class="rank">${hit.rank}</span> <p class="text"></p> <div class="meta"> <span class="source"></span> <span class="score">score ${hit.score.toFixed(3)}</span> </div>`; card.querySelector(".text").textContent = hit.text; card.querySelector(".source").textContent = `Source: ${sources(hit.occurrences)}`; card.title = hit.occurrences.map((o) => `${o.contract} #${o.position + 1}: ${o.original}`).join("\n"); box.append(card); }}
async function runSearch() { const text = query.value.trim(); if (!text) { showError("Enter a sentence to search."); return; } showError(""); $("search-btn").disabled = true; try { renderResults(await post("/search", { query: text, k: Number($("k").value) })); } catch (err) { showError(`Search failed: ${err.message}`); } finally { $("search-btn").disabled = false; }}
async function runClassify() { const text = query.value.trim(); if (!text) { showError("Enter a sentence to classify."); return; } showError(""); $("classify-btn").disabled = true; try { const r = await post("/classify", { text }); const box = $("classification"); box.className = `classification ${r.potentially_unfair ? "unfair" : "fair"}`; box.replaceChildren(); const strong = document.createElement("strong"); strong.textContent = r.potentially_unfair ? "Potentially unfair clause" : "Not flagged as potentially unfair"; const detail = document.createElement("span"); detail.textContent = ` (model score ${r.probability.toFixed(2)}, threshold ${r.threshold.toFixed(2)})`; const note = document.createElement("small"); note.textContent = r.note; box.append(strong, detail, note); box.hidden = false; } catch (err) { showError(`Classification failed: ${err.message}`); } finally { $("classify-btn").disabled = false; }}
async function init() { try { const res = await fetch("/ready"); const info = await res.json(); if (!info.ready) throw new Error("not ready"); $("method").textContent = info.method; $("status").textContent = `${info.corpus_groups.toLocaleString()} unique sentences indexed`; $("classify-btn").hidden = !info.classifier; } catch { $("status").textContent = "Service is starting or unavailable — try again shortly."; }}
form.addEventListener("submit", (e) => { e.preventDefault(); runSearch(); });$("classify-btn").addEventListener("click", runClassify);query.addEventListener("keydown", (e) => { if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { e.preventDefault(); runSearch(); }});query.addEventListener("input", () => { $("classification").hidden = true; });init();123456789101112131415161718192021222324252627282930313233343536373839404142434445<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CLAIR — Clause Intelligence and Retrieval</title> <link rel="stylesheet" href="/static/style.css"></head><body> <main> <header> <h1>CLAIR <span class="expansion">Clause Intelligence and Retrieval</span></h1> <p class="sub">Describe a clause in your own words to find how 50 real Terms of Service phrase it, and check whether it reads as potentially unfair.</p> <p class="status" id="status">Connecting…</p> </header>
<form id="search-form"> <label for="query">Sentence or clause</label> <textarea id="query" rows="4" maxlength="2000" required placeholder="e.g. We may suspend or terminate your account at any time without notice."></textarea>
<div class="controls"> <label class="inline" for="k">Results <select id="k"> <option value="2">2</option> <option value="5">5</option> <option value="10" selected>10</option> <option value="20">20</option> </select> </label> <span class="method">Retrieval: <strong id="method">–</strong></span> <span class="spacer"></span> <button type="button" id="classify-btn" class="secondary" hidden>Classify</button> <button type="submit" id="search-btn">Search</button> </div> <p class="hint">Ctrl+Enter to search. Scores rank results; they are not probabilities.</p> </form>
<section id="classification" class="classification" hidden aria-live="polite"></section> <p id="error" class="error" hidden role="alert"></p> <section id="results" aria-live="polite"></section> </main> <script src="/static/app.js"></script></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135:root { --bg: #f7f7f5; --surface: #ffffff; --text: #1d1d1b; --muted: #66665f; --border: #deded8; --accent: #1f5f8b; --accent-text: #ffffff; --warn-bg: #fdf1e7; --warn-text: #8a4300; --ok-bg: #eaf5ec; --ok-text: #1f6b35; --error: #b42318;}
@media (prefers-color-scheme: dark) { :root { --bg: #161615; --surface: #20201e; --text: #ececea; --muted: #a3a39c; --border: #3a3a36; --accent: #6aaede; --accent-text: #0e1a24; --warn-bg: #3a2715; --warn-text: #f3b77d; --ok-bg: #1c3222; --ok-text: #8fd3a2; --error: #ff8a80; }}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;}
main { max-width: 820px; margin: 0 auto; padding: 32px 16px 64px; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }h1 .expansion { display: block; font-size: 0.95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }.sub { margin: 10px 0 0; max-width: 62ch; }.status { margin: 8px 0 24px; font-size: 0.85rem; color: var(--muted); }
form { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px;}
label { font-weight: 600; font-size: 0.9rem; }
textarea { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; resize: vertical;}
textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }.spacer { flex: 1; }.method { font-size: 0.9rem; color: var(--muted); }.method strong { color: var(--text); }
select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px;}
button { font: inherit; font-weight: 600; padding: 8px 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); cursor: pointer;}button.secondary { background: transparent; color: var(--accent); }button:disabled { opacity: 0.6; cursor: progress; }
.hint { margin: 10px 0 0; font-size: 0.8rem; color: var(--muted); }.error { color: var(--error); margin-top: 16px; }
.classification { margin-top: 16px; padding: 12px 16px; border-radius: 10px; font-size: 0.95rem;}.classification.unfair { background: var(--warn-bg); color: var(--warn-text); }.classification.fair { background: var(--ok-bg); color: var(--ok-text); }.classification small { display: block; margin-top: 4px; opacity: 0.85; }
#results { margin-top: 24px; display: grid; gap: 12px; }.summary { font-size: 0.85rem; color: var(--muted); margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;}.rank { grid-row: span 2; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }.text { margin: 0; overflow-wrap: anywhere; }.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.82rem; color: var(--muted); }.meta .score { font-variant-numeric: tabular-nums; }.empty { color: var(--muted); }
@media (max-width: 520px) { .spacer { display: none; } .controls button { flex: 1; }}123version https://git-lfs.github.com/spec/v1oid sha256:3151b918b4901d86170a2454e650ace9ff1a322e5589ba2d5565027101368fb4size 65845312345678910111213141516171819{ "selected": "bm25", "numeric_rule_result": "contracts_bert", "production_gate_rejected": { "contracts_bert": "Section 8 gate: +0.024 dev nDCG@10 does not justify ~80x latency, +441 MB model and the weakest paraphrase-probe behaviour (dev-only decision, pre-holdout)." }, "frozen_at": "2026-10-16T17:48:15+00:00", "rule": "start at bm25; switch to a more complex method only if dev nDCG@10 gain >= 0.02 and it wins on >= 60% of dev query contracts; then apply the plan section 8 production gate", "rule_log": [ "minilm vs bm25: gain=-0.1167, contract win share=0.04 -> keep bm25", "contracts_bert vs bm25: gain=+0.0243, contract win share=0.72 -> switch" ], "split_seed": 20261016, "dev_ndcg@10": { "bm25": 0.6030940728715899, "minilm": 0.48640840014119635, "contracts_bert": 0.6274144553392206 }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139-1-1-1-11-1-1-1-111111-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-11-11-111-1-1-1-1-1-1-11-1-1-11-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193-1-1-1-11-1-1-1-1-1-1-11-1-11-1-11-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-11-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391-1-1-1-1-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11111-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111111-1-11-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-11-1-1-11-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960-11-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1111-1-111-1-1-11234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-11-1-1-1-1-1-1-1-1-11-111-1-1-1-1-1-111-1-1-11-1-1-11-1-1-11-1-1-1-11-1-1-1-1-1-1-1-11-1-1-1-1-1-1-11-1-1-111-11-1-1-111-1-1-1-1-1-1-1-112345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712811-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-11-111-1-1-1-1-1-1-1-1-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778-1-111-11-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1111-1-1-1-1-1-11-1-1-1-11-1-1-1-1-111-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-11111-1-1-11-1-1-1-1-1-111-1-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-11-1-1-11-11-1-1-1-1-1-1-1-1-11111-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-11-111-1-1-1-1-1-1-1-1-11-111-1-11-1-1-1-1-111-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-11-1-1-1-11123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140-1-111-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-11-1-1-1-1-111-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-111-1-111-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498-1-1-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111111-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11111-1-1-1-1-1-1-1-1-1111-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236-1-1-1-1-1-1-111-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-11-11-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-11-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1111111-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-11-1-1-11-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-111-1-1-1-1-1-1-1-1-111-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-111-1-1-1-1-1-111-1-1-111-1-1-1-11-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293-1-1-11-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-11-1-1-1-1-1-1-1-1-1111-1-111-1-1-1-1-1-1-1-1-1-111-11234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713721-1-1-1-11-1-11-1-1-1-1-11-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-11-1-1-111111111-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11111-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158-1-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-111-11-11-111-1-1-1-11-11-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-11-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-111-1-1-1-1-1-11-1-1-1-1-1-1-1-11-11-1-1-1-11-11111-11111111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1111-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-11-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-111-1-1-1-1-11-1111-1-1-1-1-1-11-1-111-1-111-1-1-1-1-1-1-111111-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130-1-1-11-1-11-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1111-11-11-11-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-11-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-111-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-11111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475-1-1-1-1-11-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1111-1-1-1-1-1-1-11-1-1-1-1-1-1-1-111111-1-1-1-11234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-11-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-11-1-11-1-11-1-1-11-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240-11-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-111-1-1-11-1-1-1-1-1-1-1-1-1111-1-1-1-1-11-11-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-11111-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147-1-11-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-11-1-1-1-1-1-1-1-1-111-11-1-1-1-1-11-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212-1-1-1-11-1-1111-111-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-11-1-111-1-1-1-1-1-1-1-1-11-11111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-11-11-111-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-11-1-1-1-1-1-1-1-111-1-11-111-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455-1-1-1-1-1-1-1-1-11-1-1-1-1-11-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-11-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-11-1-111111111111-1-11-1-1-11-1-1-11-1-1-1-11-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-11-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-1-1-1-1111-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283-1-1-1-1-1-1-11-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-11-1111-1-111-1-1-1-1-1-1-1-1-1-1-11-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-11-1-1-1-1-1-1-1-1-111-11-111-1-1-1-1-1-11-111-1-1-1-1-1-1-1111-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11111-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141-1-1-1-1-1-1-1-11-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-111111111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-111-1-11-1-1-1-1-1-111-1-1-1-11111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-11-1-11111-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1111-1-1-111-1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195-1-1-1-1-1-1-1-11-11-11-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-11-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-11-11-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-11-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-11111-1-1-111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-111-1-1-1-1111-1-1-11-1-11-1-1-1-1-1-1-1-11-11-1-11-1-1-1-1-1-1-1-1.dockerignoreAdded+16
DockerfileAdded+36
LICENSEAdded+21
README.md+35-5
app/__init__.pyAdded
app/data.pyAdded+185
app/main.pyAdded+167
app/models.pyAdded+82
app/retrieval.pyAdded+131
app/static/app.jsAdded+121
app/static/index.htmlAdded+45
app/static/style.cssAdded+135
artifacts/classifier.joblibAdded+3
artifacts/selection.jsonAdded+19
data/ToS/Labels/9gag.txtAdded+139
data/ToS/Labels/Academia.txtAdded+193
data/ToS/Labels/Airbnb.txtAdded+391
data/ToS/Labels/Amazon.txtAdded+132
data/ToS/Labels/Atlas.txtAdded+60
data/ToS/Labels/Betterpoints_UK.txtAdded+113
data/ToS/Labels/Booking.txtAdded+128
data/ToS/Labels/Crowdtangle.txtAdded+78
data/ToS/Labels/Deliveroo.txtAdded+143
data/ToS/Labels/Dropbox.txtAdded+121
data/ToS/Labels/Duolingo.txtAdded+140
data/ToS/Labels/Endomondo.txtAdded+498
data/ToS/Labels/Evernote.txtAdded+236
data/ToS/Labels/Facebook.txtAdded+146
data/ToS/Labels/Fitbit.txtAdded+158
data/ToS/Labels/Google.txtAdded+93
data/ToS/Labels/Headspace.txtAdded+372
data/ToS/Labels/Instagram.txtAdded+158
data/ToS/Labels/LindenLab.txtAdded+344
data/ToS/Labels/LinkedIn.txtAdded+194
data/ToS/Labels/Masquerade.txtAdded+130
data/ToS/Labels/Microsoft.txtAdded+548
data/ToS/Labels/Moves-app.txtAdded+75
data/ToS/Labels/Netflix.txtAdded+86
data/ToS/Labels/Nintendo.txtAdded+188
data/ToS/Labels/Oculus.txtAdded+240
data/ToS/Labels/Onavo.txtAdded+147
data/ToS/Labels/PokemonGo.txtAdded+212
data/ToS/Labels/Rovio.txtAdded+99
data/ToS/Labels/Skype.txtAdded+455
data/ToS/Labels/Skyscanner.txtAdded+83
data/ToS/Labels/Snap.txtAdded+168
data/ToS/Labels/Spotify.txtAdded+293
data/ToS/Labels/Supercell.txtAdded+141
data/ToS/Labels/Syncme.txtAdded+115
data/ToS/Labels/Tinder.txtAdded+195