CN102779189A - Method and system for analyzing expressions - Google Patents

Method and system for analyzing expressions Download PDF

Info

Publication number
CN102779189A
CN102779189A CN2012102272001A CN201210227200A CN102779189A CN 102779189 A CN102779189 A CN 102779189A CN 2012102272001 A CN2012102272001 A CN 2012102272001A CN 201210227200 A CN201210227200 A CN 201210227200A CN 102779189 A CN102779189 A CN 102779189A
Authority
CN
China
Prior art keywords
prefix
expression
character string
character
binary tree
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN2012102272001A
Other languages
Chinese (zh)
Other versions
CN102779189B (en
Inventor
鞠训卓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Shenzhou Taiyue Software Co Ltd
Original Assignee
Beijing Shenzhou Taiyue Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Shenzhou Taiyue Software Co Ltd filed Critical Beijing Shenzhou Taiyue Software Co Ltd
Priority to CN201210227200.1A priority Critical patent/CN102779189B/en
Publication of CN102779189A publication Critical patent/CN102779189A/en
Application granted granted Critical
Publication of CN102779189B publication Critical patent/CN102779189B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Machine Translation (AREA)

Abstract

The invention discloses a method and a system for analyzing expressions. The method comprises the steps of: constructing an expression balanced binary tree and a prefix balanced binary tree according to expression codes, wherein nodes in the expression balanced binary tree are expression codes, and nodes in the prefix balanced binary tree are prefix sub character clusters; and retrieving a target text from the target text by using the expression balanced binary tree and the prefix balanced binary tree and analyzing the expression codes from the target text. The method and the system for analyzing expressions can solve the problem of low expression analyzing speed.

Description

A kind of method and system of expressing one's feelings and resolving
Technical field
The present invention relates to computer realm, particularly a kind of method and system of expressing one's feelings and resolving.
Background technology
Indispensable means of communication during IM (Instant Message, instant message) instrument has become people's daily life and worked.Along with increasing of the user of smart mobile phone, the IM instrument on the smart mobile phone of operating in is also more and more abundanter etc.Can send and receive expression is that IM uses an important ingredient, lacks the decline that the IM application of expression can bring user experience.On intelligent mobile phone platform, processor speed is limited, and internal memory is also comparatively nervous, in this case, how to improve the speed that expression is resolved, and takies less internal memory, just seems particularly important.
Express one's feelings in the prior art when resolving, use multiway tree to travel through.To given expression code collection, create when being used to store the multiway tree of expression code, in program, need use hard coded to each code of expressing one's feelings, be unfavorable for the expansion of expressing one's feelings.When using this multiway tree to express one's feelings to resolve, the traversal speed resolution speed that causes slowly expressing one's feelings is slow.
Summary of the invention
The invention provides a kind of method and system of expressing one's feelings and resolving, to solve the slow problem of expression resolution speed.
The invention discloses a kind of method of expressing one's feelings and resolving, said method comprises:
Based on expression code construction expression balanced binary tree and prefix balanced binary tree, node is the expression code in the expression balanced binary tree; Node is prefix substring in the expression code in the prefix balanced binary tree;
Utilize expression balanced binary tree and prefix balanced binary tree target text to be retrieved, from target text, parse the expression code from target text.
Wherein, said utilization expression balanced binary tree and prefix balanced binary tree are retrieved target text from target text, from target text, parse the expression code and specifically comprise:
From target text, get the original character of character, resolve current parsing character string as follows as current parsing character string,
Step 1, the current parsing character string of retrieval in the expression balanced binary tree, if retrieve, then execution in step 2, if do not retrieve, then execution in step 3;
Step 2 confirms that current parsing character string is the expression code;
Step 3, the current parsing character string of retrieval if retrieve, is then got character late and is added in the current parsing character string from target text in the prefix balanced binary tree, execution in step 1, if do not retrieve, then execution in step 4;
Step 4 confirms that current parsing character string is not the expression code.
Wherein, saidly specifically comprise according to expression code construction prefix balanced binary tree:
From each expression code, extract the prefix substring, form prefix sets;
For a plurality of same prefix substrings in the prefix sets, keep one in prefix sets;
Make up the prefix balanced binary tree according to prefix sets.
Wherein, the said character of from target text, getting specifically comprises as the original character of current parsing character string:
If the current parsing character string of resolving last time is the expression code, then from target text, get the character late of last character in the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
Wherein, the said character of from target text, getting specifically comprises as the original character of current parsing character string:
If the current parsing character string of resolving last time is not the expression code, then from target text, get the character late of the original character of the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
Wherein, said step 2 also comprises:
Confirm the expression of current parsing character string representative according to the expression code that retrieves.
The invention also discloses a kind of system of expressing one's feelings and resolving, said system comprises:
Balanced binary tree makes up module, is used for based on expression code construction expression balanced binary tree and prefix balanced binary tree, and node is the expression code in the expression balanced binary tree; Node is prefix substring in the expression code in the prefix balanced binary tree;
The text resolution module is used for utilizing expression balanced binary tree and prefix balanced binary tree from target text target text to be retrieved, and from target text, parses the expression code.
Wherein, said text resolution module specifically comprises:
The character extraction unit is used for getting the original character of character as current parsing character string from target text, and call the expression judging unit and begin to resolve current parsing character string,
The expression judging unit is used in the current parsing character string of expression balanced binary tree retrieval, if retrieve, confirms that then current parsing character string is the expression code, and calls the character extraction unit, if do not retrieve, then calls the prefix judging unit;
The prefix judging unit; Be used for if retrieve, then from target text, getting character late and adding in the current parsing character string in the current parsing character string of prefix balanced binary tree retrieval; Call the expression judging unit; If do not retrieve, confirm that then current parsing character string is not the expression code, and call the character extraction unit.
Wherein, said balanced binary tree makes up module and specifically is used for: extract the prefix substring from each expression code, form prefix sets; For a plurality of same prefix substrings in the prefix sets, keep one in prefix sets; Make up the prefix balanced binary tree according to prefix sets.
Wherein, said character extraction unit specifically is used for:
If the current parsing character string of resolving last time is the expression code, then from target text, get the character late of last character in the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing;
And/or,
If the current parsing character string of resolving last time is not the expression code, then from target text, get the character late of the original character of the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
The invention has the beneficial effects as follows: through making up expression balanced binary tree and prefix balanced binary tree; In expression balanced binary tree and prefix balanced binary tree, retrieve and from target text, resolve expression; Can improve the speed that expression is resolved, adapt to the limited terminal devices of processing speed such as smart mobile phone more.
Description of drawings
The process flow diagram of the method that Fig. 1 resolves for the present invention expresses one's feelings.
Fig. 2 is the method flow diagram of resolving current parsing character string in the specific embodiment of the invention.
The process flow diagram of the embodiment of the method that Fig. 3 resolves for the present invention expresses one's feelings.
The structural drawing of the system that Fig. 4 resolves for the present invention expresses one's feelings.
Fig. 5 is the structural drawing of specific embodiment of the invention Chinese version parsing module.
Embodiment
For making the object of the invention, technical scheme and advantage clearer, embodiment of the present invention is done to describe in detail further below in conjunction with accompanying drawing.
Referring to Fig. 1, the flow process of the method for resolving for expression provided by the invention.
Said method comprises the steps.
Step S100 is according to expression code construction expression balanced binary tree and prefix balanced binary tree.
Node is the expression code in the expression balanced binary tree; Node is prefix substring in the expression code in the prefix balanced binary tree.
Step S200 utilizes expression balanced binary tree and prefix balanced binary tree that target text is retrieved, and from target text, parses the expression code.
Wherein, the prefix substring arrives the character string of each character except that last character for first character in the expression code.The coded representation of promptly expressing one's feelings is: E 0E 1... E i... E m, E wherein iBe i character of this emoticon, then the prefix substring of this expression code comprises: E 0, E 0E 1..., E 0E 1... E i..., E 0E 1... E i... E M-1
Character string can be a character or a plurality of character among the present invention.
In an embodiment, the idiographic flow that said step S200 realizes is as shown in Figure 2.
From target text, get the original character of character, resolve current parsing character string as follows as current parsing character string.
Step S210, the current parsing character string of retrieval in the expression balanced binary tree, if retrieve, execution in step S220 then, if do not retrieve, execution in step S230 then.
Step S220 confirms that current parsing character string is the expression code.
Step S230, the current parsing character string of retrieval in the prefix balanced binary tree, if retrieve, execution in step S250 then, if do not retrieve, execution in step S240 then.
Step S240 confirms that current parsing character string is not the expression code.
Step S250 gets character late and adds in the current parsing character string execution in step S210 to from target text
Further, step S220 also comprises: the expression of confirming current parsing character string representative according to the expression code that retrieves.
In an embodiment, saidly specifically comprise according to expression code construction prefix balanced binary tree:
Step S110 extracts the prefix substring from each expression code, form prefix sets.
Step S120 for a plurality of same prefix substrings in the prefix sets, keeps one in prefix sets.
Step S130 makes up the prefix balanced binary tree according to prefix sets.
For example, the set of expression code composition is { ab, abc, abd, ba, bd, bca, bcd}.Utilize the method for known structure balanced binary tree according to this set, make up the expression balanced binary tree.
The prefix substring of expression code ab comprises: a.
The prefix substring of expression code abc comprises: a, ab.
The prefix substring of expression code abd comprises: a, ab.
The prefix substring of expression code ba comprises: b.
The prefix substring of expression code bd comprises: b.
The prefix substring of expression code bca comprises: b, bc.
The prefix substring of expression code bcd comprises: b, bc.
Remove wherein repeating part, final prefix sets { a, ab, b, the bc} of getting.
Initial prefix balanced binary tree is empty, by known balanced binary tree constructing method, character string in the prefix sets is inserted in the prefix balanced binary tree.
In a preferable embodiment, the said character of from target text, getting specifically comprises as the original character of current parsing character string:
If the current parsing character string of resolving last time is the expression code, then from target text, get the character late of last character in the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
In a preferable embodiment, the said character of from target text, getting specifically comprises as the original character of current parsing character string:
If the current parsing character string of resolving last time is not the expression code, then from target text, get the character late of the original character of the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
Embodiment
Referring to Fig. 3, be the express one's feelings process flow diagram of embodiment of the method for resolving of the present invention.
In an embodiment, text parameter text is set, is used to preserve the non-expression character string that parses, prefix parameter prefix is set, be used to preserve the current parsing character string of this parsing.Step S301 carries out initialization, and parameter text and prefix are put sky.
Step S302 judges whether been scanned of target text, if, execution in step S308 then, otherwise, execution in step S303.
Step S303 adds current character in the getting target text among the prefix.
When initial, get in the target text first character and add among the prefix.
After initial, all be that the character late of getting current character is a current character at every turn, adding prefix.
Step S304 retrieves prefix in expression in the balanced binary tree, judges whether prefix is the code of expressing one's feelings, if, execution in step S305 then, otherwise, execution in step S306.
Step S305 preserves text, and prefix is preserved, and empties text and prefix.
Step S306 retrieves prefix in the prefix balanced binary tree, judge whether prefix is the prefix substring, if, execution in step S302 then, otherwise, execution in step S307.
Step S307 is pressed onto first character of prefix among the text, and current character is recalled length (prefix)-1 position, empties prefix.
Step S308 is pressed into prefix among the text, and text is preserved, and empties prefix.
To use technical scheme of the present invention (hereinafter to be referred as redaction) and the old technical scheme (hereinafter to be referred as legacy version) of using multiway tree to carry out performance relatively, the result is following.
1, test case comprises 500 common characters, not expression
Legacy version: move this test case 1000 times, 7000 milliseconds consuming time;
Redaction: move this test case 2000 times, 3000 milliseconds consuming time;
2, test case only comprises 200 expressions:
Legacy version: move this test case 2000 times, 117000 milliseconds consuming time;
Redaction: move this test case 2000 times, 27000 milliseconds consuming time;
3, test case comprises 400 characters, and wherein expression and plain text are mixed:
Legacy version: move this test case 2000 times, 29000 milliseconds consuming time;
Redaction: move this test case 2000 times, 9000 milliseconds consuming time.
A kind of structure of system of the parsing of expressing one's feelings is as shown in Figure 4.
Balanced binary tree makes up module 100, is used for based on expression code construction expression balanced binary tree and prefix balanced binary tree, and node is the expression code in the expression balanced binary tree; Node is prefix substring in the expression code in the prefix balanced binary tree;
Text resolution module 200 is used for utilizing expression balanced binary tree and prefix balanced binary tree from target text target text to be retrieved, and from target text, parses the expression code.
Referring to Fig. 5, be the structural drawing of specific embodiment of the invention Chinese version parsing module.
In a preferred implementation, said text resolution module 200 specifically comprises:
Character extraction unit 210 is used for getting the original character of character as current parsing character string from target text, calls expression judging unit 220 and begins to resolve current parsing character string.
Expression judging unit 220 is used in the current parsing character string of expression balanced binary tree retrieval, if retrieve, confirms that then current parsing character string is the expression code, and calls character extraction unit 210, if do not retrieve, then calls prefix judging unit 230.
Prefix judging unit 230; Be used for if retrieve, then from target text, getting character late and adding in the current parsing character string in the current parsing character string of prefix balanced binary tree retrieval; Call expression judging unit 220; If do not retrieve, confirm that then current parsing character string is not the expression code, and call character extraction unit 210.
In a preferred implementation, said balanced binary tree makes up module 100 and specifically is used for: extract the prefix substring from each expression code, form prefix sets; For a plurality of same prefix substrings in the prefix sets, keep one in prefix sets; Make up the prefix balanced binary tree according to prefix sets.
In a preferred implementation, said character extraction unit 210 specifically is used for:
If the current parsing character string of resolving last time is the expression code, then from target text, get the character late of last character in the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing;
In a preferred implementation, said character extraction unit 210 specifically is used for:
If the current parsing character string of resolving last time is not the expression code, then from target text, get the character late of the original character of the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
The above is merely preferred embodiment of the present invention, is not to be used to limit protection scope of the present invention.All any modifications of within spirit of the present invention and principle, being done, be equal to replacement, improvement etc., all be included in protection scope of the present invention.

Claims (10)

1. method of expressing one's feelings and resolving is characterized in that said method comprises:
Based on expression code construction expression balanced binary tree and prefix balanced binary tree, node is the expression code in the expression balanced binary tree; Node is prefix substring in the expression code in the prefix balanced binary tree;
Utilize expression balanced binary tree and prefix balanced binary tree target text to be retrieved, from target text, parse the expression code from target text.
2. method according to claim 1 is characterized in that,
Said utilization expression balanced binary tree and prefix balanced binary tree are retrieved target text from target text, from target text, parse the expression code and specifically comprise:
From target text, get the original character of character, resolve current parsing character string as follows as current parsing character string,
Step 1, the current parsing character string of retrieval in the expression balanced binary tree, if retrieve, then execution in step 2, if do not retrieve, then execution in step 3;
Step 2 confirms that current parsing character string is the expression code;
Step 3, the current parsing character string of retrieval if retrieve, is then got character late and is added in the current parsing character string from target text in the prefix balanced binary tree, execution in step 1, if do not retrieve, then execution in step 4;
Step 4 confirms that current parsing character string is not the expression code.
3. method according to claim 1 is characterized in that,
Saidly specifically comprise according to expression code construction prefix balanced binary tree:
From each expression code, extract the prefix substring, form prefix sets;
For a plurality of same prefix substrings in the prefix sets, keep one in prefix sets;
Make up the prefix balanced binary tree according to prefix sets.
4. method according to claim 2 is characterized in that,
The said character of from target text, getting specifically comprises as the original character of current parsing character string:
If the current parsing character string of resolving last time is the expression code, then from target text, get the character late of last character in the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
5. method according to claim 2 is characterized in that,
The said character of from target text, getting specifically comprises as the original character of current parsing character string:
If the current parsing character string of resolving last time is not the expression code, then from target text, get the character late of the original character of the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
6. method according to claim 2 is characterized in that,
Said step 2 also comprises:
Confirm the expression of current parsing character string representative according to the expression code that retrieves.
7. system of expressing one's feelings and resolving is characterized in that said system comprises:
Balanced binary tree makes up module, is used for based on expression code construction expression balanced binary tree and prefix balanced binary tree, and node is the expression code in the expression balanced binary tree; Node is prefix substring in the expression code in the prefix balanced binary tree;
The text resolution module is used for utilizing expression balanced binary tree and prefix balanced binary tree from target text target text to be retrieved, and from target text, parses the expression code.
8. system according to claim 7 is characterized in that,
Said text resolution module specifically comprises:
The character extraction unit is used for getting the original character of character as current parsing character string from target text, and call the expression judging unit and begin to resolve current parsing character string,
The expression judging unit is used in the current parsing character string of expression balanced binary tree retrieval, if retrieve, confirms that then current parsing character string is the expression code, and calls the character extraction unit, if do not retrieve, then calls the prefix judging unit;
The prefix judging unit; Be used for if retrieve, then from target text, getting character late and adding in the current parsing character string in the current parsing character string of prefix balanced binary tree retrieval; Call the expression judging unit; If do not retrieve, confirm that then current parsing character string is not the expression code, and call the character extraction unit.
9. system according to claim 7 is characterized in that,
Said balanced binary tree makes up module and specifically is used for: extract the prefix substring from each expression code, form prefix sets; For a plurality of same prefix substrings in the prefix sets, keep one in prefix sets; Make up the prefix balanced binary tree according to prefix sets.
10. system according to claim 8 is characterized in that,
Said character extraction unit specifically is used for:
If the current parsing character string of resolving last time is the expression code, then from target text, get the character late of last character in the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing;
And/or,
If the current parsing character string of resolving last time is not the expression code, then from target text, get the character late of the original character of the current parsing character string of resolving last time, as the original character of the current parsing character string of this parsing.
CN201210227200.1A 2012-06-30 2012-06-30 Method and system for analyzing expressions Active CN102779189B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210227200.1A CN102779189B (en) 2012-06-30 2012-06-30 Method and system for analyzing expressions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210227200.1A CN102779189B (en) 2012-06-30 2012-06-30 Method and system for analyzing expressions

Publications (2)

Publication Number Publication Date
CN102779189A true CN102779189A (en) 2012-11-14
CN102779189B CN102779189B (en) 2015-01-14

Family

ID=47124101

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210227200.1A Active CN102779189B (en) 2012-06-30 2012-06-30 Method and system for analyzing expressions

Country Status (1)

Country Link
CN (1) CN102779189B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107886568A (en) * 2017-12-09 2018-04-06 东方梦幻文化产业投资有限公司 A kind of method and system that human face expression is rebuild using 3D Avatar

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040111420A1 (en) * 2002-12-05 2004-06-10 International Business Machines Corporation Performance and memory bandwidth utilization for tree searches using tree fragmentation
CN101089810A (en) * 2006-06-13 2007-12-19 上海海加网络科技有限公司 Session cache method based on binary balance tree
CN101567014A (en) * 2009-06-04 2009-10-28 福建星网锐捷网络有限公司 Equipment information retrieval method, device and cable fastener

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040111420A1 (en) * 2002-12-05 2004-06-10 International Business Machines Corporation Performance and memory bandwidth utilization for tree searches using tree fragmentation
CN1504912A (en) * 2002-12-05 2004-06-16 �Ҵ���˾ Performance and memory bandwidth utilization for tree searches using tree fragmentation
CN101089810A (en) * 2006-06-13 2007-12-19 上海海加网络科技有限公司 Session cache method based on binary balance tree
CN101567014A (en) * 2009-06-04 2009-10-28 福建星网锐捷网络有限公司 Equipment information retrieval method, device and cable fastener

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107886568A (en) * 2017-12-09 2018-04-06 东方梦幻文化产业投资有限公司 A kind of method and system that human face expression is rebuild using 3D Avatar
CN107886568B (en) * 2017-12-09 2020-03-03 东方梦幻文化产业投资有限公司 Method and system for reconstructing facial expression by using 3D Avatar

Also Published As

Publication number Publication date
CN102779189B (en) 2015-01-14

Similar Documents

Publication Publication Date Title
CN102801859B (en) Method and device for identifying junk short message, and mobile communication terminal with device
CN103037072A (en) Implementation method of extracting short message contents to apply to scene
CN101299857B (en) Method and apparatus for outputting communication information
CN107561564B (en) A kind of compression implementation method of big-dipper satellite information transmission
CN102135814A (en) Word input method and system
CN101651731A (en) Method and system for managing address book and mobile terminal
CN102769691A (en) Prompt method of new message and communication terminal
CN102946474B (en) Method and device for automatically sharing contact information of contacts and mobile terminal
CN103906012A (en) Information sending method and device
CN1322401C (en) Communications terminal apparatus, reception apparatus, and method therefor
CN108694168A (en) A kind of address processing method and processing device, computer installation and readable storage medium storing program for executing
CN103686638A (en) Information processing method, device and terminal
CN101345952B (en) Data storing and reading method, device and system for client identification card
CN102841919A (en) Method and system for analyzing expressions in conversion text
CN104092514A (en) Encoding mode switching method and device
CN102779189B (en) Method and system for analyzing expressions
CN103843292B (en) Networking component and mobile device
CN104765727A (en) Text translation method and device
CN105120045A (en) Method and device for creating address book according to note information of new contact name
TW201242411A (en) System and method for processing unsolicited responses of AT commands
CN104182286A (en) Cross-platform Chinese character messy code recovery method
CN102131161A (en) Method, device and system for encoding short message
CN114676673A (en) Form input method, device and equipment of text data based on voice recognition
CN102567294A (en) Text data processing method and text data processing device
CN110941946A (en) Information extraction method, device, equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP02 Change in the address of a patent holder

Address after: Room 818, 8 / F, 34 Haidian Street, Haidian District, Beijing 100080

Patentee after: BEIJING ULTRAPOWER SOFTWARE Co.,Ltd.

Address before: 100089 Beijing city Haidian District wanquanzhuang Road No. 28 Wanliu new building 6 storey block A Room 601

Patentee before: BEIJING ULTRAPOWER SOFTWARE Co.,Ltd.

CP02 Change in the address of a patent holder