Преглед на файлове

first proper commit

master
theserpentjew преди 3 месеца
родител
ревизия
76ab90c104
променени са 5 файла, в които са добавени 32804 реда и са изтрити 0 реда
  1. +9
    -0
      Cargo.toml
  2. +36
    -0
      examples/basic.rs
  3. +43
    -0
      examples/neocon.txt
  4. +32494
    -0
      src/jews.txt
  5. +222
    -0
      src/lib.rs

+ 9
- 0
Cargo.toml Целия файл

@@ -0,0 +1,9 @@
[package]
name = "coincidence"
version = "1.4.88"
authors = ["Jacob Goldberg <j.goldberg@mossad.gov.il>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

+ 36
- 0
examples/basic.rs Целия файл

@@ -0,0 +1,36 @@
use coincidence::*;
use std::io::Read;

fn main() {
let mut args = std::env::args();

if let Some(filepath) = args.nth(1) {
let jewlist = get_jew_list();

let mut file = std::fs::File::open(filepath).expect("you fucked up the filepath retard");
let mut buf = String::new();

file.read_to_string(&mut buf)
.expect("somehow failed to read from string");

let spans: Vec<Span> = Detector::new(&buf, &jewlist).collect();

for (idx, c) in buf.char_indices() {
let mut is_jewish = false;

for span in &spans {
if idx >= span.start && idx <= span.end {
is_jewish = true;
break;
}
}

let color = if is_jewish { "\x1b[31m" } else { "\x1b[0m" };

print!("{}{}", color, c);
}
} else {
print!("Nice argument retard");
}
println!();
}

+ 43
- 0
examples/neocon.txt Целия файл

@@ -0,0 +1,43 @@
2000s
Administration of George W. Bush
The Bush campaign and the early Bush administration did not exhibit strong endorsement of neoconservative principles. As a presidential candidate, Bush had argued for a restrained foreign policy, stating his opposition to the idea of nation-building[60] and an early foreign policy confrontation with China was managed without the vociferousness suggested by some neoconservatives.[61] Also early in the administration, some neoconservatives criticized Bush's administration as insufficiently supportive of Israel and suggested Bush's foreign policies were not substantially different from those of President Clinton.[62]


During November 2010, former U.S. President George W. Bush (here with the former President of Egypt Hosni Mubarak at Camp David in 2002) wrote in his memoir Decision Points that Mubarak endorsed the administration's position that Iraq had WMDs before the war with the country, but kept it private for fear of "inciting the Arab street"[63]
Bush's policies changed dramatically immediately after the 11 September 2001 attacks.

During Bush's State of the Union speech of January 2002, he named Iraq, Iran and North Korea as states that "constitute an axis of evil" and "pose a grave and growing danger". Bush suggested the possibility of preemptive war: "I will not wait on events, while dangers gather. I will not stand by, as peril draws closer and closer. The United States of America will not permit the world's most dangerous regimes to threaten us with the world's most destructive weapons".[64][65]

Some major defense and national-security persons have been quite critical of what they believed was a neoconservative influence in getting the United States to go to war against Iraq.[66]

Former Nebraska Republican U.S. senator and Secretary of Defense, Chuck Hagel, who has been critical of the Bush administration's adoption of neoconservative ideology, in his book America: Our Next Chapter wrote:
So why did we invade Iraq? I believe it was the triumph of the so-called neo-conservative ideology, as well as Bush administration arrogance and incompetence that took America into this war of choice. ... They obviously made a convincing case to a president with very limited national security and foreign policy experience, who keenly felt the burden of leading the nation in the wake of the deadliest terrorist attack ever on American soil.

Bush Doctrine

President Bush meets with Secretary of Defense Donald Rumsfeld and his staff at the Pentagon, 14 August 2006
The Bush Doctrine of preemptive war was stated explicitly in the National Security Council (NSC) text "National Security Strategy of the United States". published 20 September 2002: "We must deter and defend against the threat before it is unleashed ... even if uncertainty remains as to the time and place of the enemy's attack. ... The United States will, if necessary, act preemptively".[67]

The choice not to use the word "preventive" in the 2002 National Security Strategy and instead use the word "preemptive" was largely in anticipation of the widely perceived illegality of preventive attacks in international law via both Charter Law and Customary Law.[68]

Policy analysts noted that the Bush Doctrine as stated in the 2002 NSC document had a strong resemblance to recommendations presented originally in a controversial Defense Planning Guidance draft written during 1992 by Paul Wolfowitz, during the first Bush administration.[69]

The Bush Doctrine was greeted with accolades by many neoconservatives. When asked whether he agreed with the Bush Doctrine, Max Boot said he did and that "I think [Bush is] exactly right to say we can't sit back and wait for the next terrorist strike on Manhattan. We have to go out and stop the terrorists overseas. We have to play the role of the global policeman. ... But I also argue that we ought to go further".[70] Discussing the significance of the Bush Doctrine, neoconservative writer Bill Kristol claimed: "The world is a mess. And, I think, it's very much to Bush's credit that he's gotten serious about dealing with it. ... The danger is not that we're going to do too much. The danger is that we're going to do too little".[71]

2008 presidential election and aftermath

President George W. Bush and Senator John McCain at the White House, 5 March 2008, after McCain became the Republican presumptive presidential nominee
John McCain, who was the Republican candidate for the 2008 United States presidential election, endorsed continuing the second Iraq War, "the issue that is most clearly identified with the neoconservatives". The New York Times reported further that his foreign policy views combined elements of neoconservatism and the main competing conservative opinion, pragmatism, also known as realism:[72]
Among [McCain's advisers] are several prominent neoconservatives, including Robert Kagan ... [and] Max Boot... 'It may be too strong a term to say a fight is going on over John McCain's soul,' said Lawrence Eagleburger ... who is a member of the pragmatist camp, ... [but he] said, "there is no question that a lot of my far right friends have now decided that since you can't beat him, let's persuade him to slide over as best we can on these critical issues.

Barack Obama campaigned for the Democratic nomination during 2008 by attacking his opponents, especially Hillary Clinton, for originally endorsing Bush's Iraq-war policies.
Obama maintained a selection of prominent military officials from the Bush Administration including Robert Gates (Bush's Defense Secretary) and David Petraeus (Bush's ranking general in Iraq).

2010s
By 2010, U.S. forces had switched from combat to a training role in Iraq and they left in 2011.
The neocons had little influence in the Obama White House, and neo-conservatives have lost much influence in the Republican party since the rise of Tea Party Movement.

Several neoconservatives played a major role in the Stop Trump movement in 2016, in opposition to the Republican presidential candidacy of Donald Trump, due to his criticism of interventionist foreign policies, as well as their perception of him as an "authoritarian" figure.
Since Trump took office, some neoconservatives have joined his administration, such as Elliott Abrams.
Neoconservatives have supported the Trump administration's hawkish approach towards Iran and Venezuela,
while opposing the administration's withdrawal of troops from Syria[80] and diplomatic outreach to North Korea.

+ 32494
- 0
src/jews.txt
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 222
- 0
src/lib.rs Целия файл

@@ -0,0 +1,222 @@
use std::slice::Iter;

#[derive(Debug)]
pub struct Span {
pub start: usize,
pub end: usize,
pub what: String,
}

impl Span {
pub fn new(start: usize, end: usize, what: String) -> Span {
Span { start, end, what }
}
}

pub struct Detector<'a> {
source: &'a str,
coincidences: &'a Vec<&'a str>,
coincidence_iter: Iter<'a, &'a str>,
last_spans: Vec<Span>,
}

impl Detector<'_> {
pub fn new<'a>(input: &'a str, coincidences: &'a Vec<&'a str>) -> Detector<'a> {
Detector {
source: input,
coincidences,
coincidence_iter: coincidences.iter(),
last_spans: Vec::new(),
}
}
}

