Character Encoding Detection Using N-gram Vector Similarity

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Traditional character encoding detection systems often fail to accurately identify the encoding of textual documents, especially those with multiple languages, due to similarities in character encodings and the absence or incorrectness of metadata, leading to frequent misidentification.

Innovation Solution

The method involves identifying uncommon data sequences across character encodings to select features for comparison, generating a representative vector based on n-grams and their inverse frequency, and determining the character encoding by finding similarity within a vector space, thereby distinguishing between potentially similar encodings.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If traditional character encoding detection systems analyze raw textual data for patterns to guess the correct character encoding, then they can operate without metadata, but they frequently fail to detect the correct character encoding for textual documents with multiple languages

Engineering Contradiction:
Improvecharacter encoding detection accuracyVSAvoidhandling of multiple language documents
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The system segments the text stream into multiple n-grams of different lengths (e.g., 1-gram to 5-gram) to capture patterns at different granularities. This segmentation allows the system to analyze both common and uncommon character sequences, improving detection accuracy for multi-language documents by examining patterns at multiple scales simultaneously

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system transforms the character encoding detection problem into a vector space representation where each character encoding is represented as a vector of n-gram frequencies. By adding the dimension of inverse frequency weighting and multi-length n-grams, the system creates a higher-dimensional feature space that better distinguishes between similar encodings, especially for multi-language documents

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

2Ease of manufacture

If character encodings use similar mappings for some characters, then processing becomes simpler, but false positives increase in detection

Engineering Contradiction:
Improveencoding similarityVSAvoiddetection accuracy
Core Design Contradiction:
Ease of manufactureVSMeasurement precision

Solution Approach 1:

The system applies different weighting qualities to different n-grams based on their discriminative power. Common n-grams (high frequency across encodings) receive lower weights, while uncommon n-grams (low frequency, high discriminative power) receive higher weights through inverse frequency calculation. This local quality differentiation allows the system to focus on the most informative patterns for distinguishing similar encodings

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The system changes the parameter of n-gram length analysis by examining multiple lengths (1-gram through 5-gram). This parameter variation allows the system to capture both short distinctive sequences and longer contextual patterns, improving the ability to distinguish between encodings with similar character mappings by looking at patterns at different scales

Inventive Principle:
Principle #35Parameter changes

3Productivity

If traditional systems assume a predetermined character encoding by convention, then processing speed increases, but detection accuracy decreases when metadata is absent or incorrect

Engineering Contradiction:
Improveprocessing speedVSAvoidencoding identification accuracy
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The system performs preliminary analysis by pre-calculating and storing n-gram frequency profiles for multiple character encodings in a vector space before actual detection. This preliminary action creates a ready-to-use reference framework that enables fast comparison and detection without requiring complex real-time analysis, thus maintaining high processing speed while improving accuracy

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS9990339B1Systems and methods for detecting character encodings of text streams
Publication Date: 2018.06.05 GEN DIGITAL INC
  • US9990339B1 patent drawing
  • US9990339B1 patent drawing
  • US9990339B1 patent drawing

AI summary

A computer-implemented method for detecting character encodings of text streams may include 1) identifying a request to identify a character encoding of a text stream, 2) dividing the text stream to identify a plurality of n-grams within the text stream, 3) identifying a plurality of vectors within a vector space, each vector representing a potential character encoding by a plurality of expected n-grams within the potential character encoding, 4) generating, based on the plurality of n-grams within the text stream and on an inverse frequency of appearance of each of the plurality of n-grams within the plurality of vectors, a representative vector describing the text stream, and 5) identifying the character encoding of the text stream based on identifying a similarity between the representative vector and a neighboring vector within the plurality of vectors representing the character encoding. Various other methods, systems, and computer-readable media are also disclosed.