Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoSign in
Socket

quickner

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quickner - pypi Package Compare versions

Comparing version
0.0.1a15
to
0.0.1a16
+100
-22
Cargo.lock

@@ -28,5 +28,5 @@ # This file is automatically @generated by Cargo.

name = "block-buffer"
version = "0.10.3"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [

@@ -162,5 +162,5 @@ "generic-array",

name = "csv"
version = "1.2.0"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af91f40b7355f82b0a891f50e70399475945bb0b0da4f1700ce60761c9d3e359"
checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad"
dependencies = [

@@ -311,5 +311,5 @@ "csv-core",

name = "io-lifetimes"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3"
dependencies = [

@@ -346,5 +346,5 @@ "libc",

name = "libc"
version = "0.2.139"
version = "0.2.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"

@@ -377,2 +377,11 @@ [[package]]

[[package]]
name = "matrixmultiply"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84"
dependencies = [
"rawpointer",
]
[[package]]
name = "memchr"

@@ -393,2 +402,43 @@ version = "2.5.0"

[[package]]
name = "ndarray"
version = "0.15.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32"
dependencies = [
"matrixmultiply",
"num-complex",
"num-integer",
"num-traits",
"rawpointer",
]
[[package]]
name = "num-complex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d"
dependencies = [
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"

@@ -410,2 +460,17 @@ version = "1.15.0"

[[package]]
name = "numpy"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96b0fee4571867d318651c24f4a570c3f18408cf95f16ccb576b3ce85496a46e"
dependencies = [
"libc",
"ndarray",
"num-complex",
"num-integer",
"num-traits",
"pyo3",
"rustc-hash",
]
[[package]]
name = "once_cell"

@@ -546,4 +611,5 @@ version = "1.17.1"

name = "quickner"
version = "0.0.1-alpha.15"
version = "0.0.1-alpha.16"
dependencies = [
"numpy",
"pyo3",

@@ -556,3 +622,3 @@ "quickner-core",

name = "quickner-core"
version = "0.0.1-alpha.15"
version = "0.0.1-alpha.16"
dependencies = [

@@ -582,2 +648,8 @@ "aho-corasick",

[[package]]
name = "rawpointer"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
[[package]]
name = "rayon"

@@ -631,2 +703,8 @@ version = "1.7.0"

[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"

@@ -659,5 +737,5 @@ version = "0.36.9"

name = "serde"
version = "1.0.152"
version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
checksum = "8cdd151213925e7f1ab45a9bbfb129316bd00799784b174b7cc7bcd16961c49e"
dependencies = [

@@ -669,5 +747,5 @@ "serde_derive",

name = "serde_derive"
version = "1.0.152"
version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
checksum = "4fc80d722935453bcafdc2c9a73cd6fac4dc1938f0346035d84bf99fa9e33217"
dependencies = [

@@ -681,5 +759,5 @@ "proc-macro2",

name = "serde_json"
version = "1.0.93"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea"
dependencies = [

@@ -772,5 +850,5 @@ "itoa",

name = "toml_edit"
version = "0.19.4"
version = "0.19.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825"
checksum = "7082a95d48029677a28f181e5f6422d0c8339ad8396a39d3f33d62a90c1f6c30"
dependencies = [

@@ -792,5 +870,5 @@ "indexmap",

name = "unicode-ident"
version = "1.0.7"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "775c11906edafc97bc378816b94585fbd9a054eabaf86fdd0ced94af449efab7"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"

@@ -929,7 +1007,7 @@ [[package]]

name = "winnow"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c95fb4ff192527911dd18eb138ac30908e7165b8944e528b6af93aa4c842d345"
checksum = "ee7b2c67f962bf5042bfd8b6a916178df33a26eec343ae064cb8e069f638fa6f"
dependencies = [
"memchr",
]
+2
-1
[package]
name = "quickner"
version = "0.0.1-alpha.15"
version = "0.0.1-alpha.16"
edition = "2021"

@@ -24,1 +24,2 @@ authors = ["Omar MHAIMDAT"]

serde = { version = "1.0.130", features = ["derive"] }
numpy = "0.18"
[package]
name = "quickner-core"
version = "0.0.1-alpha.15"
version = "0.0.1-alpha.16"
edition = "2021"

@@ -5,0 +5,0 @@ authors = ["Omar MHAIMDAT"]

Metadata-Version: 2.1
Name: quickner
Version: 0.0.1a15
Version: 0.0.1a16
Classifier: Programming Language :: Rust

@@ -5,0 +5,0 @@ Classifier: Programming Language :: Python :: Implementation :: CPython

@@ -14,3 +14,2 @@ [build-system]

[project.scripts]

@@ -17,0 +16,0 @@ Quickner = "quickner:Quickner"

@@ -312,14 +312,2 @@ from ast import Dict

def add_string(self, string: str) -> None:
"""
Add a string to the list of documents.
Parameters:
string (str): String to add.
Returns:
None
"""
...
def add_entity(self, entity: Entity) -> None:

@@ -362,1 +350,10 @@ """

...
def numpy(self) -> NDArray:
"""
Convert the list of documents to a Numpy array.
Returns:
NDArray: Numpy array of documents.
"""
...
use pyo3::prelude::*;
use pyquickner::QuicknerError;
mod pyconfig;

@@ -35,3 +36,4 @@ mod pydocument;

m.add_class::<pyentity::PyEntity>()?;
m.add("QuicknerError", _py.get_type::<QuicknerError>())?;
Ok(())
}

@@ -102,3 +102,6 @@ use crate::{

pub fn __repr__(&self) -> PyResult<String> {
let mut repr = format!("Document(id=\"{}\", text={}, label=[", self.id, self.text);
let mut repr = format!(
"Document(id=\"{}\", text=\"{}\", label=[",
self.id, self.text
);
for (start, end, label) in &self.label {

@@ -105,0 +108,0 @@ repr.push_str(&format!("({start}, {end}, {label}), "));

@@ -12,8 +12,13 @@ use std::collections::HashMap;

};
use numpy::PyArray2;
use pyo3::create_exception;
use pyo3::{
exceptions::{self, PyGeneratorExit},
prelude::*,
types::{PyDict, PyTuple},
};
use quickner::{Document, Entity, Quickner, SpacyEntity};
create_exception!(quickner, QuicknerError, exceptions::PyException);
#[pyclass(name = "Quickner")]

@@ -135,8 +140,2 @@ pub struct PyQuickner {

pub fn add_string(&mut self, text: &str) {
let document = Document::from_string(text.to_string());
self.quickner.add_document(document.clone());
self.add_document(PyDocument::from(document));
}
pub fn add_entity(&mut self, entity: PyEntity) {

@@ -365,2 +364,70 @@ // Check if the entity is already in the list

}
/// Convert Vec<Document> to numpy array of (string, array of (int, int, string))
/// where the first int is the start index and the second int is the end index
/// of the entity in the string.
/// The string is the text of the document.
/// The array of (int, int, string) is the list of entities in the document.
/// Return a numpy array like so: array(['rust is made by Mozilla', list([(0, 4, 'PL'), (16, 23, 'ORG')])], dtype=object)
/// And type is numpy.ndarray
// pub fn numpy(&self) -> Py<PyArray1<PyObject>> {
// Python::with_gil(|py| {
// let numpy = PyModule::import(py, "numpy").unwrap();
// let array = numpy.getattr("array").unwrap();
// let array = array.call1((self.documents.clone(),)).unwrap();
// array.extract().unwrap()
// })
// }
pub fn numpy(&self) -> PyResult<Py<PyArray2<PyObject>>> {
Python::with_gil(|py| {
let numpy = PyModule::import(py, "numpy").unwrap();
let array = numpy.getattr("array").unwrap();
let object: Vec<&PyTuple> = self
.documents
.iter()
.map(|document| {
let entities: Vec<&PyTuple> = document
.label
.iter()
.map(|entity| {
PyTuple::new(
py,
&[
entity.0.to_object(py),
entity.1.to_object(py),
entity.2.clone().to_object(py),
],
)
})
.collect();
PyTuple::new(
py,
&[
document.id.clone().to_object(py),
document.text.clone().to_object(py),
entities.to_object(py),
],
)
})
.collect::<Vec<&PyTuple>>();
let args = PyDict::new(py);
args.set_item("dtype", "object").unwrap();
let array = array.call((object,), Some(args));
if let Ok(array) = array {
let array = array.extract::<Py<PyArray2<PyObject>>>();
match array {
Ok(array) => Ok(array),
Err(array) => {
// Raise an exception QuicknerError
Err(PyErr::new::<QuicknerError, _>(array.to_string()))
}
}
} else {
let array = array.unwrap_err();
// Raise an exception QuicknerError
Err(PyErr::new::<QuicknerError, _>(array.to_string()))
}
})
}
}

@@ -367,0 +434,0 @@