diff --git a/etk/unit_tests/ground_truth/news.html b/etk/unit_tests/ground_truth/news.html new file mode 100644 index 00000000..702a6909 --- /dev/null +++ b/etk/unit_tests/ground_truth/news.html @@ -0,0 +1,298 @@ + + + + + + + + + + + + + + + + + + Iranian General Locks Horns With Trump, Escalating Threat-Filled Feud - The New York Times + + + + + + + + + + +

Advertisement

Iranian General Locks Horns With Trump, Escalating Threat-Filled Feud

Video
Maj. Gen. Qassim Suleimani, an influential Iranian military leader, ridiculed President Trump for his tweets threatening Iran’s president.Published OnCreditImage by Agence France-Presse — Getty Images

A powerful commander in Iran’s Revolutionary Guards Corps escalated the invective duel with President Trump on Thursday, calling his threat against Iran’s president “cabaret-style rhetoric” in remarks that political analysts called worrisome.

The commander, Maj. Gen. Qassim Suleimani, who wields enormous influence in Iran, may emerge as its future leader and is considered a terrorist mastermind by the United States. He said that Mr. Trump should pick a fight directly with him and not Iran’s president, Hassan Rouhani.

In a Twitter message on Sunday posted in all-capital letters, Mr. Trump warned Mr. Rouhani that he would suffer “consequences the likes of which few throughout history have ever suffered before” if he threatened the United States.

+

Top aides to Mr. Rouhani dismissed Mr. Trump’s warning, apparently viewing it as an attempt by the American president to replicate his strategy of threats against another adversary, North Korea.

But General Suleimani’s public challenge to Mr. Trump appeared to signal that the Iranian hierarchy felt obliged to send a more assertive reply.

“It is beneath the dignity of our president to respond to you,” General Suleimani said in a speech in western Iran reported by state-run media. “I, as a soldier, respond to you.”

Directly addressing Mr. Trump, General Suleimani said: “You threaten us with an action that is ‘unprecedented’ in the world. This is cabaret-style rhetoric. Only a cabaret owner talks to the world this way.”

Deriding what he described as the history of American military failures in Afghanistan, Iraq and elsewhere in the region, General Suleimani said Mr. Trump was in no position to issue threats to Iran.

“We are near you, where you can’t even imagine,” he said. “We are ready. We are the man of this arena.”

While the possibility of a war between Iran and the United States is considered extremely low, political analysts worry that escalating threats could lead to something more serious.

General Suleimani’s words and actions are closely scrutinized because he is regarded as one of Iran’s most cunning and autonomous military figures, in charge of its intelligence gathering and covert military operations.

“His fire-breathing retort to Trump is important and worrisome,” said Cliff Kupchan, chairman of the Eurasia Group, a political risk consultancy in Washington.

“Suleimani is directly mocking the U.S. president, and he lambastes U.S. policy,” Mr. Kupchan said. “Suleimani is telling Trump to watch his words, reminding him that Iran has both power across the Middle East and potent capability for asymmetric warfare. That’s an implicit threat against U.S. assets in the Middle East.”

A once-shadowy figure who now enjoys celebritylike status among the hard-line conservatives in Iran, General Suleimani leads the Islamic Revolutionary Guards Corps’ Quds Force, a special forces unit responsible for Iranian operations outside Iran’s borders. Quds is the Persian word for Jerusalem.

The general is known to have the personal backing of Iran’s supreme leader, Ayatollah Ali Khamenei, and is believed to be the chief strategist behind Iran’s military ventures and influence in Syria, Iraq and elsewhere in the region and beyond.

The United States has regarded General Suleimani as a vexing foe for many years. It accused him of plotting attacks on American soldiers in Iraq after the 2003 American-led invasion that toppled Saddam Hussein.

The Treasury Department placed him on a sanctions blacklist in 2011, accusing the commander of complicity in what American officials called a plot to kill the Saudi ambassador to Washington.

But the United States also has found itself in the awkward position of cooperating with General Suleimani in Iraq, where the Americans and Iranians have both worked to reverse gains made by the Islamic State.

He was in the northern Iraqi city of Tikrit in 2015, commanding Iraqi Shiite militias attempting to recapture it from Islamic State fighters before American warplanes belatedly joined that campaign.

Advertisement

Collapse

SEE MY OPTIONS

+ + + + + + + +
+ +
+ + + \ No newline at end of file diff --git a/etk/unit_tests/ground_truth/sample_spacy_rule.json b/etk/unit_tests/ground_truth/sample_spacy_rule.json new file mode 100644 index 00000000..682449d6 --- /dev/null +++ b/etk/unit_tests/ground_truth/sample_spacy_rule.json @@ -0,0 +1,170 @@ +{ + "rules": [ + { + "polarity": true, + "description": "", + "pattern": [ + { + "prefix": "", + "suffix": "", + "capitalization": [], + "part_of_speech": [], + "length": [], + "maximum": "", + "minimum": "", + "shapes": [], + "token": [ + "Iranian", + "General", + "Locks", + "Horns", + "With" + ], + "numbers": [], + "is_in_vocabulary": false, + "is_out_of_vocabulary": false, + "is_required": true, + "type": "word", + "is_in_output": false, + "match_all_forms": false, + "contain_digit": false + }, + { + "prefix": "", + "suffix": "", + "capitalization": [], + "part_of_speech": [], + "length": [], + "maximum": "", + "minimum": "", + "shapes": [], + "token": [ + "Trump" + ], + "numbers": [], + "is_in_vocabulary": false, + "is_out_of_vocabulary": false, + "is_required": true, + "type": "word", + "is_in_output": true, + "match_all_forms": false, + "contain_digit": false + } + ], + "output_format": "", + "is_active": true, + "dependencies": [], + "identifier": "current rule" + } + ], + "test_text": "Iranian General Locks Horns With Trump, Escalating Threat-Filled Feud - The New York Times", + "field_name": "dummy", + "test_tokens": [ + { + "index": 0, + "whitespace": " ", + "text": "Iranian" + }, + { + "index": 1, + "whitespace": " ", + "text": "General" + }, + { + "index": 2, + "whitespace": " ", + "text": "Locks" + }, + { + "index": 3, + "whitespace": " ", + "text": "Horns" + }, + { + "index": 4, + "whitespace": " ", + "text": "With" + }, + { + "index": 5, + "whitespace": "", + "text": "Trump" + }, + { + "index": 6, + "whitespace": " ", + "text": "," + }, + { + "index": 7, + "whitespace": " ", + "text": "Escalating" + }, + { + "index": 8, + "whitespace": "", + "text": "Threat" + }, + { + "index": 9, + "whitespace": "", + "text": "-" + }, + { + "index": 10, + "whitespace": " ", + "text": "Filled" + }, + { + "index": 11, + "whitespace": " ", + "text": "Feud" + }, + { + "index": 12, + "whitespace": " ", + "text": "-" + }, + { + "index": 13, + "whitespace": " ", + "text": "The" + }, + { + "index": 14, + "whitespace": " ", + "text": "New" + }, + { + "index": 15, + "whitespace": " ", + "text": "York" + }, + { + "index": 16, + "whitespace": "", + "text": "Times" + } + ], + "results": [ + { + "confidence": 1.0, + "start_token": 4, + "end_token": 6, + "start_char": 28, + "end_char": 38, + "identifier": "current rule", + "text": "Trump", + "token_based_match_mapping": { + "0": [ + 0, + 1 + ], + "1": [ + 1, + 2 + ] + } + } + ] +} \ No newline at end of file diff --git a/etk/unit_tests/test_spacy_rule_and_html_metadata.py b/etk/unit_tests/test_spacy_rule_and_html_metadata.py new file mode 100644 index 00000000..c0c4f535 --- /dev/null +++ b/etk/unit_tests/test_spacy_rule_and_html_metadata.py @@ -0,0 +1,26 @@ +import unittest +from etk.extractors.spacy_rule_extractor import SpacyRuleExtractor +import spacy +from etk.extractors.html_metadata_extractor import HTMLMetadataExtractor +import json + + +class TestSpacyRuleExtractor(unittest.TestCase): + + def test_SpacyRuleExtractor(self) -> None: + hme = HTMLMetadataExtractor() + with open('etk/unit_tests/ground_truth/news.html', 'r') as f: + sample_html = f.read() + + sample_rules = json.load(open('etk/unit_tests/ground_truth/sample_spacy_rule.json')) + + title_extraction = hme.extract(sample_html, extract_title=True)[0].value + + sample_rule_extractor = SpacyRuleExtractor(spacy.load("en_core_web_sm"), sample_rules, "dummy") + extractions = sample_rule_extractor.extract(title_extraction) + expected_extraction = 'Trump' + self.assertEqual(extractions[0].value, expected_extraction) + + +if __name__ == '__main__': + unittest.main()