Skip to content

Instantly share code, notes, and snippets.

@shivdhar
Last active December 16, 2021 21:48
Show Gist options
  • Save shivdhar/b12a92297407632c47a3355e7efaea3d to your computer and use it in GitHub Desktop.
Save shivdhar/b12a92297407632c47a3355e7efaea3d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import json\n"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [],
"source": [
"inp = {\n",
" \"contract_id\": 4,\n",
" \"clauses\": [\n",
" {\n",
" \"name\": \"Recital\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"\",\n",
" \"text\": \"Master Service Agreement Standard\\nTerms and Conditions\\nThese Standard Terms and Conditions, are an integral part of the BCM One, Inc. (“BCM One”) Master\\nService Agreement (“MSA”), Service Orders, Rate Schedules, Service Addendums, and other documents\\nannexed thereto and made part thereof (collectively the “Agreement”) by and between BCM One (on\\nbehalf of itself, its parent, affiliates, successors, and assigns), and the Client and shall be deemed\\naccepted by, and binding upon, Client in accordance with the terms of the Agreement. These Standard\\nTerms and Conditions are subject to change upon written notice to Client.\\n\",\n",
" \"attributes\": [\n",
" {\n",
" \"name\": \"party1\",\n",
" \"value\": \"\",\n",
" \"confidence\": 6,\n",
" \"answer\": \"\",\n",
" \"processed_answer\": \"\",\n",
" },\n",
" {\n",
" \"name\": \"party1_address\",\n",
" \"value\": \"\",\n",
" \"confidence\": 0,\n",
" \"answer\": \"\",\n",
" \"processed_answer\": \"\",\n",
" },\n",
" {\n",
" \"name\": \"party2\",\n",
" \"value\": \"\",\n",
" \"confidence\": 6,\n",
" \"answer\": \"\",\n",
" \"processed_answer\": \"\",\n",
" },\n",
" {\n",
" \"name\": \"party2_address\",\n",
" \"value\": \"\",\n",
" \"confidence\": 0,\n",
" \"answer\": \"\",\n",
" \"processed_answer\": \"\",\n",
" },\n",
" {\n",
" \"name\": \"effective_date\",\n",
" \"value\": \"None\",\n",
" \"confidence\": \"None\",\n",
" \"answer\": \"None\",\n",
" \"processed_answer\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"subject\",\n",
" \"value\": \"standard terms and conditions\",\n",
" \"confidence\": 0.310413386379765,\n",
" \"answer\": \"standard terms and conditions\",\n",
" \"processed_answer\": \"standard terms and conditions\",\n",
" },\n",
" ],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Services and Period of Performance\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"SERVICES\",\n",
" \"text\": \"BCM One shall provide to Client the products, services and solutions set forth in the Agreement and applicable Service Order(s) (each a “Service,” and, collectively, the “Services”). The\\nAgreement and any accompanying documentation, including but not limited to Service Orders, Rate\\nSchedules, Service Addendums, and policies shall describe the Services that are being purchased and\\nform the final written Agreement between BCM One and the Client. Services are subject to availability\\nand BCM One has the right not to accept any service order submitted by Client. BCM One may require a\\ndeposit prior to the provision of any new Service. If an order for any Service has been accepted by BCM\\nOne, BCM One shall provide Services for the term set forth in the Service Order and any renewal periods\\nthereof.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Services\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"SERVICES\",\n",
" \"text\": \"BCM One shall provide to Client the products, services and solutions set forth in the Agreement and applicable Service Order(s) (each a “Service,” and, collectively, the “Services”). The\\nAgreement and any accompanying documentation, including but not limited to Service Orders, Rate\\nSchedules, Service Addendums, and policies shall describe the Services that are being purchased and\\nform the final written Agreement between BCM One and the Client. Services are subject to availability\\nand BCM One has the right not to accept any service order submitted by Client. BCM One may require a\\ndeposit prior to the provision of any new Service. If an order for any Service has been accepted by BCM\\nOne, BCM One shall provide Services for the term set forth in the Service Order and any renewal periods\\nthereof.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"termination\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"TERM\",\n",
" \"text\": \"The term and any renewal terms of the MSA and each Service Order shall be governed by the time period stated therein (the “Term”). If the MSA and/or Service Order do not contain a renewal period, the\\nTerm will be automatically renewed for successive one (1) month terms at BCM One's then current out-\\nof-contract rates, unless cancelled by either party pursuant to the terms of the Agreement.\\n\",\n",
" \"attributes\": [\n",
" {\n",
" \"name\": \"auto_renewal\",\n",
" \"value\": \"False\",\n",
" \"confidence\": 0,\n",
" \"answer\": \"False\",\n",
" \"processed_answer\": \"False\",\n",
" },\n",
" {\n",
" \"name\": \"renewal_period\",\n",
" \"value\": \"\",\n",
" \"confidence\": 0,\n",
" \"answer\": \"\",\n",
" \"processed_answer\": \"\",\n",
" },\n",
" {\n",
" \"name\": \"notice_period\",\n",
" \"value\": \"None\",\n",
" \"confidence\": \"None\",\n",
" \"answer\": \"None\",\n",
" \"processed_answer\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"cure_period\",\n",
" \"value\": \"None\",\n",
" \"confidence\": \"None\",\n",
" \"answer\": \"None\",\n",
" \"processed_answer\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"who_can_terminate\",\n",
" \"value\": \"\",\n",
" \"confidence\": 0,\n",
" \"answer\": \"\",\n",
" \"processed_answer\": \"\",\n",
" },\n",
" ],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Taxes\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"TAXES\",\n",
" \"text\": \"In addition to payment for the rates and charges for Service(s), Client is responsible for payment of all sales, use, gross receipts, value added, excise and other local, state and federal taxes, fees,\\ncharges and surcharges, however designated, imposed on or based upon the provision, sale or use of the\\nServices, excluding taxes based on BCM One's employees, property and net income. If Client claims that\\nits purchase of the Services is subject to tax exemption, Client must furnish BCM One with the proper tax\\nexemption certificate as authorized by the appropriate taxing authority, or required by statute or\\nregulation. If applicable, BCM One shall not collect such tax amounts from Client beginning on the date\\nsuch certificate is provided. However, if BCM One does not collect such amounts in reliance on Client's\\ntax exemption certificate, which certificate is later determined to be inadequate, then, as between BCM\\nOne and Client, Client shall be liable for such uncollected amounts and for all interest, penalties and\\nadditions to tax which are determined to be due with respect to such uncollected amounts. BCM One shall\\nnot issue any credit(s) for applicable taxes, tax-like charges and surcharges assessed prior to BCM One's\\nreceipt of Client's evidence of exemption. Notwithstanding any Client representation that any exemption\\napplication is pending, no exemption shall be available to Client until Client presents BCM One with the\\nvalid certificate(s).\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Payment\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"PAYMENT\",\n",
" \"text\": \"Client must remit payment to BCM One for the full amount indicated in Client's monthly invoice on or before the due date printed thereon (“Due Date”). Payments must be made at the address\\ndesignated on the invoice or such other place as BCM One may designate. Any amount not paid on or\\nbefore the Due Date, shall be considered to be past due and subject to a late payment charge equal to the\\nlesser of: (a) one and one-half percent (1.5%) per month, compounded, or (b) the maximum amount\\nallowed by law, as applied against the past due amounts. Client must not place any condition or restrictive\\nlegend, such as “Paid in Full,” on any check or instrument used to make a payment. The negotiation of\\nany such check or instrument so inscribed shall not constitute an accord and satisfaction or novation, and\\nClient waives its right to assert any such defense. Client shall be liable for the payment of all fees and\\nexpenses, including reasonable attorney's fees, incurred by BCM One in collecting, or attempting to\\ncollect, any charges owed hereunder. BCM One may, at its discretion, setoff any charges, fees or any\\nother amounts owed to BCM One by Client in the event of a default from any bond or security deposit\\ngiven to BCM One by Client, and BCM One shall notify Client of such setoff.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Confidentiality\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"CONFIDENTIAL INFORMATION\",\n",
" \"text\": \"Commencing on the date Client executes the Agreement, and continuing for a period of three (3) years following the termination or expiration of the Agreement, each party shall\\nprotect as confidential, and shall not disclose to any third party, any Confidential Information received\\nfrom the disclosing party or otherwise discovered by the receiving party during the Term of the\\nAgreement, including, but not limited to, the terms of the MSA, Service Orders, Service Addendums,\\nService Level Agreements, all pricing, network or other designs, or other information that is marked\\nconfidential or bears a marking of like import, or that the disclosing party states (orally or in writing) is\\nconfidential or which under the circumstances surrounding the disclosure, the receiving party knows or\\nshould know is treated as confidential by the disclosing party, as well as any information relating to the\\ndisclosing party's technology, business affairs, and marketing or sales plans (collectively the “Confidential\\nInformation”). The parties shall use Confidential Information only for the purpose of the Agreement. The\\nforegoing restrictions on use and disclosure of Confidential Information do not apply to information that:\\n(a) is in the possession of the receiving party at the time of its disclosure and is not otherwise subject to\\n\\nobligations of confidentiality; (b) is or becomes publicly known through no wrongful act or omission of the\\nreceiving party; (c) is received, without restriction, from a third party free to disclose it without obligation\\nto the disclosing party; (d) is developed, independently, by the receiving party without reference to the\\nConfidential Information, or (e) is required to be disclosed by law, regulation, court or governmental\\norder.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Limitation of Liability\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"LIMITATION OF LIABILITY\",\n",
" \"text\": \"Client shall be bound by the limitation of liability clause contained in the MSA and any applicable Service Orders and Service Addendums.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Indemnification\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"INDEMNIFICATION\",\n",
" \"text\": \"Client shall indemnify and hold harmless BCM One, its officers, directors, employees, agents, parent, affiliates, successors and assigns from and against all claims for damages,\\nliabilities, or expenses, including reasonable attorney's\\nfees related to the modification or sale of Services to Client, or any violation of BCM One's Acceptable\\nUse Policy or Privacy Policy.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Assignment\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"ASSIGNMENT\",\n",
" \"text\": \"Neither party may assign the Agreement or any of its rights thereunder without the prior written consent of the other party, which consent shall not be unreasonably withheld, except that (a) BCM\\nOne may assign its rights and/or obligations under the Agreement, (i) to any parent, affiliate or subsidiary,\\n(ii) pursuant to any merger, acquisition, reorganization, sale or transfer of all or substantially all of its\\nassets, or (iii) for purposes of financing; and (b) Client may assign its rights and/or obligations under the\\nAgreement, (i) to its parent, affiliates or subsidiaries, or (ii) pursuant to any merger, acquisition,\\nreorganization, sale or transfer of all or substantially all of its assets, provided that any assignment by\\nClient pursuant to this exception is subject to the following conditions: (a) the proposed assignee satisfies\\nBCM One's then current credit and deposit standards; (b) Client has fully paid for all Services through the\\ndate of the assignment; and (c) the proposed assignee agrees in writing to be bound by all provisions of\\nthe Agreement. Any assignment in violation of this Section is null and void.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Intellectual Property\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"SERVICE MARKS; TRADEMARKS AND PUBLICITY\",\n",
" \"text\": \"Client shall not use any service mark or trademark of BCM One, without prior written consent. BCM One shall have the right to disclose Client's use of the\\nServices in connection with any advertising, promotion, press release or publication.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Jurisdiction\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"COMPLIANCE WITH LAWS\",\n",
" \"text\": \"Each party agrees to comply with all applicable laws in connection with the Agreement, including all applicable import, re-import, export, and re-export control laws and regulations,\\nincluding the Export Administration Regulations, the International Traffic in Arms Regulations, and\\ncountry-specific economic sanctions programs implemented by the Office of Foreign Assets Control. For\\nclarity, Client is solely responsible for compliance related to the manner in which chooses to use the\\nService, including transfer and processing of content and the provision of content to any users.\\n\",\n",
" \"attributes\": [\n",
" {\n",
" \"name\": \"jurisdiction\",\n",
" \"value\": \"\",\n",
" \"confidence\": 0,\n",
" \"answer\": \"\",\n",
" \"processed_answer\": \"\",\n",
" }\n",
" ],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Jurisdiction\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"GOVERNING LAW; VENUE\",\n",
" \"text\": \"All matters arising out of and relating to the Agreement (including these Standard and Terms and Conditions) shall be governed by and construed and enforced in accordance with\\nthe laws of the State of New Jersey without regard to its choice of law principles. Any action that is or\\nmay be commenced by any party pertaining to the Agreement and the subject matter thereof, shall be\\ncommenced in a federal or state court located in the county of Bergen, the state of New Jersey. The\\n\\nparties hereby consent to the jurisdiction of such court, waiving objection to forum non conveniens and\\npersonal jurisdiction.\\n\",\n",
" \"attributes\": [\n",
" {\n",
" \"name\": \"jurisdiction\",\n",
" \"value\": \"federal or state court located in the county of bergen , the state of new jersey\",\n",
" \"confidence\": 0.14352874975156582,\n",
" \"answer\": \"federal or state court located in the county of bergen , the state of new jersey\",\n",
" \"processed_answer\": \"federal or state court located in the county of bergen , the state of new jersey\",\n",
" }\n",
" ],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Notices\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"NOTICE\",\n",
" \"text\": \"Unless otherwise advised in any Service Addendum, all notices (including Client's notice of disconnect), requests, or other communications (excluding invoices) hereunder shall be in writing and\\neither transmitted via overnight courier, electronic mail, facsimile, hand delivery, certified or registered\\nmail, postage prepaid and return receipt requested to the parties at the following addresses. Notices of\\ndisconnect must be sent to disconnects@BCMOne.com. Notices shall be deemed to have been given when\\nreceived (or delivery refused).\\n\\nTo: BCM One Operations Center\\nBCM One, Inc.\\n521 Fifth Avenue, 14th Floor New York, NY 10175\\nAttn. Contract Administration\\n\\nTo: Client: At the billing address indicated in Client's Agreement.\\nEither party may change its address by providing notice of such address change to the other party in the\\nmanner set forth above.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Notices\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"NOTICE\",\n",
" \"text\": \"Unless otherwise advised in any Service Addendum, all notices (including Client's notice of disconnect), requests, or other communications (excluding invoices) hereunder shall be in writing and\\neither transmitted via overnight courier, electronic mail, facsimile, hand delivery, certified or registered\\nmail, postage prepaid and return receipt requested to the parties at the following addresses. Notices of\\ndisconnect must be sent to disconnects@BCMOne.com. Notices shall be deemed to have been given when\\nreceived (or delivery refused).\\n\\nTo: BCM One Operations Center\\nBCM One, Inc.\\n521 Fifth Avenue, 14th Floor New York, NY 10175\\nAttn. Contract Administration\\n\\nTo: Client: At the billing address indicated in Client's Agreement.\\nEither party may change its address by providing notice of such address change to the other party in the\\nmanner set forth above.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Waiver\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"NO WAIVER\",\n",
" \"text\": \"The failure to enforce any provision or term of the MSA, Service Order, Service Addendum, Service Level Agreement or any other document that becomes part of the Agreement including these\\nStandard Terms and Conditions, shall not be construed as a future or continuing waiver of any provision\\nor term of any of the above.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Severability\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"NO WAIVER\",\n",
" \"text\": \"The failure to enforce any provision or term of the MSA, Service Order, Service Addendum, Service Level Agreement or any other document that becomes part of the Agreement including these\\nStandard Terms and Conditions, shall not be construed as a future or continuing waiver of any provision\\nor term of any of the above.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Severability\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"SEVERABILITY\",\n",
" \"text\": \"If any provision under the MSA, Service Order, Service Addendum, Service Level Agreement or any other document that becomes part of the Agreement including these Standard Terms\\nand Conditions are declared or held to be invalid, illegal or unenforceable, all of the foregoing shall be\\nrevised only to the extent necessary to make such provision(s) legal and enforceable, or if impossible, the\\nunaffected portions of either or both shall remain in full force and effect, provided that the modification is\\nconsistent with the original intent.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Severability\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"SEVERABILITY\",\n",
" \"text\": \"If any provision under the MSA, Service Order, Service Addendum, Service Level Agreement or any other document that becomes part of the Agreement including these Standard Terms\\nand Conditions are declared or held to be invalid, illegal or unenforceable, all of the foregoing shall be\\nrevised only to the extent necessary to make such provision(s) legal and enforceable, or if impossible, the\\nunaffected portions of either or both shall remain in full force and effect, provided that the modification is\\nconsistent with the original intent.\\n\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" {\n",
" \"name\": \"Entire Agreement\",\n",
" \"mapping\": \"True\",\n",
" \"title\": \"ENTIRE AGREEMENT\",\n",
" \"text\": \"These Standard Terms and Conditions, the MSA, Service Order, Service\",\n",
" \"attributes\": [],\n",
" \"obligations\": \"None\",\n",
" },\n",
" ],\n",
"}\n",
"\n",
"inp = [inp] * 2\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(29, 16)"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"colnames = [\n",
" 'file_name',\n",
" 'clause_name',\n",
" 'party1',\n",
" 'clause_name',\n",
" 'party1_address',\n",
" 'clause_name',\n",
" 'party2',\n",
" 'clause_name',\n",
" 'party2_address',\n",
" 'clause_name',\n",
" 'effective_date',\n",
" 'clause_name',\n",
" 'subject',\n",
" 'clause_name',\n",
" 'expiry_date',\n",
" 'clause_name',\n",
" 'auto_renewal',\n",
" 'clause_name',\n",
" 'renewal_period',\n",
" 'clause_name',\n",
" 'jurisdiction',\n",
" 'clause_name',\n",
" 'non_compete_present',\n",
" 'clause_name',\n",
" 'signatory1',\n",
" 'clause_name',\n",
" 'signatory2',\n",
" 'clause_name',\n",
" 'signed_date',\n",
"]\n",
"colnames_set = set(colnames)\n",
"len(colnames), len(colnames_set)\n"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'auto_renewal',\n",
" 'cure_period',\n",
" 'effective_date',\n",
" 'jurisdiction',\n",
" 'notice_period',\n",
" 'party1',\n",
" 'party1_address',\n",
" 'party2',\n",
" 'party2_address',\n",
" 'renewal_period',\n",
" 'subject',\n",
" 'who_can_terminate'}"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clsses = set()\n",
"for filedct in inp:\n",
" for cl in filedct['clauses']:\n",
" for attr in cl['attributes']:\n",
" clsses.add(attr['name'])\n",
"clsses\n"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'clause_name',\n",
" 'cure_period',\n",
" 'expiry_date',\n",
" 'file_name',\n",
" 'non_compete_present',\n",
" 'notice_period',\n",
" 'signatory1',\n",
" 'signatory2',\n",
" 'signed_date',\n",
" 'who_can_terminate'}"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clsses.symmetric_difference(colnames_set)\n"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'cure_period', 'notice_period', 'who_can_terminate'}"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clsses - colnames_set\n"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"discarding attribute \"notice_period\" of clause \"termination\"\n",
"discarding attribute \"cure_period\" of clause \"termination\"\n",
"discarding attribute \"who_can_terminate\" of clause \"termination\"\n",
"discarding attribute \"notice_period\" of clause \"termination\"\n",
"discarding attribute \"cure_period\" of clause \"termination\"\n",
"discarding attribute \"who_can_terminate\" of clause \"termination\"\n"
]
}
],
"source": [
"lst = []\n",
"for dct in inp:\n",
" attrs = {}\n",
" for cl in dct['clauses']:\n",
" cl_name = cl['name']\n",
" for metafield in cl['attributes']:\n",
" name = metafield['name']\n",
" if name in colnames_set:\n",
" val = metafield['value']\n",
" if (name not in attrs) or val:\n",
" attrs[name] = metafield['value'] \n",
" attrs[f'{name}_clause'] = cl_name\n",
" else:\n",
" print(f'discarding attribute \"{name}\" of clause \"{cl_name}\"')\n",
" lst.append(attrs)\n"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>party1</th>\n",
" <th>party1_clause</th>\n",
" <th>party1_address</th>\n",
" <th>party1_address_clause</th>\n",
" <th>party2</th>\n",
" <th>party2_clause</th>\n",
" <th>party2_address</th>\n",
" <th>party2_address_clause</th>\n",
" <th>effective_date</th>\n",
" <th>effective_date_clause</th>\n",
" <th>subject</th>\n",
" <th>subject_clause</th>\n",
" <th>auto_renewal</th>\n",
" <th>auto_renewal_clause</th>\n",
" <th>renewal_period</th>\n",
" <th>renewal_period_clause</th>\n",
" <th>jurisdiction</th>\n",
" <th>jurisdiction_clause</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td>None</td>\n",
" <td>Recital</td>\n",
" <td>standard terms and conditions</td>\n",
" <td>Recital</td>\n",
" <td>False</td>\n",
" <td>termination</td>\n",
" <td></td>\n",
" <td>termination</td>\n",
" <td>federal or state court located in the county o...</td>\n",
" <td>Jurisdiction</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td></td>\n",
" <td>Recital</td>\n",
" <td>None</td>\n",
" <td>Recital</td>\n",
" <td>standard terms and conditions</td>\n",
" <td>Recital</td>\n",
" <td>False</td>\n",
" <td>termination</td>\n",
" <td></td>\n",
" <td>termination</td>\n",
" <td>federal or state court located in the county o...</td>\n",
" <td>Jurisdiction</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" party1 party1_clause party1_address party1_address_clause party2 \\\n",
"0 Recital Recital \n",
"1 Recital Recital \n",
"\n",
" party2_clause party2_address party2_address_clause effective_date \\\n",
"0 Recital Recital None \n",
"1 Recital Recital None \n",
"\n",
" effective_date_clause subject subject_clause \\\n",
"0 Recital standard terms and conditions Recital \n",
"1 Recital standard terms and conditions Recital \n",
"\n",
" auto_renewal auto_renewal_clause renewal_period renewal_period_clause \\\n",
"0 False termination termination \n",
"1 False termination termination \n",
"\n",
" jurisdiction jurisdiction_clause \n",
"0 federal or state court located in the county o... Jurisdiction \n",
"1 federal or state court located in the county o... Jurisdiction "
]
},
"execution_count": 100,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.DataFrame.from_records(lst)\n",
"df\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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.6.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment