A method and device for automatically typesetting articles
Through automated technical means, including lexical analysis, rule matching algorithms and natural language processing technology, the problem of low manual inspection and layout efficiency in the existing technology is solved, and efficient and accurate article format inspection and layout are achieved.
Patent Information
- Application Number
- CN202411318195.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-09-20
AI Technical Summary
The prior art relies on manual labor in the process of article format checking and typing, resulting in wasted time and easy to miss format problems, resulting in format errors.
It provides an automatic layout method, which automatically checks and typesets the articles through technical means such as lexical analysis, syntax analysis, rule matching algorithm, spelling checking algorithm, grammatical analysis algorithm, sentence boundary detection algorithm, keyword extraction algorithm, natural language processing technology, layout algorithm and aesthetic rule algorithm.
Automatic article format checking and typography is realized, the layout efficiency is improved, manual errors are reduced, and the accuracy and aesthetics of article formats are ensured.
Smart Images

Figure CN119337820B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of article typesetting, and more specifically, to an automatic article typesetting method and device. Background Art
[0002] At present, there is a great demand for article format checking and typesetting. When performing the task of article format checking and typesetting, it is generally done manually, which is very time-consuming and it is easy to miss format problems, resulting in technical problems with format errors. Summary of the invention
[0003] In view of the deficiencies in the prior art, the present invention provides an automatic typesetting method and device for articles.
[0004] According to one aspect of the present invention, there is provided a method for automatically typesetting an article, comprising:
[0005] Perform lexical analysis and syntactic analysis on the articles to be typeset, and convert the text content of the articles to be typeset into structured data that can be understood by computers;
[0006] Identify and standardize the non-compliant content in structured data through a preset rule matching algorithm to obtain the standardized text of the content;
[0007] Using a spelling check algorithm and a syntax analysis algorithm to check the article format of the content normalized text, and obtaining a first format normalized text;
[0008] Using a sentence boundary detection algorithm to segment and concatenate the first format normalized text to obtain a second format normalized text;
[0009] A keyword extraction algorithm is used to extract keywords and sentence segments from the second format normalized text to obtain keywords of the article to be typeset;
[0010] Using natural language processing technology and paragraph length statistical algorithm to perform paragraph adjustment on the second format normalized text to obtain a third format normalized text;
[0011] The third format normalized text is formatted and beautified according to keywords through typesetting algorithms and aesthetic rule algorithms to determine the initial typesetting article;
[0012] Through the word vector model and topic model, semantic analysis is performed on the initial typeset article to identify the subject and emotional tendency of the article to be typeset, and personalized adjustments are made to the layout of the initial typeset article to determine the final typeset article.
[0013] Optionally, a pre-set rule matching algorithm is used to identify and standardize formats that do not conform to the standard in the structured data, and obtain content normalized text, including:
[0014] A multi-level rule combination is used to perform multi-level matching on structured data from character strings to grammatical structures to obtain a first content normalized text;
[0015] Using a context-sensitive matching algorithm to perform rule matching on the context content of the first content normalized text to obtain a second content normalized text;
[0016] Using a fuzzy matching and correction mechanism to perform approximate text matching on the second content normalized text within a preset error, to obtain the third content normalized text;
[0017] A dynamic rule algorithm is used to match and update the third content normalized text according to the feedback data to obtain the content normalized text.
[0018] Optionally, performing article format check on the content normalized text using a spelling check algorithm and a syntax analysis algorithm to obtain a first format normalized text includes:
[0019] Using a spell checking algorithm to perform spell checking and correction on the content normalized text, to obtain a spelling normalized text;
[0020] A grammatical analysis algorithm is used to check and correct the grammatical structure of the spelling normalized text to obtain a first format normalized text.
[0021] Optionally, it further includes: optimizing a sentence boundary detection algorithm using reinforcement learning, wherein the optimization process is as follows:
[0022] Q(s,a)←Q(s,a)+α[r+γa′maxQ(s′,a′)-Q(s,a)]
[0023] Where Q(s,a) is the value Q of taking action a in the current state s, S is the state space, a is the vector in the action space A, r is the immediate reward obtained after performing action a in state s, α is the learning rate, γ is the discount factor, and a′maxQ(s′,a′) represents the maximum Q value of all possible actions a′ in the new state s′.
[0024] Optionally, a keyword extraction algorithm is used to extract keywords and sentence segments from the second format normalized text to obtain keywords of the article to be typeset, including:
[0025] The TF-IDF algorithm is used to calculate the frequency and inverse document frequency of terms in the second format normalized text to evaluate the first importance of the terms;
[0026] The TextRank algorithm is used to evaluate the second importance of words using the relationship between nodes in the graph model of the second format planning text;
[0027] According to the first importance and the second importance of the words in the second normalized text, the keywords of the article to be typeset are determined, wherein:
[0028] The contextual weight factor of the TF-IDF algorithm is:
[0029] TFIDF(w,d)=TF(w,d)·C(w,d) / max(TF(w,d)))·log(∣D∣ / ∣d:w∈d∣+1)
[0030] In the formula, w represents a specific word or term; d represents a single document; TF(w,d) represents the number of times word w appears in document d; C(w,d) represents the specific count or weight for word w in document d; max(TF(w,d)) represents the maximum frequency of all words in document d; |D| represents the total number of documents in document set D.
[0031] Optionally, using natural language processing technology and a paragraph length statistical algorithm to perform paragraph adjustment on the second format normalized text to obtain a third format normalized text includes:
[0032] Calculate the readability score of each paragraph in the second format normalized text using natural language processing technology;
[0033] For paragraphs in the second format normalized text whose readability score is lower than a preset threshold, the structure and vocabulary are simplified to obtain a third format normalized text.
[0034] Optionally, the third format normalized text is formatted and beautified according to keywords by using a typesetting algorithm and an aesthetic rule algorithm to determine an initial typeset article, including:
[0035] Using a typesetting algorithm, positions and styles of words, paragraphs and page layout elements in the third format normalized text are adjusted to obtain a first typeset article;
[0036] An aesthetic rule algorithm is used to optimize the font, line spacing, text alignment, and image insertion in the first typeset article to obtain the initial typeset article.
[0037] Optionally, the expression of the intelligent typesetting algorithm is:
[0038] C=α·(L d ) 2 +β·S
[0039] In the formula, C represents the paragraph adjustment cost, L d Represents the difference in paragraph length, Ld = |L1-L2|, where L1 and L2 are the lengths of the two paragraphs, S represents the semantic similarity of the paragraphs, and α and β are the weight coefficients for adjusting the cost.
[0040] Optionally, the expression of the topic model is:
[0041]
[0042] In the formula, T represents the title optimization target, I represents information gain, F represents format consistency, and γ and δ are weight coefficients.
[0043] According to another aspect of the present invention, there is provided an automatic typesetting device for articles, comprising:
[0044] The analysis module is used to perform lexical analysis and syntactic analysis on the article to be typeset, and convert the text content of the article to be typeset into structured data that can be understood by a computer;
[0045] A first acquisition module is used to identify and standardize the non-compliant content in the structured data through a preset rule matching algorithm to obtain a content normalized text;
[0046] A second acquisition module is used to perform article format check on the content normalized text using a spelling check algorithm and a grammar analysis algorithm to obtain a first format normalized text;
[0047] A third acquisition module is used to segment and divide the first format normalized text into two parts by using a sentence boundary detection algorithm to acquire a second format normalized text.
[0048] A fourth acquisition module is used to extract keywords and sentence segments from the second format normalized text using a keyword extraction algorithm to obtain keywords of the article to be typeset;
[0049] A fifth acquisition module is used to perform paragraph adjustment on the second format normalized text by using natural language processing technology and paragraph length statistical algorithm to acquire a third format normalized text;
[0050] A first determination module is used to beautify the format of the third format normalized text according to keywords through a typesetting algorithm and an aesthetic rule algorithm to determine an initial typeset article;
[0051] The second determination module is used to perform semantic analysis on the initial typeset article through a word vector model and a topic model, identify the subject and sentiment tendency of the article to be typeset, make personalized adjustments to the typeset of the initial typeset article, and determine the final typeset article.
[0052] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the method described in any one of the above aspects of the present invention.
[0053] According to another aspect of the present invention, an electronic device is provided, comprising: a processor; a memory for storing instructions executable by the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the method described in any one of the above aspects of the present invention.
[0054] Therefore, through the technical solution proposed by the present invention, when checking the format of an article and typeset the article, the article format can be automatically checked and typeset according to the format specifications, and modification suggestions and intelligent modifications can be given, thereby improving the typesetting efficiency and greatly improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] A more complete understanding of exemplary embodiments of the present invention may be obtained by referring to the following drawings:
[0056] Figure 1 It is a flowchart of an automatic typesetting method for articles provided by an exemplary embodiment of the present invention;
[0057] Figure 2 It is a schematic diagram of the structure of an automatic typesetting device for articles provided by an exemplary embodiment of the present invention;
[0058] Figure 3 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0059] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.
[0060] It should be noted that the relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
[0061] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present invention are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.
[0062] It should also be understood that, in the embodiments of the present invention, “plurality” may refer to two or more than two, and “at least one” may refer to one, two or more than two.
[0063] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0064] In addition, the term "and / or" in the present invention is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects before and after are in an "or" relationship.
[0065] It should also be understood that the description of the various embodiments of the present invention focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0066] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0067] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0068] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0069] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0070] Embodiments of the present invention can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0071] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0072] Exemplary Methods
[0073] Figure 1 FIG. 1 is a flow chart of an automatic typesetting method for articles provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices, such as Figure 1 As shown, the automatic typesetting method 100 of an article includes the following steps:
[0074] Step 101, performing lexical analysis and syntactic analysis on the article to be typeset, and converting the text content of the article to be typeset into structured data that can be understood by a computer;
[0075] Step 102, identifying and standardizing the content that does not conform to the standard in the structured data through a preset rule matching algorithm, and obtaining a content standardized text;
[0076] Step 103, using a spelling check algorithm and a syntax analysis algorithm to perform an article format check on the content normalized text to obtain a first format normalized text;
[0077] Step 104, using a sentence boundary detection algorithm to segment and concatenate the first format normalized text to obtain a second format normalized text;
[0078] Step 105, using a keyword extraction algorithm to extract keywords and sentence segments from the second format normalized text to obtain keywords of the article to be typeset;
[0079] Step 106, using natural language processing technology and paragraph length statistical algorithm to perform paragraph adjustment on the second format normalized text to obtain a third format normalized text;
[0080] Step 107, formatting the third format normalized text according to the keywords using a typesetting algorithm and an aesthetic rule algorithm to determine an initial typeset article;
[0081] Step 108, semantic analysis is performed on the initial typeset article through a word vector model and a topic model, the subject and sentiment tendency of the article to be typeset are identified, and the typeset of the initial typeset article is adjusted in a personalized manner to determine the final typeset article.
[0082] Specifically, the present invention extracts text content through NLP technology, and then pre-processes the content. After processing, the pre-trained language model is used to check the article format. After the article format is checked, a text generation model can be used to generate a typesetting style that meets the specifications and intelligently typeset the article.
[0083] Implementation steps:
[0084] 1. First, you need to use NLP (natural language processing) technology to perform lexical analysis and syntactic analysis on the input article, convert the text into structured data that can be understood by the computer, and identify elements such as sentences, paragraphs, and titles. NLP (natural language processing) technology performs lexical analysis and syntactic analysis on the input article, which brings many benefits. It can automate text processing, realize automatic understanding and processing; improve the accuracy and depth of semantic understanding; realize information extraction and knowledge extraction; support language generation and training language models; improve search engine effects and personalized recommendations; perform sentiment analysis and public opinion monitoring; and improve the convenience of human-computer interaction. In short, the application of NLP technology in lexical analysis and syntactic analysis has brought convenience and improvement to the fields of text understanding, information extraction, intelligent recommendation, sentiment analysis, etc.
[0085] 2. After extracting the text content of the article, the content needs to be formatted and standardized. For this purpose, a set of format specifications is formulated. Through rule matching algorithms or regular expressions, the formats that do not conform to the specifications in the article, such as missing punctuation, incorrect title formats, inconsistent paragraph spacing, etc., are identified and marked. The rule matching algorithm brings many benefits when performing format normalization. By defining a series of rules and patterns, the algorithm can accurately match and convert the input text to achieve standardization and uniformity of the format. It can quickly identify and process text with specific patterns and improve processing efficiency. The rule matching algorithm is also flexible and can design and adjust custom rules according to needs. In addition, the rule matching algorithm is easy to understand and implement, and does not require a large amount of training data and a complex model building process, making its application simple and scalable. In summary, the rule matching algorithm can efficiently and accurately convert text formats in format normalization, providing a simple and reliable method.
[0086] (Innovative algorithm 1: Rule matching algorithm: Deterministic finite automaton (DFA), DFA is a state machine that can perform pattern matching on input strings. It can start from the initial state q0, read the characters a∈Σ of the input string in sequence, transfer to the next state according to the transition function δ, and finally determine whether it is in the acceptance state set F. Including;
[0087] Multi-level rule combination: The innovative rule matching algorithm can combine multiple levels of rules, from simple string matching to complex grammatical structures.
[0088] Context-sensitive matching: The algorithm can consider the contextual information of the text and adjust the matching rules according to the previous and next text content to improve the accuracy and scope of the match.
[0089] Fuzzy matching and correction: Introducing fuzzy matching and correction mechanisms that allow finding approximate matches within a certain margin of error, thus better handling spelling errors or formatting differences.
[0090] Dynamic rule update: Dynamically update the matching rule set based on data feedback from actual applications to adapt to new text patterns or changes in requirements, maintaining the practicality and adaptability of the algorithm.
[0091] Consider the following common formatting issues and regular expression examples:
[0092] Check the mailbox format: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[AZ|az]{2,}\b;
[0093] Check the phone number format: ^(?:\+86)?1[3-9]\d{9}$;
[0094] Check the URL format: \b(https?: / / [^\s / $.?#].[^\s]*)\b;
[0095] Check for repeated spaces: \s{2,};
[0096] Check for special characters: [!@#$%^&*(),.? ":{}|<>];
[0097] Check for capitalization of first letter: (?<!^)(?:^|\s)([az]).
[0098] 3. After processing the above two steps, you can use pre-trained language models, such as BERT or GPT-3.5, to check the format of the article content, and use spelling check algorithms and grammatical analysis algorithms to check the spelling and grammar of the article, identify and correct spelling errors, grammatical errors and incoherent expressions. When checking the format of the article content, spelling check algorithms and grammatical analysis algorithms have many benefits. Spelling check algorithms can detect and correct spelling errors in input text, helping to improve the accuracy and professionalism of the article. It can capture common spelling errors and provide correction suggestions to help users avoid embarrassment and misleading. On the other hand, grammatical analysis algorithms can check the grammatical structure and grammatical errors of the text, helping to improve the fluency and readability of the article. By analyzing sentence structure, part of speech and grammatical rules, grammatical analysis algorithms can discover and correct grammatical problems, such as subject-verb inconsistency and verb tense errors. The combined use of these two algorithms can effectively improve the quality and accuracy of the article, making it more in line with language standards and professional requirements. In short, spelling check algorithms and grammatical analysis algorithms play an important role in improving spelling errors and correcting grammatical problems in article content format checking.
[0099] The present invention uses NLTK or Spacy library to analyze the part of speech and syntactic relationship of each word, and construct a syntactic tree and a dependency graph. These analyses are helpful for grammatical checking and semantic analysis in subsequent steps. Using NLTK or SpaCy library can creatively solve specific text processing problems by combining text generation and custom feature extraction methods. The following is a specific idea:
[0100] Custom feature extraction combined with generative model:
[0101] Text preprocessing:
[0102] Use NLTK or SpaCy for basic text cleaning and preprocessing, such as stop word removal, lemmatization, and tokenization.
[0103] Custom feature extraction:
[0104] (1) Domain-specific features: Design unique feature extraction methods based on specific tasks (such as sentiment analysis or topic classification). For example, calculate the frequency of occurrence of sentiment words in the text, sentiment intensity, sentence structure characteristics, etc.
[0105] (2) Contextual embedding: Use SpaCy’s word embedding function or combine it with contextual embedding such as BERT to generate richer feature representations for text.
[0106] Text Generation:
[0107] (1) Generative model: Use pre-trained text generation models (such as the GPT series) to generate text similar to the original text, or generate additional training samples to enhance the diversity of the dataset.
[0108] (2) Data enhancement: Generate new text samples through methods such as synonym replacement and word order change to increase the generalization ability of the model.
[0109] Model training:
[0110] (1) The extracted features and generated text samples are used to train machine learning models or deep learning models (such as LSTM, Transformer, etc.) and optimized with appropriate loss functions.
[0111] (2) Consider using multi-task learning to allow the model to learn multiple related tasks simultaneously to improve performance.
[0112] 4. After checking the format of the article, the article is intelligently segmented and segmented by identifying the end punctuation of sentences (such as periods, question marks, exclamation marks) and the end symbols of paragraphs (such as line breaks, blank lines) to ensure that the format of sentences and paragraphs is accurate. Sentence boundary detection algorithms can be used, which have many benefits in text processing. It can accurately determine the start and end positions of sentences, which helps to process text at the sentence and sentence levels. Sentence boundary detection algorithms can help divide long paragraphs or continuous texts into independent sentence units, making text processing more accurate and controllable. This algorithm can be applied to various natural language processing tasks, such as machine translation, text summarization, sentiment analysis, etc., to provide more accurate input data. By correctly dividing sentence boundaries, in-depth analysis of sentence structure, semantics, and context can be further achieved, thereby improving the quality of text understanding and processing. In short, sentence boundary detection algorithms play a key role in text processing, helping to accurately define sentence boundaries and provide a basis for subsequent language processing tasks.
[0113] Optimizing sentence boundary detection using reinforcement learning
[0114] Algorithmic idea: Consider sentence boundary detection as a decision-making process and use reinforcement learning model to dynamically adjust the detection strategy.
[0115] Algorithm formula: Assume state space S, action space A, and use Q-learning to update the strategy:
[0116] Q(s,a)←Q(s,a)+α[r+γa′max Q(s′,a′)-Q(s,a)]
[0117] Among them, r is the reward of the current action (for example, the number of sentence boundaries accurately detected), α is the learning rate, and γ is the discount factor used to weigh the importance of future rewards. The use of single quotes is to distinguish the current state from the next state, indicating that this state is transferred as the action is executed.
[0118] 5. Through the TF-IDF algorithm and the TextRank algorithm, keywords and phrases are extracted from the article using the keyword extraction algorithm, so as to better handle the display of titles, abstracts and key contents in the intelligent typesetting process. Both the TF-IDF algorithm and the TextRank algorithm are commonly used algorithms for extracting keywords and phrases. The TF-IDF algorithm evaluates the importance of words by calculating the frequency and inverse document frequency of the terms, which can highlight the keywords that appear frequently in the document but are relatively rare in the entire corpus. This enables the TF-IDF algorithm to provide more effective information retrieval and text classification. On the other hand, the TextRank algorithm uses the relationship between nodes in the graph model to evaluate the importance of words, and analyzes the text as an undirected weighted graph. It determines keywords by iteratively calculating the mutual influence between nodes, and can capture the importance of words in the context. This enables the TextRank algorithm to provide more comprehensive and context-related keywords and phrases. In summary, the TF-IDF algorithm and the TextRank algorithm have their own advantages in extracting keywords and phrases. The former can highlight important words in the document, and the latter can consider the importance of words in the context. The combination of the two can provide more comprehensive and accurate keyword and phrase extraction results.
[0119] Context-aware TF-ID: Algorithm idea: Consider the context information of the word and adjust the TF-IDF calculation so that the same word has different importance in different contexts.
[0120] Algorithm formula: The context weight factor C(w,d) can be introduced:
[0121] TFIDF(w,d)=TF(w,d)·C(w,d) / max(TF(w,d)))·log(∣D∣ / ∣d:w∈d∣+1)
[0122] Among them, C(w,d) is dynamically adjusted by analyzing the relative position and semantic relationship of the words in the context.
[0123] w represents a specific word (or term). Purpose: Used to calculate the importance of the word in the document.
[0124] d represents a single document. Purpose: In TF-IDF calculation, it refers to the object of analysis, usually text data.
[0125] TF(w,d) Term Frequency, which indicates the number of times word w appears in document d. Calculation: The common calculation method is TF(w,d) = the number of times word w appears in document d / the total number of words in document d, which is used to measure the relative importance of word w in the document.
[0126] C(w,d): Definition: The specific count or weight for word w in document d.
[0127] 1. Purpose: It can be some variation of word frequency, such as weighting of certain important words. The specific definition depends on the application scenario.
[0128] max(TF(w,d)): Definition: The maximum term frequency of all words in document d.
[0129] 2. Purpose: Used to normalize word frequency so that the frequencies of different words can be compared to ensure that the TF value is not affected by certain high-frequency words in the document.
[0130] |D|: Definition: The total number of documents in document set D. Purpose: Used to calculate the inverse document
[0131] 6. Through natural language processing technology and paragraph length statistics algorithm, the paragraphs are adjusted according to paragraph length statistics and natural language processing technology to make the paragraph length appropriate and improve the readability of the article.
[0132] Language style and readability adjustments
[0133] Algorithm idea: Use natural language processing technology to evaluate the readability of the paragraph (such as Flesch-Kincaid, Gunning Fog Index), and adjust sentence structure and vocabulary as needed. Steps:
[0134] aCalculate the readability score of a paragraph.
[0135] b. For paragraphs with scores below a certain threshold, simplify the structure and vocabulary.
[0136] 7. Use typesetting algorithms and aesthetic rule algorithms to beautify the format of articles, including adjusting fonts, line spacing, paragraph spacing, alignment, etc., to improve the layout effect of articles. Typesetting algorithms and aesthetic rule algorithms can help beautify the format of articles and improve the readability and visual effect of articles. Typesetting algorithms adjust the position and style of elements such as text, paragraphs and page layout to make the article present a more neat and clear typesetting effect, so that readers can read and understand the content of the article more easily. The aesthetic rule algorithm optimizes fonts, line spacing, text alignment, image insertion and other aspects based on aesthetic principles and design specifications to achieve a more beautiful and comfortable visual effect. The advantage of these two algorithms is that they can beautify articles from different angles and improve the texture and professionalism of articles. Typesetting algorithms can adjust the structure of the page and the layout of the text to make the article visually neater and easier to read, helping readers quickly obtain information. The aesthetic rule algorithm focuses on details, optimizes font style, line spacing, color matching, etc., making the article more beautiful and attractive, and enhancing the reader's reading experience.
[0137] (Innovative algorithm 1: Intelligent typesetting algorithm design
[0138] Design intelligent typesetting algorithms based on paragraph length, content relevance, and semantic coherence. For example, paragraph adjustment is done through the following formula:
[0139] C=α·(L d ) 2 +β·S
[0140] Where: C represents the paragraph adjustment cost, L d represents the difference in paragraph length, Ld = |L1-L2|, where L1 and L2 are the lengths of the two paragraphs, S represents the semantic similarity of the paragraphs, S can be calculated by some similarity measure (such as cosine similarity), and α and β are weight coefficients for adjusting the cost.
[0141] Among them, the paragraph length difference measures the deviation of the current paragraph length from the average length, and the semantic similarity evaluates the semantic relevance between the current paragraph and the context. The optimization process minimizes the overall cost by dynamically adjusting the order of paragraphs).
[0142] 8. Perform semantic analysis through word vector models and topic models to identify the themes and sentiments in the article so that the layout can be personalized according to different topics.
[0143] Innovative algorithm 1: title optimization and style unification
[0144] For article titles, we design optimization algorithms to ensure that the amount of information and format of the title conform to the preset style and importance. For example, we consider information gain and format consistency:
[0145] T=γ·I+δ·F
[0146] Where: T represents the title optimization target, I represents information gain, F represents format consistency, γ and δ are weight coefficients used to adjust the contribution of information gain and format consistency in the optimization target. Information gain I can be calculated by a specific measurement method (such as information entropy), and format consistency F can be evaluated by consistency score or other standardized indicators.
[0147] Information gain measures the amount of unique information provided by the title, and format consistency evaluates how well the title matches the style of the article. The algorithm adjusts the title content and format according to the optimization goal to improve the overall readability and attractiveness of the article)
[0148] 9. Collect user feedback on typesetting effects, conduct user behavior analysis and A / B testing, and continuously optimize algorithms and models to achieve intelligent typesetting effects that better meet user needs.
[0149] Therefore, through the technical solution proposed by the present invention, when checking the format of an article and typeset the article, the article format can be automatically checked and typeset according to the format specifications, and modification suggestions and intelligent modifications can be given, thereby improving the typesetting efficiency and greatly improving work efficiency.
[0150] Exemplary Devices
[0151] Figure 2 FIG. 1 is a schematic diagram of the structure of an automatic typesetting device for articles provided by an exemplary embodiment of the present invention. Figure 2 As shown, the device 200 includes:
[0152] The analysis module 210 is used to perform lexical analysis and syntactic analysis on the article to be typeset, and convert the text content of the article to be typeset into structured data that can be understood by a computer;
[0153] The first acquisition module 220 is used to identify and standardize the non-compliant content in the structured data through a preset rule matching algorithm to obtain a content standardized text;
[0154] The second acquisition module 230 is used to perform article format check on the content normalized text using a spelling check algorithm and a syntax analysis algorithm to obtain a first format normalized text;
[0155] The third acquisition module 240 is used to segment and divide the first format normalized text into two parts by using a sentence boundary detection algorithm to acquire a second format normalized text.
[0156] A fourth acquisition module 250 is used to extract keywords and sentence segments from the second format normalized text using a keyword extraction algorithm to obtain keywords of the article to be typeset;
[0157] A fifth acquisition module 260 is used to perform paragraph adjustment on the second format normalized text by using natural language processing technology and a paragraph length statistical algorithm to acquire a third format normalized text;
[0158] The first determination module 270 is used to beautify the third format normalized text according to keywords by using a typesetting algorithm and an aesthetic rule algorithm to determine an initial typeset article;
[0159] The second determination module 280 is used to perform semantic analysis on the initial typeset article through a word vector model and a topic model, identify the subject and sentiment tendency of the article to be typeset, make personalized adjustments to the typeset of the initial typeset article, and determine the final typeset article.
[0160] Optionally, the first acquisition module 220 includes:
[0161] A multi-level rule combination is used to perform multi-level matching on structured data from character strings to grammatical structures to obtain a first content normalized text;
[0162] Using a context-sensitive matching algorithm to perform rule matching on the context content of the first content normalized text to obtain a second content normalized text;
[0163] Using a fuzzy matching and correction mechanism to perform approximate text matching on the second content normalized text within a preset error, to obtain the third content normalized text;
[0164] A dynamic rule algorithm is used to match and update the third content normalized text according to the feedback data to obtain the content normalized text.
[0165] Optionally, the second acquisition module 230 includes:
[0166] Using a spell checking algorithm to perform spell checking and correction on the content normalized text, to obtain a spelling normalized text;
[0167] A grammatical analysis algorithm is used to check and correct the grammatical structure of the spelling normalized text to obtain a first format normalized text.
[0168] Optionally, it further includes: optimizing a sentence boundary detection algorithm using reinforcement learning, wherein the optimization process is as follows:
[0169] Q(s,a)←Q(s,a)+α[r+γa′maxQ(s′,a′)-Q(s,a)]
[0170] Where Q(s,a) is the value Q of taking action a in the current state s, S is the state space, a is the vector in the action space A, r is the immediate reward obtained after performing action a in state s, α is the learning rate, γ is the discount factor, and a′maxQ(s′,a′) represents the maximum Q value of all possible actions a′ in the new state s′.
[0171] Optionally, the fourth acquisition module 250 includes:
[0172] The TF-IDF algorithm is used to calculate the frequency and inverse document frequency of terms in the second format normalized text to evaluate the first importance of the terms;
[0173] The TextRank algorithm is used to evaluate the second importance of words using the relationship between nodes in the graph model of the second format planning text;
[0174] According to the first importance and the second importance of the words in the second normalized text, the keywords of the article to be typeset are determined, wherein:
[0175] The contextual weight factor of the TF-IDF algorithm is:
[0176] TFIDF(w,d)=TF(w,d)·C(w,d) / max(TF(w,d)))·log(∣D∣ / ∣d:w∈d∣+1)
[0177] In the formula, w represents a specific word or term; d represents a single document; TF(w,d) represents the number of times word w appears in document d; C(w,d) represents the specific count or weight for word w in document d; max(TF(w,d)) represents the maximum frequency of all words in document d; |D| represents the total number of documents in document set D.
[0178] Optionally, the fifth acquisition module 260 includes:
[0179] Calculate the readability score of each paragraph in the second format normalized text using natural language processing technology;
[0180] For paragraphs in the second format normalized text whose readability score is lower than a preset threshold, the structure and vocabulary are simplified to obtain a third format normalized text.
[0181] Optionally, the first determining module 270 includes:
[0182] Using a typesetting algorithm, positions and styles of words, paragraphs and page layout elements in the third format normalized text are adjusted to obtain a first typeset article;
[0183] An aesthetic rule algorithm is used to optimize the font, line spacing, text alignment, and image insertion in the first typeset article to obtain the initial typeset article.
[0184] Optionally, the expression of the intelligent typesetting algorithm is:
[0185] C=α·(L d ) 2 +β·S
[0186] In the formula, C represents the paragraph adjustment cost, L d Represents the difference in paragraph length, Ld = |L1-L2|, where L1 and L2 are the lengths of the two paragraphs, S represents the semantic similarity of the paragraphs, and α and β are the weight coefficients for adjusting the cost.
[0187] Optionally, the expression of the topic model is:
[0188] T=γ·I+δ·F
[0189] In the formula, T represents the title optimization target, I represents information gain, F represents format consistency, and γ and δ are weight coefficients.
[0190] Exemplary Electronic Devices
[0191] Figure 3 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. Figure 3 As shown, the electronic device 30 includes one or more processors 31 and a memory 32 .
[0192] The processor 31 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0193] The memory 32 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 31 may run the program instructions to implement the methods of the software programs of the various embodiments of the present invention described above and / or other desired functions. In one example, the electronic device may also include: an input device 33 and an output device 34, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0194] In addition, the input device 33 may also include, for example, a keyboard, a mouse, and the like.
[0195] The output device 34 can output various information to the outside. The output device 34 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto.
[0196] Of course, to simplify, Figure 3 Only some of the components related to the present invention in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device may also include any other appropriate components.
[0197] Exemplary computer program products and computer-readable storage media
[0198] In addition to the above-mentioned methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the method according to various embodiments of the present invention described in the above-mentioned "Exemplary Method" section of this specification.
[0199] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the embodiments of the present invention, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0200] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enables the processor to execute the steps of the method for information mining of historical change records according to various embodiments of the present invention described in the above “Exemplary Method” section of this specification.
[0201] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, system or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0202] The basic principle of the present invention is described above in conjunction with specific embodiments. However, it should be pointed out that the advantages, strengths, effects, etc. mentioned in the present invention are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. must be possessed by each embodiment of the present invention. In addition, the specific details disclosed above are only for the purpose of illustration and facilitation of understanding, rather than limitation, and the above details do not limit the present invention to being implemented by adopting the above specific details.
[0203] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0204] The block diagrams of the devices, systems, equipment, and systems involved in the present invention are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, systems, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The word "such as" used here refers to the phrase "such as but not limited to", and can be used interchangeably with it.
[0205] The method and system of the present invention may be implemented in many ways. For example, the method and system of the present invention may be implemented by software, hardware, firmware or any combination of software, hardware, firmware. The above order of steps for the method is only for illustration, and the steps of the method of the present invention are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present invention may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
[0206] It should also be noted that in the system, device and method of the present invention, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. The above description of the disclosed aspects is provided to enable any technician in the field to make or use the present invention. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined here can be applied to other aspects without departing from the scope of the present invention. Therefore, the present invention is not intended to be limited to the aspects shown here, but in accordance with the widest range consistent with the principles and novel features disclosed here.
[0207] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present invention to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. An automatic typesetting method for an article, characterized in that: include: Performing lexical analysis and syntactic analysis on the article to be typeset, and converting the text content of the article to be typeset into structured data that can be understood by a computer; Identify and standardize the non-compliant content in the structured data through a preset rule matching algorithm to obtain a content standardized text; Performing article format check on the content normalized text using a spelling check algorithm and a syntax analysis algorithm to obtain a first format normalized text; Using a sentence boundary detection algorithm to segment and concatenate the first format normalized text to obtain a second format normalized text; Using a keyword extraction algorithm to extract keywords and sentence segments from the second format normalized text to obtain keywords of the article to be typeset; Using natural language processing technology and paragraph length statistical algorithm to perform paragraph adjustment on the second format normalized text to obtain a third format normalized text; Beautify the format of the third format normalized text according to the keywords by using a typesetting algorithm and an aesthetic rule algorithm to determine an initial typeset article; Perform semantic analysis on the initial typeset article through a word vector model and a topic model, identify the subject and sentiment tendency of the article to be typeset, perform personalized adjustments to the typeset of the initial typeset article, and determine the final typeset article; The third format normalized text is formatted and beautified according to the keywords by using a typesetting algorithm and an aesthetic rule algorithm to determine an initial typeset article, including: Using the typesetting algorithm, adjusting the position and style of the words, paragraphs and page layout elements in the third format normalized text to obtain a first typeset article; The aesthetic rule algorithm is used to optimize the font, line spacing, text alignment, and picture insertion in the first typeset article to obtain the initial typeset article; The expression of the typesetting algorithm is: ; In the formula, C Represents the paragraph adjustment cost, L d Indicates the difference in paragraph length, ,in L 1 and L 2 is the length of two paragraphs, S Indicates the semantic similarity of paragraphs, α and β is the weight coefficient of the adjustment cost; The expression of the topic model is: ; In the formula, T Indicates the title optimization goal. I represents information gain, F Indicates format consistency, γ and δ is the weight coefficient.
2. The method according to claim 1, characterized in that Identifying and normalizing the format that does not conform to the standard in the structured data through a preset rule matching algorithm to obtain a content normalized text, including: Using a combination of multi-level rules to perform multi-level matching on the structured data from character strings to grammatical structures, to obtain a first content normalized text; Using a context-sensitive matching algorithm to perform rule matching on the context content of the first content normalized text to obtain a second content normalized text; Using a fuzzy matching and correction mechanism to perform approximate text matching on the second content normalized text within a preset error to obtain a third content normalized text; A dynamic rule algorithm is used to match and update the third content normalized text according to the feedback data to obtain the content normalized text.
3. The method according to claim 1, characterized in that Performing article format check on the content normalized text using a spelling check algorithm and a syntax analysis algorithm to obtain a first format normalized text includes: Using the spell checking algorithm to perform spell checking and correction on the content normalized text to obtain a spelling normalized text; The grammatical analysis algorithm is used to check and correct the grammatical structure of the spelling normalized text to obtain the first format normalized text.
4. The method according to claim 1, characterized in that: Also includes: Reinforcement learning is used to optimize the sentence boundary detection algorithm, wherein the optimization process is as follows: ; In the formula, Q ( s , a ) is the current state s Take action a The value of Q , S is the state space, a is a vector in the action space A, r is in state s Next action a After receiving the instant reward, α 1 is the learning rate, γ 1 is the discount factor, a ′max Q ( s ′, a ′) indicates that in the new state s All possible actions in ′ a The maximum Q value.
5. The method according to claim 1, characterized in that Using a keyword extraction algorithm to extract keywords and sentence segments from the second format normalized text to obtain keywords of the article to be typeset includes: Calculating the frequency and inverse document frequency of terms in the second format normalized text using the TF-IDF algorithm to evaluate the primary importance of the terms; Using the TextRank algorithm to evaluate the second importance of a word using the relationship between nodes in the graph model of the text normalized in the second format; Determine the keywords of the article to be typeset according to the first importance and the second importance of the words in the second format normalized text, wherein: The context weight factor of the TF-IDF algorithm is: ; In the formula, w To indicate a specific word or term; d Represents a single document; TF(w, d) Expressive words w In the documentation d The number of times it appears in C(w, d) For words w In the documentation d a specific count or weight in ; max(TF(w, d)) Representation Document d The maximum frequency of all words in | D ∣ represents a document set D The total number of documents.
6. The method according to claim 1, characterized in that The method of adjusting the paragraphs of the second format normalized text by using natural language processing technology and a paragraph length statistical algorithm to obtain a third format normalized text includes: Calculating the readability score of each paragraph in the second format normalized text using natural language processing technology; For paragraphs in the second format normalized text whose readability score is lower than a preset threshold, the structure and vocabulary are simplified to obtain the third format normalized text.
7. An automatic typesetting device for articles, characterized in that: include: An analysis module, used for performing lexical analysis and syntactic analysis on the article to be typeset, and converting the text content of the article to be typeset into structured data that can be understood by a computer; A first acquisition module, configured to identify and standardize non-compliant content in the structured data through a preset rule matching algorithm, and acquire a content normalized text; A second acquisition module is used to perform article format check on the content normalized text using a spelling check algorithm and a grammar analysis algorithm to obtain a first format normalized text; A third acquisition module is used to segment and concatenate the first format normalized text using a sentence boundary detection algorithm to acquire a second format normalized text; A fourth acquisition module is used to extract keywords and sentence segments from the second format normalized text using a keyword extraction algorithm to obtain keywords of the article to be typeset; A fifth acquisition module, configured to perform paragraph adjustment on the second format normalized text by using natural language processing technology and a paragraph length statistical algorithm to acquire a third format normalized text; A first determination module is used to beautify the third format normalized text according to the keywords by using a typesetting algorithm and an aesthetic rule algorithm to determine an initial typeset article; The second determination module is used to perform semantic analysis on the initial typeset article through a word vector model and a topic model, identify the subject and sentiment tendency of the article to be typeset, perform personalized adjustment on the typeset of the initial typeset article, and determine the final typeset article; The first determination module includes: Using the typesetting algorithm, adjusting the position and style of the words, paragraphs and page layout elements in the third format normalized text to obtain a first typeset article; The aesthetic rule algorithm is used to optimize the font, line spacing, text alignment, and picture insertion in the first typeset article to obtain the initial typeset article; The expression of the typesetting algorithm is: ; In the formula, C Represents the paragraph adjustment cost, L d Indicates the difference in paragraph length, ,in L 1 and L 2 is the length of two paragraphs, S Indicates the semantic similarity of paragraphs, α and β is the weight coefficient of the adjustment cost; The expression of the topic model is: ; In the formula, T Indicates the title optimization goal. I represents information gain, F Indicates format consistency, γ and δ is the weight coefficient.
Citation Information
Patent Citations
Similar text calibration method
CN111581947A
Text key content intelligent extraction method and system based on subject term optimization
CN112926320A