Fatih Kansoy

Projects · Software · 2026

sicilahval

I wrote a Python program to do this. Combining a language-model skill to structure the text with Python code to verify every quotation lets me extract the data cleanly. So my code does the following. Given biographies in Sicill-i Ahvâl's format, convert them into structured data (CSV/JSON tables in a SQLite database) along with all the evidence for each fact in the original text. In other words, automate what would otherwise be a laborious process of converting biographies into databases and getting the numbers right.

Version
0.1.7, 24 October 2026
Licence
Apache-2.0
Python
3.10 or later
Reads
TXT, Markdown, DOCX, PDF, HTML, RTF and ODT
Writes
CSV, JSON and SQLite
An open package with a database and output sheets beside it, one sheet rising out
Contents
  1. Why a package
  2. How it works
  3. What the checks catch
  4. A real record
  5. Limits

Why a package

The problem with the text of a Sicill-i Ahvâl is that it all tends to run together. What you have is one continuous block of text describing an official's career, his family when he was born, what languages he was educated in, where he was posted and how much he got paid and so on and so forth. So if you want to ask questions about this stuff (what appointments did they hold, when, and what were they paid?) you need columns like "appointments" and "dates" and "salary." But I didn't want to lose the original flavor of the text, at least not more than was necessary. So I wrote a program called sicilahval that would let me express a common schema for this type of text, in such a way as to preserve its flavor but also allow me to audit it and share my readings.

The advantage of this schema is that it distinguishes unambiguously between these three categories. You can see whether a given statement is stated explicitly in the text, or whether you have to make any inferences as a reader, and if so what they are. And if there are conflicting interpretations of a sentence that came from the same original statement (when the source text can be read more than one way), these will be visible also.

How it works

The workflow is to split the work between a language model and a Python program. Use the language model (or other assistant) to read and extract structure from a biography, and use my Python program to do all the necessary text processing and table creation. For the reading part I'll use an existing assistant like OpenAI's Codex or Anthropic's Claude Code. My Python package doesn't call any language model, so you don't need an API key to use it.

  1. Prepare

    Python then reads the source file, splits it into numbered segments, and computes the SHA-256 cryptographic checksum of the original text. I give each segment a unique identifier.

  2. Read

    The language model represents each biography as an explicit representation of the set of interrelated facts about each official's life. Each fact would include not only historical events and their dates, but all information about payments (with exact citation to the source where each fact was found).

  3. Validate

    And finally I can write a program that checks the structure of the schema, makes sure all the checksums in the data match up with the schema, and so on. In other words, a program that validates the quotations, numbers, and all my decisions about what to cover (or not) for each segment of text, and that everything is properly formatted.

  4. Export

    You can export verified readings directly to linked CSV tables, a complete JSON file, or an SQLite database. of all cells will be exported in an identical manner and without any further processing. Multiple file formats are available.

python -m pip install "sicilahval @ git+https://github.com/kansoy/ottoman-personnel-tools.git@v0.1.7"
sicilahval install-skill --target claude --scope user
sicilahval prepare records.docx --out work --language en
# The language model reads the text and writes work/records.json.
sicilahval validate work/records.json --source work/source.json
sicilahval export work/records.json --source work/source.json --out data

What the checks catch

The validation routines are all pretty mechanical. The boundaries between whole numbers (and so on) are all handled very strictly. I can't even add "150 kuruş" to the line that says "1150 kuruş". Among other things, version 0.1.3 now includes a bunch of regression tests to make sure I handle decimal points and plus and minus signs and so on.

def _raw_attached(raw: str, quotes: list[str], *, monetary: bool = False) -> bool:
    if not monetary:
        return any(raw in quote for quote in quotes)
    for quote in quotes:
        # Check the source's complete digit tokens even when raw includes a
        # currency: "150 kuruş" must not attach to "1150 kuruş". A comma or
        # full stop extends a number only when another digit follows it.
        numbers = list(re.finditer(
            r"[+-]?\d{1,3}(?:[   ]\d{3})+(?!\d)(?:[.,]\d+)*|[+-]?\d+(?:[.,]\d+)*", quote))
        for match in re.finditer(re.escape(raw), quote):
            if not any(number.start() < match.end() and number.end() > match.start()
                       and (number.start() < match.start() or number.end() > match.end())
                       for number in numbers):
                return True
    return False

A real record

In this repository I include two full biographies of register entries (with references to the archival sources) including Manuk Filcancıyan who converted to Islam and changed his name to Mahmut Süreyya in 4 Rebiülevvel AH 1306. In this version, I interpret the name change as limited to 4 Rebiülevvel AH 1306 (not across all of AH 1306) so that one can regenerate all tables from this biography .

sicilahval demo --out example-output --language en

In the table of payment descriptions just described, you can see this for an example salary expressed in words. The transformation to the corresponding numeric value is shown together with an indication of the precise phrasing from which the figure was generated.

Date in the recordYearEventAmount as writtenKuruş
1 Muharrem 12861869/70Appointment to the Diyarbakır telegraph officeyedi yüz yirmi720
14 Rebiülahir 12871870/71Transfer to the Beyoğlu telegraph centredört yüz seksen480
26 Zilkade 12931876/77Rise on reorganisationyedi yüz elli750
2 Rebiülahir 12971879/80Reductionaltı yüz600
4 Rebiülevvel 13061888/89Rise, the incrementyetmiş beş75
4 Rebiülevvel 13061888/89Rise, the new salaryaltı yüz yetmiş beş675

In addition, in a second pass of this review process, the extraction of both biographies was refreshed and again found to correspond precisely to the archival text provided as input. All 28 segments of source text are explicitly marked for coverage decisions, and both exports now also pass not only the quotation, reference, and CSV-to-SQLite cell parsing tests described above but also the further 46 unit tests shipped with version 0.1.7.

RecordFactsEventsDatesPayments
Manuk Filcancıyan, later Mahmut Süreyya3314146
Zenop Tangaryan38212510

Limits

Automated validation can't guarantee historical accuracy and completeness on its own. So it is important that when the text of a difficult passage is ambiguous there is still a way for a human reader to compare against the source. The package doesn't do handwriting recognition, so the images or scans will need to be converted into some verified transcription (or an OCR'd version) before using this software. Linking between registers and coding places and jobs, and building person-year panels are separate empirical decisions left to the researcher.

The opening of the sicilahval methods note
The opening of the English methods note, From personnel biographies to auditable data. A Turkish note accompanies it.

The software, the skill and the documentation are released under the Apache-2.0 licence. Cite it as Kansoy, Fatih. 2026. sicilahval: Evidence-linked extraction of Ottoman personnel records. Version 0.1.7.

More projects

All projects