# Smart Contract Generation Assisted by AI-Based Word Segmentation
## 1 Introduction  
In the past decade, the blockchain smart contract has transcended beyond its initial application to the finance sector. It provides automatic, immutable, traceable, and decentralized solutions to various real-world applications, including healthcare data sharing [1], supply chain management [2], Internet of Things (IoT) services [3], and energy management [4]. Despite its prevalence, most existing blockchain smart contracts are directly represented in programming languages of different levels of abstraction [5]. Thus, contracting parties without knowledge of smart contract languages may struggle to read and understand the smart contracts. Furthermore, the complexity of the contractual content may not be fully understood by the programmers implementing the smart contract, leading to extra negotiation and revision about involved entities in the smart contract and decreasing the smart contract development efficiency. Moreover, considering the drafting of legal contracts in the real world, participants from heterogeneous contexts (e.g., stakeholders, lawyers, and external service providers)and speaking different languages are involved, raising the concerns of semantic consistency and common consent. 1. Semantic consistency: because contracting parties are in different contexts, they may perceive the terms in a contract clause differently, i.e., the sense of ambiguity in contract content. For example, the word \"refrigerator\" can mean either a household appliance for preserving foods at low temperature, or customized cooling devices or spaces to store specific objects, such as biological samples. 2. Common consent: because different languages contain heterogeneous grammar rules and unique grammar features, the translation of a contract clause between two languages cannot always preserve its original meanings completely. The information lost during translation and the sense of ambiguity of contract terms can lead to disputes regarding the future execution of a contract. As the preliminary work of this paper, _Intelligible Description Language Contract_ (IDLC) was proposed as a new smart contract paradigm, using the formal language representation _Machine Natural Language_ (MNL) to guarantee semantic consistency and common consent [6; 7]. Nevertheless, IDLC requires manual input of the smart contracts written in MNL sentences: the terms in each sentences are selected one-by-one from a common dictionary (CoDiC). However, for contracts written in natural language without explicit boundaries between words, such as Chinese, IDLC requires editors to first split the sentence into a sequence of words. The well-segmented words are then converted to terms predefined in CoDiC, and manually input to generate an MNL sentence. IDLC demands considerable manual effort and lacks efficiency when drafting complex contracts. Furthermore, manual contract generation is error-prone when one is fatigued or distracted. In this paper, we explore an alternative to IDLC's manual contract generation. We consider the contract generation problem as to how to quickly and automatically construct a sentence (i.e., a contract obligation) that requires minimal manual adjustment by contract editors on word meaning and sentence grammar. Grounded on MNL and IDLC, the overall methodology is to automate the process of converting contract clauses written in arbitrary natural languages into MNL sentences, which are interpretable by smart contract code scripts and understandable by a human. Particularly, a critical issue is the correct identification of terms and their senses which are the building blocks of MNL sentences. Utilizing artificial intelligence (AI), a novel technique called _Separation Inference_ (SpIn) is introduced to perform automatic word segmentation (WS) for natural language contracts, which is a core supporting tool in AIASCG that facilitates efficient and effortless smart contract generation. The main contributions of this paper are as follows:  
1.