Skip to main content

Module classify

Module classify 

Source
Expand description

Content classification for plain-text clipboard input.

Returns Text, Url, or Code. The caller must have already ruled out image bytes via magic-byte sniffing — this module never returns Image.

Decision order (first match wins):

  1. trim; empty / > 64 KB → Text
  2. shebang #!/... → Code
  3. whole-string URL parse with scheme allow-list → Url
  4. {...} / [...] shape + valid JSON → Code
  5. any line starts with a code-opener keyword → Code
  6. symbol-to-alphanumeric ratio > 0.20 with at least one code bigram → Code
  7. ≥ 2 distinct code bigrams → Code
  8. indented line(s) with a code bigram → Code
  9. otherwise → Text

Functions§

detect
Classify a plain-text clip. Never returns Image.