Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Occurrence Counter

text.count_occurrences

ProductionEngine wrapper (Class A)Deterministicstrictfastv1.0.0
File inputNo network

Overview

You pass text (or a file_ref) and one or more literal or regex patterns; we return per-pattern occurrence counts with optional match offsets. Regex uses RE2/J (linear-time, ReDoS-safe). Do not use this for semantic entity extraction.

Batch pattern counting with per-pattern results saves round-trips and avoids LLM miscounting.

Reliability

STRICT and deterministic for literal patterns on this deployment. Regex uses RE2/J (linear-time, ReDoS-safe); regex_engine=re2j when regex patterns are used. Input validation (not retryable): missing patterns; too many patterns; empty literal; pattern too long; invalid regex; neither text nor file_ref.

Context footprint

Batch counting in a single call saves multiple tool invocations and avoids LLM counting errors. Accepts inline text up to 1000000 chars or file input via file_ref (up to 2 MB). Upload files via POST /v1/files/upload before passing file_ref. A successful call costs 1 execution credit.

When to use it

When you need multiple pattern counts in one call with per-pattern breakdowns.

For semantic entity extraction — use dedicated NLP skills.

Powered by RE2/J, Google's linear-time regular-expression engine that counts pattern matches without risk of catastrophic backtracking.

Scope

Note
Counts occurrences of multiple literal or regex patterns in text, returning per-pattern counts.

Non-goals

  • Does not perform semantic analysis
  • Does not extract entities
  • Regex has safety limits (max pattern length, max pattern count)

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

analysistext-processing

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input976.6 KBMax file size1.9 MB

File limits

Constraints this skill applies to your input and generated files. The “Limited by” column shows the static source of each cap; none of these can be raised by upgrading your plan.

LimitValueLimited by
Maximum size per input file1.9 MiBSkill maximum

How we handle your data

Sensitive input, safe output
What this means

This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.

Squillify guarantees
  • Runs inside Squillify
  • This skill runs inside Squillify.
  • Payloads are not sent to an external service by this skill.
  • Squillify does not permanently store submitted payloads.
  • Telemetry records metadata only, not submitted content.
  • Submitted payloads are not used for training.
  • Submitted payloads are not reviewed by humans.
  • This skill does not target sensitive data.
  • The response does not contain submitted content.
Your responsibility

Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
textstringNoBounded inline text source. Required unless file_ref is provided.
file_refstringNoTenant-scoped opaque text-file reference. Omit it to use the required inline text; never send both.
patternsarrayYesBounded array containing from 1 through 50 items in reporting order; each item has id, value, and literal-or-regex type properties.
case_sensitivebooleanNoWhether literal case is significant; omit it for true.
overlapbooleanNoWhether literal matches may overlap; omit it for false.
normalizationstringNoUnicode normalization; omit it for none.
return_matchesbooleanNoWhether code-point offsets are returned; omit it for false.

Output schema

FieldTypeRequiredDescription
skillstringYesProducing skill key.
unitstringYesMeasurement unit for the returned match total.
policystringYesApplied search policy.
total_countintegerYesTotal matches across patterns. This non-negative total is bounded by the documented input limit.
countsarrayYesBounded array containing from 1 through 50 items, one per supplied pattern; each item has id, count, and optional match-span properties.
case_sensitivebooleanYesApplied literal-case setting.
overlapbooleanYesApplied literal-overlap setting.
normalizedbooleanYesWhether normalization was applied.
normalizationstringYesApplied normalization form.
offset_unitstringNoReturned offset unit.
regex_enginestringNoApplied regular-expression engine.
warningsarrayYesBounded warning array containing from 0 through 50 items, where each item is one non-fatal advisory string.

API contract

POST /v1/execute
curl
curl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"text.count_occurrences","input":{"text":"hello world hello","patterns":[{"id":"hello","value":"hello","type":"literal"}]}}'
Integrations
TypeScript SDK
import { Squillify } from "@squillify/sdk";

const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });

const { output } = await sq.execute("text.count_occurrences", {"patterns":[{"type":"literal","id":"hello","value":"hello"},{"type":"literal","id":"world","value":"world"}],"text":"hello world hello"});

Errors

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.

Other limits

LimitValue
Recommended inline bytes32 KiB

Limitations

  • Does not perform semantic analysis
  • Does not extract entities
  • Regex has safety limits (max pattern length, max pattern count)
  • Entity extraction (use NLP tools)

How to call

POST /v1/execute (requires authentication)

Request bodyjson
{
  "skillKey": "text.count_occurrences",
  "input": {
    "patterns": [
      {
        "type": "literal",
        "id": "hello",
        "value": "hello"
      },
      {
        "type": "literal",
        "id": "world",
        "value": "world"
      }
    ],
    "text": "hello world hello"
  }
}

Examples

Two literal patterns

Inputjson
{
  "patterns": [
    {
      "type": "literal",
      "id": "hello",
      "value": "hello"
    },
    {
      "type": "literal",
      "id": "world",
      "value": "world"
    }
  ],
  "text": "hello world hello"
}
Expected outputjson
{
  "policy": "multi_pattern",
  "normalized": false,
  "normalization": "none",
  "skill": "text.count_occurrences",
  "counts": [
    {
      "id": "hello",
      "count": 2
    },
    {
      "id": "world",
      "count": 1
    }
  ],
  "warnings": [],
  "total_count": 3,
  "case_sensitive": true,
  "unit": "occurrence",
  "overlap": false
}

Case-insensitive literal

Inputjson
{
  "text": "HELLO hello Hello",
  "case_sensitive": false,
  "patterns": [
    {
      "type": "literal",
      "id": "hello",
      "value": "Hello"
    }
  ]
}
Expected outputjson
{
  "policy": "multi_pattern",
  "normalized": false,
  "normalization": "none",
  "skill": "text.count_occurrences",
  "counts": [
    {
      "id": "hello",
      "count": 3
    }
  ],
  "warnings": [],
  "total_count": 3,
  "case_sensitive": false,
  "unit": "occurrence",
  "overlap": false
}
  • Multi-keyword frequency analysis
  • Content audit
  • Pattern density measurement

Avoid for

  • Entity extraction (use NLP tools)

Composable with

Safety & privacy

  • Runs without calling any external service.
  • Your payloads are never stored permanently.
  • Telemetry captures metadata only — never your payload contents.
  • We never train models on your payloads.
  • No human reviews your payloads.

Tags

textanalysisstatistics