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
import subprocess | |
from flask import Flask, Response | |
app = Flask(__name__) | |
@app.route("/interactive") | |
def interactive(): | |
def generator(): |
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
import subprocess | |
def main(): | |
proc = subprocess.Popen(["python3", "p2.py"], stdout=subprocess.PIPE) | |
while True: | |
line = proc.stdout.readline().rstrip() | |
if not line: | |
break | |
print(line) |
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 rita.engine.translate_standalone import RuleExecutor | |
text = "Hello there!" | |
patterns = RuleExecutor.load("output-regex.jsonl") | |
print(list(patterns.execute(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
import spacy | |
from spacy.pipeline import EntityRuler | |
nlp = spacy.load("en") | |
ruler = EntityRuler(nlp, overwrite_ents=True) | |
ruler.from_disk("output.jsonl") | |
nlp.add_pipe(ruler) | |
doc = nlp(text) | |
for e in doc.ents: |
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
import sys | |
import argparse | |
import spacy | |
from rita.shortcuts import setup_spacy | |
def main(args): | |
nlp = spacy.load("en") | |
setup_spacy(nlp, rules_path=args.script) | |
for line in sys.stdin: |
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
greetings = {"hello", "hi", "hola"} | |
time_of_day = {"morning", "evening", "afternoon", "day"} | |
usual_suspects = {"life", "wife", "kids", "job"} | |
IN_LIST(greetings)->MARK("GREETING") | |
{WORD("GOOD"), IN_LIST(time_of_day)}->MARK("GREETING") | |
{WORD("How are you doing?")}->MARK("WHATS_UP") | |
{WORD("How"), WORD?, WORD("the"), WORD("weather")}->MARK("WEATHER_QUESTION") | |
{WORD("How"), WORD?, WORD("your")?, IN_LIST(usual_suspects)}->MARK("WHATS_UP") |
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
greetings = {"hello", "hi", "hola"} | |
time_of_day = {"morning", "evening", "afternoon", "day"} | |
IN_LIST(greetings)->MARK("GREETING") | |
{WORD("GOOD"), IN_LIST(time_of_day)}->MARK("GREETING") | |
{WORD("How are you doing?")}->MARK("WHATS_UP") | |
{WORD("How"), WORD?, WORD("the"), WORD("weather")}->MARK("WEATHER_QUESTION") |
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
greetings = {"hello", "hi", "hola"} | |
time_of_day = {"morning", "evening", "afternoon", "day"} | |
IN_LIST(greetings)->MARK("GREETING") | |
{WORD("GOOD"), IN_LIST(time_of_day)}->MARK("GREETING") | |
{WORD("How are you doing?")}->MARK("WHATS_UP") |
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
greetings = {"hello", "hi", "hola"} | |
time_of_day = {"morning", "evening", "afternoon", "day"} | |
IN_LIST(greetings)->MARK("GREETING") | |
{WORD("GOOD"), IN_LIST(time_of_day)}->MARK("GREETING") |
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
greetings = {"hello", "hi", "hola", "good morning", "good evening", "good afternoon", "good day"} | |
IN_LIST(greetings)->MARK("GREETING") |
NewerOlder