Parser

Struct Parser 

Source
pub struct Parser<Templates = NoCompute, Masks = NoCompute> { /* private fields */ }
Expand description

Tipping (Token Interdependency Parsing) log parser

use fancy_regex::Regex;

let msgs = vec![
    "User 'admin' logged in from IP address 192.168.1.10",
    "Attempt to access unauthorized resource by user 'guest'",
    "Database connection failed due to timeout",
    "Processing request for data retrieval with queryId: 34521",
];

let special_whites = vec![];
let special_blacks = vec![Regex::new(r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}").unwrap()];
let symbols = "'{}|,".chars().collect();
let (event_ids, masks, templates) = tipping_rs::Parser::default()
   .with_threshold(0.5)
   .with_special_whites(special_whites)
   .with_special_blacks(special_blacks)
   .with_symbols(symbols)
   .with_filter_alphabetic(true)
   .with_filter_numeric(false)
   .with_filter_impure(false)
   .compute_templates()
   .compute_masks()
   .parse(&msgs);

Implementations§

Source§

impl Parser

Source

pub fn new() -> Self

Initiates a new Parser with default parameters

Source

pub fn with_threshold(self, value: f32) -> Self

Sets value as threshold. The threshold determines if an interdependency link should be considered during key node computation or not. The threshod should be 0 <= threshold <= 1.

Source

pub fn with_special_whites(self, value: Vec<Regex>) -> Self

Sets value as spcial white regexes. White regexes are never parameterized.

Source

pub fn with_special_blacks(self, value: Vec<Regex>) -> Self

Sets value as special black regexes. Black regexes are always parameterized.

Source

pub fn with_symbols(self, value: HashSet<char>) -> Self

Sets value as symbols. Symbolds are characters that are used alongside the white spaces to split string during tokenization.

Source

pub fn with_filter_alphabetic(self, value: bool) -> Self

The value determines if alphabetic tokens should be used during key node computation.

Source

pub fn with_filter_numeric(self, value: bool) -> Self

The value determines if numeric tokens should be used during key node computation.

Source

pub fn with_filter_impure(self, value: bool) -> Self

The value determines if impure tokens should be used during key node computation.

Source§

impl<T> Parser<NoCompute, T>

Source

pub fn compute_templates(self) -> Parser<Compute, T>

Source§

impl<T> Parser<T, NoCompute>

Source

pub fn compute_masks(self) -> Parser<T, Compute>

Source§

impl Parser<NoCompute, NoCompute>

Source

pub fn parse<Message: AsRef<str> + Sync>( self, messages: &[Message], ) -> Vec<Option<usize>>

Parses the input messages and returns Clusters.

  • Clusters: A Vec<Option<usize>> representing potential cluster IDs. Each Option<usize> corresponds to the cluster ID of the message at the same index, or None if the message couldn’t be parsed.
Source§

impl Parser<Compute, NoCompute>

Source

pub fn parse<Message: AsRef<str> + Sync>( self, messages: &[Message], ) -> (Vec<Option<usize>>, Vec<HashSet<String>>)

Parses the input messages and returns Clusters, and Templates.

  • Clusters: A Vec<Option<usize>> representing potential cluster IDs. Each Option<usize> corresponds to the cluster ID of the message at the same index, or None if the message couldn’t be parsed.

  • Templates: A Vec<HashSet<String>> where each set of templates is aligned with the corresponding cluster ID in the Clusters vector.

Source§

impl Parser<NoCompute, Compute>

Source

pub fn parse<Message: AsRef<str> + Sync>( self, messages: &[Message], ) -> (Vec<Option<usize>>, HashMap<String, String>)

Parses the input messages and returns Clusters, Masks.

  • Clusters: A Vec<Option<usize>> representing potential cluster IDs. Each Option<usize> corresponds to the cluster ID of the message at the same index, or None if the message couldn’t be parsed.

  • Masks: A table mapping each message to its parameter masks.

Source§

impl Parser<Compute, Compute>

Source

pub fn parse<Message: AsRef<str> + Sync>( self, messages: &[Message], ) -> (Vec<Option<usize>>, Vec<HashSet<String>>, HashMap<String, String>)

Parses the input messages and returns Clusters, Templates, and Masks.

  • Clusters: A Vec<Option<usize>> representing potential cluster IDs. Each Option<usize> corresponds to the cluster ID of the message at the same index, or None if the message couldn’t be parsed.

  • Templates: A Vec<HashSet<String>> where each set of templates is aligned with the corresponding cluster ID in the Clusters vector.

  • Masks: A table mapping each message to its parameter masks.

Trait Implementations§

Source§

impl<Templates: Clone, Masks: Clone> Clone for Parser<Templates, Masks>

Source§

fn clone(&self) -> Parser<Templates, Masks>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Templates: Debug, Masks: Debug> Debug for Parser<Templates, Masks>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Parser

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Templates, Masks> Freeze for Parser<Templates, Masks>

§

impl<Templates, Masks> RefUnwindSafe for Parser<Templates, Masks>
where Templates: RefUnwindSafe, Masks: RefUnwindSafe,

§

impl<Templates, Masks> Send for Parser<Templates, Masks>
where Templates: Send, Masks: Send,

§

impl<Templates, Masks> Sync for Parser<Templates, Masks>
where Templates: Sync, Masks: Sync,

§

impl<Templates, Masks> Unpin for Parser<Templates, Masks>
where Templates: Unpin, Masks: Unpin,

§

impl<Templates, Masks> UnwindSafe for Parser<Templates, Masks>
where Templates: UnwindSafe, Masks: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.