Semantic result processing method and device, electronic equipment and storage medium
By dynamically loading semantic processing packages and using reflection mechanisms to create semantic processing objects, the problem of the inability to effectively handle new semantic fields in the existing technology is solved, and the flexibility and availability of the system is improved, reducing maintenance costs and error risks.
Patent Information
- Application Number
- CN202411461166.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-14
AI Technical Summary
The existing semantic result processing methods cannot effectively handle the new semantic fields, resulting in high system maintenance costs, difficulty in updating and high potential error risks.
By obtaining the semantic results and semantic fields recognized by the voice assistant, a semantic processing object is created based on the reflection mechanism. If the creation fails, the semantic processing package on the preset path will be dynamically loaded so that the voice assistant can create a semantic processing object and process it based on the object Semantic results.
It realizes updating semantic processing logic without restarting the system, improves system flexibility and availability, reduces maintenance costs and potential error risks, and improves the scalability and user experience of voice assistants.
Smart Images

Figure CN119443108A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent vehicle technology, and in particular to a semantic result processing method, device, electronic device and storage medium. Background Art
[0002] With the development of smart vehicle technology, most smart vehicles are equipped with in-vehicle intelligent voice assistants, which rely on the rapid development of artificial intelligence, speech recognition, natural language processing, and human-computer interaction to provide drivers with a more convenient, safe, and intelligent driving experience. The entire intelligent voice assistant system is divided into cloud-based semantic understanding and vehicle-side voice assistant. After collecting user commands, the vehicle-side voice assistant needs to use cloud-based semantic understanding to understand the user commands semantically to obtain semantic results. After obtaining the voice results, the vehicle-side voice assistant needs to process the semantic results and execute corresponding functions based on the semantic results.
[0003] The semantic result processing method in the related technology usually calls the corresponding processing class through an if-else structure or similar branching logic. This method tightly couples the semantic processing logic and the specific implementation class at the code level, resulting in the system having to modify the source code to add new processing branches when facing a new semantic domain, and then recompile and deploy the application. Repeated code modification and redeployment not only increase maintenance costs and extend the time to market for new features, but may also introduce potential errors and affect the stability and reliability of the system. In addition, due to the limitations of its processing logic, the traditional semantic result processing method cannot be quickly hot-updated. Summary of the invention
[0004] In view of the shortcomings of the related technologies mentioned above, the present application provides a semantic result processing method, device, electronic device and storage medium to solve the technical problem that the existing semantic result processing method cannot process the newly added semantic field.
[0005] The present application provides a semantic result processing method, which includes: obtaining the semantic result after recognition by a voice assistant and the semantic domain corresponding to the semantic result, and creating a semantic processing object based on the semantic domain and a reflection mechanism; if the creation of the semantic processing object fails, loading the semantic processing package corresponding to the semantic domain based on a preset path, so that the voice assistant creates the semantic processing object based on the semantic processing package; and processing the semantic result based on the semantic processing method in the semantic processing object.
[0006] In one embodiment of the present application, creating a semantic processing object based on the semantic domain and the reflection mechanism includes: if the semantic processing package corresponding to the semantic domain has been loaded into the memory of the voice assistant, then creating the semantic processing object based on the semantic processing package and the reflection mechanism; if the semantic processing package corresponding to the semantic domain has not been loaded into the memory of the voice assistant, then the creation of the semantic processing object fails.
[0007] In one embodiment of the present application, the semantic processing package also includes a binary file, and loading the semantic processing package corresponding to the semantic domain based on a preset path includes dynamically loading the semantic processing package corresponding to the semantic domain based on the preset path, and the dynamic loading includes: obtaining the absolute path of the semantic processing package according to the semantic domain and the preset path, creating a first object, and passing the absolute path of the semantic processing package to the first object; obtaining a first array based on a reflection mechanism and the first object, the first array including the absolute path of the semantic processing package; obtaining the absolute path of the loader, creating a second object, and passing the absolute path of the loader to the second object; obtaining a second array based on the reflection mechanism and the second object, the second array including the absolute path of the loader; merging the first array and the second array to obtain a third array, and loading the binary file based on the third array and the loader.
[0008] In one embodiment of the present application, the semantic processing package also includes shared object files, and loading the semantic processing package corresponding to the semantic domain based on a preset path includes dynamically loading the semantic processing package corresponding to the semantic domain based on a preset path, and the dynamic loading includes: decompressing the semantic processing package and copying all shared object files in the semantic processing package to a library folder, and the voice assistant includes the library folder.
[0009] In one embodiment of the present application, the semantic processing package also includes a resource file, and loading the semantic processing package corresponding to the semantic domain based on a preset path includes dynamically loading the semantic processing package corresponding to the semantic domain based on the preset path, and the dynamic loading includes: creating a resource management object based on a reflection mechanism and obtaining a resource loading function in the resource management class; obtaining the absolute path of the semantic processing package according to the semantic domain and the preset path, taking the resource management object as a first parameter, taking the absolute path of the semantic processing package as a second parameter, and executing the resource loading function based on the first parameter and the second parameter, so that the resource management object stores the absolute path of the semantic processing package; creating a resource object, and passing the absolute path of the semantic processing package to the resource object based on the resource management object, so as to load the resource file based on the resource object.
[0010] In one embodiment of the present application, the semantic result processing method also includes: if a voice assistant startup signal is detected, a semantic processing package management service is performed, and the semantic processing package management service includes: detecting whether there is a version file in the semantic processing package stored in the voice assistant, if the version file exists, obtaining the version file of the semantic update package in the cloud server, and the semantic domain of the semantic update package is the same as that of the semantic processing package; comparing the version file of the semantic processing package with the version file of the semantic update package, if the comparison is inconsistent, downloading the semantic update package and the update verification value from the cloud server; comparing the update verification value with the local verification value, if the comparison is consistent, deleting the semantic processing package in the voice assistant, and using the semantic update package as the new semantic processing package.
[0011] In one embodiment of the present application, the semantic result processing method also includes: defining a semantic processing interface module, which includes the semantic processing method; generating a plurality of semantic processing classes corresponding to the semantic domains based on different semantic domains and the semantic processing interface module, and packaging the semantic processing classes and version files to obtain the semantic processing package.
[0012] An embodiment of the present application also provides a semantic result processing device, which includes: an input module, used to obtain the semantic result after recognition by a voice assistant and the semantic domain corresponding to the semantic result, and create a semantic processing object based on the semantic domain and the reflection mechanism; a loading module, used to load the semantic processing package corresponding to the semantic domain based on a preset path if the creation of the semantic processing object fails, so that the voice assistant creates the semantic processing object based on the semantic processing package; a processing module, used to process the semantic result based on the semantic processing method in the semantic processing object.
[0013] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements the semantic result processing method as described in any of the above embodiments.
[0014] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer, the computer is caused to execute the semantic result processing method as described in any one of the above embodiments.
[0015] Beneficial effects of the present application: The embodiments of the present application provide a semantic result processing method, device, electronic device and storage medium. The method obtains the semantic result recognized by the voice assistant and the semantic domain corresponding to the semantic result, and creates a semantic processing object based on the semantic domain and the reflection mechanism. If the creation of the semantic processing object fails, the semantic processing package corresponding to the semantic domain is loaded based on a preset path, so that the voice assistant creates a semantic processing object based on the semantic processing package, and processes the semantic result based on the semantic processing method in the semantic processing object. Through the dynamic loading mechanism in the method, the voice assistant can update the semantic processing logic without restarting, thereby improving the flexibility and availability of the system. Through the semantic result processing method of the present application, when adding a new semantic domain, there is no need to modify and recompile the source code. Only the semantic processing package of the relevant semantic domain needs to be added, thereby reducing maintenance costs and potential error risks. The semantic result processing method based on the present application can significantly improve the scalability, maintainability and user experience of the voice assistant.
[0016] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a schematic diagram of an implementation environment of a semantic result processing method shown in an exemplary embodiment of the present application;
[0018] Figure 2 is a flowchart of a semantic result processing method shown in an exemplary embodiment of the present application;
[0019] Figure 3 is a schematic diagram of a semantic result processing implementation flow diagram shown in an exemplary embodiment of the present application;
[0020] Figure 4 is a block diagram of a semantic result processing device shown in an exemplary embodiment of the present application;
[0021] Figure 5 It is a structural schematic diagram of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0022] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0023] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.
[0024] It should be noted that in this application, "first", "second", etc. are only used to distinguish similar objects, and are not used to limit the order or precedence of similar objects. The variations of "including", "having", etc. described above indicate that the scope covered by the subject of the word is not exclusive except for the examples shown by the word.
[0025] It is understood that the various numbers, step numbers, and other reference numerals recorded in this application are distinguished for the convenience of description and are not intended to limit the scope of this application. The size of the reference numerals in this application does not mean the order of execution. The execution order of each process should be determined by its function and internal logic.
[0026] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present application difficult to understand.
[0027] The embodiments of the present application respectively propose a semantic result processing method, a semantic result processing device, an electronic device, a computer-readable storage medium, and a computer program product, which will be described in detail below.
[0028] See also Figure 1 , Figure 1 It is a schematic diagram of an implementation environment of a semantic result processing method shown in an exemplary embodiment of the present application.
[0029] like Figure 1As shown, the implementation environment includes a cloud server 102 and an in-vehicle voice assistant 101, wherein the cloud server 102 is used to provide a semantic processing package storage service, mainly used to perform version management on the semantic processing package, and provide the download address and upload page of the semantic processing package corresponding to each semantic field. The in-vehicle voice assistant 101 is used to perform voice recognition on the user's command to obtain the semantic result and the semantic field corresponding to the semantic result, and to create a semantic processing object based on the semantic field and the reflection mechanism. If the creation of the semantic processing object fails, the semantic processing package corresponding to the semantic field is loaded based on the preset path, so that the voice assistant creates a semantic processing object based on the semantic processing package, and processes the semantic result based on the semantic processing method in the semantic processing object.
[0030] It is important to understand that the semantic domain is a classification of user commands. For example, "I want to listen to music" or "I want to listen to songs by xxx (singer)" are all related to the music domain, so the semantic domain corresponding to this user command is the music domain.
[0031] See also Figure 2 , Figure 2 is a flowchart of a semantic result processing method shown in an exemplary embodiment of the present application. The method can be applied to Figure 1 The implementation environment shown is as follows. The method may also be applicable to other exemplary implementation environments and be specifically executed by devices in other implementation environments. This embodiment does not limit the implementation environment to which the method is applicable.
[0032] like Figure 2 As shown, in an exemplary embodiment, the semantic result processing method includes at least steps S210 to S240, which are described in detail as follows:
[0033] Step S210, obtaining the semantic results recognized by the voice assistant and the semantic domain corresponding to the semantic results, and creating a semantic processing object based on the semantic domain and the reflection mechanism.
[0034] It is important to understand that Java's reflection mechanism is the ability to analyze and manipulate classes, interfaces, fields, and methods at runtime. It allows programs to query and use information about any class at runtime, including private and protected members, as well as dynamically create objects and call methods.
[0035] In one embodiment of the present application, if the semantic processing package corresponding to the semantic domain has been loaded into the memory of the voice assistant, the semantic processing class in the semantic processing package can be queried through the reflection mechanism, and the corresponding semantic processing object can be created based on the semantic processing class. If the creation fails, it means that the semantic processing package corresponding to the semantic domain has not been loaded in the memory of the voice assistant.
[0036] In one embodiment of the present application, creating a semantic processing object based on a semantic domain and a reflection mechanism includes: if a semantic processing package corresponding to the semantic domain has been loaded into the memory of the voice assistant, creating a semantic processing object based on the semantic processing package and the reflection mechanism; if the semantic processing package corresponding to the semantic domain has not been loaded into the memory of the voice assistant, creation of the semantic processing object fails.
[0037] Step S220: If the creation of the semantic processing object fails, the semantic processing package corresponding to the semantic domain is loaded based on a preset path, so that the voice assistant creates the semantic processing object based on the semantic processing package.
[0038] In one embodiment of the present application, the semantic result processing method also includes: defining a semantic processing interface module, which includes a semantic processing method; generating semantic processing classes corresponding to multiple semantic domains based on different semantic domains and semantic processing interface modules, and packaging the semantic processing classes and version files to obtain a semantic processing package.
[0039] In one embodiment of the present application, when packaging a semantic processing package, a unified processing method is first defined for semantic processing to form an aar package. The semantic processing framework and the semantic processing class both rely on this common aar package, and the aar package is used as a semantic processing interface module. Semantic processing classes for different semantic fields are implemented according to the semantic processing interface module, and the semantic processing class and the version file are packaged as a semantic processing package and uploaded to the cloud server. In this embodiment, the semantic processing package can be an APK package.
[0040] In one embodiment of the present application, the semantic processing class in each semantic processing package constructs a class name based on the format of semantic domain name + preset suffix name, for example, the class name in the music domain is MusicExecutor, where Executor is the preset suffix name.
[0041] In one embodiment of the present application, after the semantic processing package is downloaded from the cloud server, the package name + class name is used as the preset path of the semantic processing package, such as com / example / smartvoice / MusicExecutor, so that the semantic processing packages corresponding to different semantic fields can be located through the preset path and the semantic processing packages can be dynamically loaded.
[0042] In one embodiment of the present application, when the semantic processing package is dynamically loaded, the DexClassLoader class loader of Android can be used to load the semantic processing package corresponding to the semantic domain based on a preset path.
[0043] In one embodiment of the present application, the voice assistant can download the semantic processing packages corresponding to each semantic field to the local computer through the cloud server, and then dynamically load the corresponding semantic processing packages when needed. The semantic processing packages mainly include binary files (.class files in .dex files), shared object files (.so files) and resource files (various pictures and xml files). These three types of files have different loading methods and can be dynamically loaded separately according to the following embodiments.
[0044] In one embodiment of the present application, the semantic processing package also includes a binary file, and dynamically loading the semantic processing package corresponding to the semantic domain based on a preset path includes: obtaining the absolute path of the semantic processing package according to the semantic domain and the preset path, creating a first object, and passing the absolute path of the semantic processing package into the first object; obtaining a first array based on a reflection mechanism and the first object, the first array including the absolute path of the semantic processing package; obtaining the absolute path of the loader, creating a second object, and passing the absolute path of the loader into the second object; obtaining a second array based on the reflection mechanism and the second object, the second array including the absolute path of the loader; merging the first array and the second array to obtain a third array, and loading the binary file based on the third array and the loader.
[0045] In one embodiment of the present application, the .dex file is a binary file generated by compiling, reconstructing, rearranging, compressing or obfuscating the .class file. Compared with the .class file, the .dex file is optimized for the virtual machine or operating environment of the Android system and is more suitable for running on embedded devices with limited resources.
[0046] In one embodiment of the present application, the .dex file includes an optimized .class file (i.e., a binary file). Loading a .dex file is to load the .class file therein into memory. In this embodiment, the DexClassLoader tool class provided by the system can be used for loading. The tool class can load the .class file based on the absolute path of the semantic processing package. First, create the semantic processing package's own DexClassLoder object A (i.e., the first object), and pass the absolute path of the semantic processing package into object A, then use the reflection mechanism to get the object B of the member variable pathList of object A, and then use the reflection mechanism to get the member variable dexElements object C of object B (i.e., the first array), object C is an array storing the absolute path of the semantic processing package, repeat the above process to get the loader's dexElements object D (i.e., the second array), merge object C and object D, and get a dexElements object E (i.e., the third array) containing the absolute path of the semantic processing package and the absolute path of the loader, and use object E to replace the object D of the voice assistant loader, so that the voice assistant loader can load the .class files in its own APK package, and can also load the .class files in the semantic processing package.
[0047] In one embodiment of the present application, the semantic processing package also includes a shared object file, and dynamically loading the semantic processing package corresponding to the semantic domain based on a preset path includes:
[0048] Unzip the semantic processing package and copy all shared object files in the semantic processing package to the library folder. The voice assistant includes the library folder.
[0049] In one embodiment of the present application, .so file is a shared object file used in a Unix-like operating system (such as Linux), which is equivalent to a dynamic link library (DLL file) in a Windows operating system. This file format is used to store executable code and data that can be shared between multiple programs, thereby reducing the storage of duplicate code and optimizing resource use. It should be noted that the executable code of a general function is stored in the shared object file, and the executable code of the general function can be shared between multiple programs. When a certain program needs to use the general function, it is not necessary to load other codes additionally, and the executable code in the shared object file in the memory can be directly called. For example, different audio playback software may need to use the audio playback function. If the executable code of the audio playback function is stored in the shared object file, different audio playback software can load the shared object file in the memory and call the corresponding executable code in the shared object file, thereby realizing the general function of audio playback. Loading .so library Android system provides two methods, using the load function and loadLibrary function in the System class. Using the load function only requires providing the full path of .so, and there is no need to copy .so to the path required by the Android system. However, the load function cannot be loaded on demand, and all .so files in the APK package need to be loaded into memory during processing; using the loadLibrary function does not require centralized loading, and only needs to be loaded when the class initialization of the .so library file is used. This on-demand loading saves memory overhead, but using the load function requires copying all .so files to the voice assistant APK installation path required by the Android system. This path has high read and write permissions, and ordinary applications can copy data but cannot create folders required by the Android system. In this embodiment, the loadLibrary function is used for loading. Create a library folder (libs folder) in the source code project of the voice assistant, create an arm64-v8a folder in the libs folder, and create a random .so file in the arm64-v8a folder, such as libnative.so. The purpose of this is that when installing the voice assistant APK, the Android system automatically creates a / lib / arm64 folder under the installation path, solving the problem that ordinary applications can copy .so files but cannot create folders under this path. Then decompress the semantic processing APK, obtain all the .so files in the package, and then copy them to lib / arm64 in the voice assistant APK installation path.
[0050] In one embodiment of the present application, the semantic processing package also includes a resource file, and dynamically loading the semantic processing package corresponding to the semantic domain based on a preset path includes: creating a resource management object based on a reflection mechanism and obtaining a resource loading function in a resource management class; obtaining the absolute path of the semantic processing package according to the semantic domain and the preset path, taking the resource management object as the first parameter, taking the absolute path of the semantic processing package as the second parameter, and executing the resource loading function based on the first parameter and the second parameter, so that the resource management object stores the absolute path of the semantic processing package; creating a resource object, and passing the absolute path of the semantic processing package to the resource object based on the resource management object, so as to load the resource file based on the resource object.
[0051] In one embodiment of the present application, the management of resource files in APK in the Android system is implemented through the AssetManager class (i.e., resource management class). The objects of this class are encapsulated in the Resources class (i.e., resource class), and the application operates resource files through the Resources class object. The Android system does not directly support loading resources of non-installed APKs, so it is necessary to use reflection to create the semantic processing package's own Resources object and AssetManager object, and tell the AssetManager object the absolute path of the semantic processing package. First, use the reflection mechanism to create an AssetManager object A (i.e., resource management object), use the reflection mechanism to obtain the addAssetPath function (i.e., resource loading function) of the AssetManager class, and obtain the Method object M of the function, with object A as the first parameter and the absolute path of the semantic processing package as the second parameter, and call the invoke function of the M object to execute the addAssetPath function of object A, so that object A obtains the absolute path of the semantic processing package. Create another Resources object R (i.e., resource object), and pass the absolute path of the semantic processing package to object R based on object A, so that the absolute path of the semantic processing package can be obtained through object R when the resource file needs to be loaded later.
[0052] Step S230, processing the semantic result based on the semantic processing method in the semantic processing object.
[0053] In one embodiment of the present application, processing the semantic result based on the semantic processing method in the semantic processing object includes: if the semantic field of the semantic processing object is the music field, processing the semantic result based on the processing method in the music field. If the semantic result is "play xxx (singer) music", that is, play xxx (singer) music after searching, then in this embodiment, the functions of searching music and playing music are encapsulated in the semantic processing method corresponding to the music field.
[0054] In one embodiment of the present application, if a voice assistant startup signal is detected, a semantic processing package management service is performed, and the semantic processing package management service includes: detecting whether there is a version file in the semantic processing package stored in the voice assistant, and if there is a version file, obtaining the version file of the semantic update package in the cloud server, and the semantic domain of the semantic update package is the same as that of the semantic processing package; comparing the version file of the semantic processing package with the version file of the semantic update package, if the comparison is inconsistent, downloading the semantic update package and the update verification value from the cloud server; comparing the updated verification value with the local verification value, if the comparison is consistent, deleting the semantic processing package in the voice assistant, and using the semantic update package as a new semantic processing package.
[0055] In one embodiment of the present application, the semantic processing package management service includes semantic processing package download and semantic processing package storage. The semantic processing package storage is located on the cloud server and is mainly used for version management of the semantic processing package, providing the download address and upload page of the semantic processing package corresponding to each semantic field. The semantic processing package download is located on the voice assistant. Each time the voice assistant is started, it checks whether there is a version file in each semantic processing package. If there is no version file, the semantic update package corresponding to the semantic processing package is directly obtained based on the cloud server. The semantic processing package and the corresponding semantic update package have the same semantic field. If there is a version file, the version number A in the version file is compared with the version number B of the corresponding semantic update package in the cloud server. If the comparison is inconsistent, it means that the version has been updated, and the semantic update package is downloaded based on the cloud server, and the integrity of the semantic update package after downloading is checked based on the update check value. If the update check value is inconsistent with the local check value, the semantic update package is deleted and downloaded again. If the update check value and the local check value are inconsistent for more than three times, the update error is reported and the download is exited.
[0056] See also Figure 3 , Figure 3It is a schematic diagram of the implementation process of semantic result processing shown in an exemplary embodiment of the present application, and the process includes: interface definition, implementation class packaging, server storage, dynamic loading mechanism and reflection call. First, the semantic processing package corresponding to each semantic domain is developed on the developer side. The development includes interface definition and implementation class packaging. The interface definition includes creating a DomainInterface interface and defining the common methods required for semantic result processing. Implementation class packaging includes creating an independent engineering module for each semantic domain. The class that implements DomainInterface in this module, the type of implementation class follows the format of semantic domain + Executor, for example, if the semantic domain is music, it is named MusicExecutor. After implementation, these classes are packaged into independent semantic processing packages. Server storage includes uploading the semantic processing packages corresponding to each semantic domain to the cloud server for subsequent dynamic download and update. The dynamic loading mechanism includes that on the voice assistant side, after receiving the semantic result and the corresponding semantic domain, in this embodiment, if the semantic domain is Music, the system attempts to use the Java reflection mechanism to create the semantic object corresponding to Music. If the creation fails, it means that the semantic processing package corresponding to the semantic domain has not been loaded into the memory, so it is necessary to use Android's DexClassLoader class loader to load the semantic processing package where the MusicExecutor class is located under the preset path. The reflection call includes that after loading the semantic processing package where the MusicExecutor class is located, the reflection mechanism is used to instantiate the MusicExecutor class to obtain the corresponding semantic processing object, and the semantic processing method defined in DomainInterface is called to process the semantic result.
[0057] See also Figure 4 , Figure 4 is a block diagram of a semantic result processing device shown in an exemplary embodiment of the present application. The device can be applied to Figure 1 The implementation environment shown is as follows. The device may also be applicable to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the device is applicable.
[0058] like Figure 4 As shown, the exemplary semantic result processing device includes: an input module 401 , a loading module 402 and a processing module 403 .
[0059] Input module 401, used to obtain the semantic results recognized by the voice assistant and the semantic fields corresponding to the semantic results, and create a semantic processing object based on the semantic fields and reflection mechanism;
[0060] A loading module 402 is used to load a semantic processing package corresponding to the semantic domain based on a preset path if the creation of the semantic processing object fails, so that the voice assistant creates the semantic processing object based on the semantic processing package;
[0061] The processing module 403 is used to process the semantic result based on the semantic processing method in the semantic processing object.
[0062] Figure 5 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Figure 5 The computer system 500 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0063] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503, such as executing the method described in the above embodiment. In the RAM 503, various programs and data required for system operation are also stored. The CPU 501, the ROM 502 and the RAM 503 are connected to each other through a bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.
[0064] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that a computer program read therefrom is installed into the storage section 508 as needed.
[0065] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 509, and / or installed from a removable medium 511. When the computer program is executed by a central processing unit (CPU) 501, various functions defined in the system of the present application are executed.
[0066] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a 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. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0067] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0068] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0069] Another aspect of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the semantic result processing method as described above. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.
[0070] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the semantic result processing method provided in each of the above embodiments.
[0071] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A semantic result processing method, characterized in that: The semantic result processing method comprises: Obtaining the semantic results recognized by the voice assistant and the semantic domain corresponding to the semantic results, and creating a semantic processing object based on the semantic domain and the reflection mechanism; If the creation of the semantic processing object fails, the semantic processing package corresponding to the semantic domain is loaded based on a preset path, so that the voice assistant creates the semantic processing object based on the semantic processing package; The semantic result is processed based on the semantic processing method in the semantic processing object.
2. The semantic result processing method according to claim 1, characterized in that: Creating a semantic processing object based on the semantic domain and the reflection mechanism includes: If the semantic processing package corresponding to the semantic domain has been loaded into the memory of the voice assistant, creating the semantic processing object based on the semantic processing package and the reflection mechanism; If the semantic processing package corresponding to the semantic domain is not loaded into the memory of the voice assistant, the creation of the semantic processing object fails.
3. The semantic result processing method according to claim 1, characterized in that: The semantic processing package also includes a binary file, and loading the semantic processing package corresponding to the semantic field based on a preset path includes dynamically loading the semantic processing package corresponding to the semantic field based on a preset path, and the dynamic loading includes: Obtaining the absolute path of the semantic processing package according to the semantic domain and the preset path, creating a first object, and transferring the absolute path of the semantic processing package into the first object; Obtaining a first array based on a reflection mechanism and the first object, wherein the first array includes an absolute path of the semantic processing package; Obtaining the absolute path of the loader, creating a second object, and passing the absolute path of the loader into the second object; Obtaining a second array based on a reflection mechanism and the second object, wherein the second array includes an absolute path of the loader; The first array and the second array are combined to obtain a third array, and the binary file is loaded based on the third array and the loader.
4. The semantic result processing method according to claim 1, characterized in that: The semantic processing package also includes a shared object file, and loading the semantic processing package corresponding to the semantic domain based on a preset path includes dynamically loading the semantic processing package corresponding to the semantic domain based on a preset path, and the dynamic loading includes: The semantic processing package is decompressed, and all shared object files in the semantic processing package are copied to a library folder, and the voice assistant includes the library folder.
5. The semantic result processing method according to claim 1, characterized in that: The semantic processing package also includes a resource file, and loading the semantic processing package corresponding to the semantic domain based on a preset path includes dynamically loading the semantic processing package corresponding to the semantic domain based on a preset path, and the dynamic loading includes: Create a resource management object based on the reflection mechanism and obtain the resource loading function in the resource management class; Obtaining the absolute path of the semantic processing package according to the semantic domain and the preset path, taking the resource management object as a first parameter, taking the absolute path of the semantic processing package as a second parameter, and executing the resource loading function based on the first parameter and the second parameter, so that the resource management object stores the absolute path of the semantic processing package; A resource object is created, and the absolute path of the semantic processing package is passed to the resource object based on the resource management object, so as to load the resource file based on the resource object.
6. The semantic result processing method according to any one of claims 1 to 5, characterized in that: The semantic result processing method also includes: If a voice assistant startup signal is detected, a semantic processing package management service is performed, and the semantic processing package management service includes: Detecting whether there is a version file in the semantic processing package stored in the voice assistant, and if the version file exists, obtaining the version file of the semantic update package in the cloud server, wherein the semantic domain of the semantic update package is the same as that of the semantic processing package; Comparing the version file of the semantic processing package with the version file of the semantic update package, and if the comparison is inconsistent, downloading the semantic update package and the update check value from the cloud server; The updated check value is compared with the local check value. If the comparison is consistent, the semantic processing package in the voice assistant is deleted, and the semantic update package is used as the new semantic processing package.
7. The semantic result processing method according to any one of claims 1 to 5, characterized in that: The semantic result processing method also includes: Defining a semantic processing interface module, wherein the semantic processing interface module includes the semantic processing method; Based on different semantic domains and the semantic processing interface module, a plurality of semantic processing classes corresponding to the semantic domains are generated, and the semantic processing classes and version files are packaged to obtain the semantic processing package.
8. A semantic result processing device, characterized in that: The semantic result processing device comprises: An input module, used to obtain the semantic results recognized by the voice assistant and the semantic domain corresponding to the semantic results, and create a semantic processing object based on the semantic domain and the reflection mechanism; A loading module, configured to load a semantic processing package corresponding to the semantic domain based on a preset path if the creation of the semantic processing object fails, so that the voice assistant creates the semantic processing object based on the semantic processing package; A processing module is used to process the semantic result based on the semantic processing method in the semantic processing object.
9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the semantic result processing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of a computer, the computer is caused to execute the semantic result processing method as described in any one of claims 1 to 7.