{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AB
thethe
blackblack
dogdingo
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from collatex import *\n", "\n", "json_input = {\n", " \"witnesses\" : [ \n", " {\n", " \"id\": \"A\",\n", " \"tokens\": [ \n", " { \"t\" : \"the\" }, \n", " { \"t\" : \"black\" }, \n", " { \"t\" : \"dog\" } \n", " ]\n", " },\n", " {\n", " \"id\": \"B\",\n", " \"tokens\": [ \n", " { \"t\" : \"the\" }, \n", " { \"t\" : \"black\", \"tag\" : \"emph\" }, \n", " { \"t\" : \"dingo\" } \n", " ]\n", " } \n", " ]\n", "}\n", "\n", "collate_pretokenized_json(json_input, output=\"html2\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AB
thethe
blackblack
dogdingo
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "def match_properties(token1_data, token2_data):\n", " return token1_data == token2_data\n", "\n", "collate_pretokenized_json(json_input, properties_filter=match_properties, output=\"html2\")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }