This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def extract_span_start_end_positions(text: str, spans: List[str]): | |
""" | |
Extract positions of indicated spans from indicated text. | |
Adapted from : https://www.programcreek.com/python/?CodeExample=convert+to+spans | |
Args: | |
text: The string to be searched | |
spans: The spans of interest within the string. Can be single or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
import time | |
from random import randint | |
def scrape_news_summaries(s): | |
# It is based on a notebook posted on Kaggle, http://bit.ly/1VJ8pF9 | |
time.sleep( randint(0,2) ) #relax and don't let google be angry | |
r = requests.get("http://www.google.co.uk/search?q="+s+"&tbm=nws") | |
content = r.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.nirmalya.util.ipaddr; | |
import java.io.InputStream; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Random; | |
import java.util.Scanner; | |
import org.apache.commons.net.util.SubnetUtils; | |
import org.slf4j.Logger; |