{
 "metadata": {
  "name": "",
  "signature": "sha256:67957c32de0b25985026234b7339a22f49875ce40763446383679750634e3066"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import sys\n",
      "sys.path.insert(0, '..')\n",
      "\n",
      "from formtype.extractor import FormExtractor\n",
      "from formtype.storage import load_html\n",
      "from formtype.annotation import load_data, print_form_html"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fe = FormExtractor.load(\"../model.joblib\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "url = \"http://www08.eyny.com/\"\n",
      "idx = 1\n",
      "\n",
      "data, url = load_data(url)\n",
      "tree = load_html(data, url)\n",
      "forms = tree.xpath(\"//form\")\n",
      "\n",
      "print_form_html(forms[idx])\n",
      "fe.classify_proba(forms[idx], 0.01)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "<form id=\"scbar_form\" method=\"post\" action=\"search.php?searchsubmit=yes\">\n",
        "<input type=\"hidden\" name=\"mod\" id=\"scbar_mod\" value=\"search\"><input type=\"hidden\" name=\"formhash\" value=\"2221a907\"><input type=\"hidden\" name=\"srchtype\" value=\"title\"><input type=\"hidden\" name=\"srchfrom\" value=\"0\"><input type=\"hidden\" name=\"srhfid\" value=\"\"><input type=\"hidden\" name=\"srhlocality\" value=\"forum::index\">\n",
        "<input type=\"text\" name=\"srchtxt\" id=\"scbar_txt\" value=\"\">\n",
        "<a href=\"\" id=\"scbar_type\" class=\"showmenu xg1 xs2\">\u641c\u7d22</a>\n",
        "\u641c\u7d22\n",
        "</form>\n"
       ]
      },
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 4,
       "text": [
        "{u'o': 0.055819680860805569, u's': 0.92674512903902495}"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fe.extract_forms_proba(tree, 0.1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 7,
       "text": [
        "[(<Element form at 0x11063a998>, {u'l': 0.99482396809618978}),\n",
        " (<Element form at 0x111833940>, {u's': 0.92674512903902495})]"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}