const JEWS: &'static str = include_str!("jews.txt");

pub fn get_jew_list() -> Vec<&'static str> {
JEWS.split('\n').collect()
}

impl Iterator for Detector<'_> {
type Item = Span;

fn next(&mut self) -> Option<Self::Item> {
loop {
if self.last_spans.is_empty() {
let coincidence = self.coincidence_iter.next();
if let Some(coincidence) = coincidence {
let mut spans = self
.source
.to_lowercase()
.rmatch_indices(&coincidence.to_lowercase())
.map(|(idx, str)| {
Span::new(
idx,
idx + str.len() - 1,
self.source[idx..(idx + str.len())].to_string(),
)
})
.collect();

self.last_spans.append(&mut spans);
continue;
} else {
break None;
}
} else {
break self.last_spans.pop();
}
}
}
}

#[cfg(test)]
mod tests {
use crate::{get_jew_list, Detector};

#[test]
fn exact() {
let text = "Who is responsible for 9/11?";
let coincidences = vec!["Who"];

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "Who", "span contains invalid string");
assert_eq!(jew.start, 0, "span contains invalid start");
assert_eq!(jew.end, 2, "span contains invalid end");

assert!(detector.next().is_none(), "detector returned something");
}

#[test]
fn coincidence_lower() {
let text = "Who is responsible for 9/11?";
let coincidences = vec!["who"];

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "Who", "span contains invalid string");
assert_eq!(jew.start, 0, "span contains invalid start");
assert_eq!(jew.end, 2, "span contains invalid end");
}

#[test]
fn coincidence_upper() {
let text = "Who is responsible for 9/11?";
let coincidences = vec!["WHO"];

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "Who", "span contains invalid string");
assert_eq!(jew.start, 0, "span contains invalid start");
assert_eq!(jew.end, 2, "span contains invalid end");
}

#[test]
fn source_upper() {
let text = "WHO is responsible for 9/11?";
let coincidences = vec!["Who"];

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "WHO", "span contains invalid string");
assert_eq!(jew.start, 0, "span contains invalid start");
assert_eq!(jew.end, 2, "span contains invalid end");
}

#[test]
fn source_lower() {
let text = "who is responsible for 9/11?";
let coincidences = vec!["Who"];

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "who", "span contains invalid string");
assert_eq!(jew.start, 0, "span contains invalid start");
assert_eq!(jew.end, 2, "span contains invalid end");
}

#[test]
fn source_multiple_same() {
let text = "Who is responsible for 9/11? the WHO is responsible for 9/11.";
let coincidences = vec!["Who"];

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "Who", "span contains invalid string");
assert_eq!(jew.start, 0, "span contains invalid start");
assert_eq!(jew.end, 2, "span contains invalid end");

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "WHO", "span contains invalid string");
assert_eq!(jew.start, 33, "span contains invalid start");
assert_eq!(jew.end, 35, "span contains invalid end");
}

#[test]
fn source_multiple_unique() {
let text = "Who is responsible for 9/11? Israel is responsible for 9/11.";
let coincidences = vec!["Who", "israel"];

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "Who", "span contains invalid string");
assert_eq!(jew.start, 0, "span contains invalid start");
assert_eq!(jew.end, 2, "span contains invalid end");

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "Israel", "span contains invalid string");
assert_eq!(jew.start, 29, "span contains invalid start");
assert_eq!(jew.end, 34, "span contains invalid end");
}

#[test]
fn try_jew_list() {
let text = "the most based man on earth, mark zuckerberg, created facebook";
let coincidences = get_jew_list();

let mut detector = Detector::new(text, &coincidences);

let jew = detector.next();
assert!(jew.is_some(), "detector returned none");

let jew = jew.unwrap();
assert_eq!(jew.what, "mark zuckerberg", "span contains invalid string");
assert_eq!(jew.start, 29, "span contains invalid start");
assert_eq!(jew.end, 43, "span contains invalid end");
}
}

Зареждане…
Отказ
Запис