Skip to content

Commit

Permalink
rename privacy_policy_analyzer package to poligrapher
Browse files Browse the repository at this point in the history
  • Loading branch information
cuihaoleo committed Jun 9, 2023
1 parent 057bb0a commit bcce4b8
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ stats/
figs/
# cProfile data
profile*.bin

# Extra data, distributed separately
*/extra-data/entity_info.json
*/extra-data/named_entity_recognition/
*/extra-data/purpose_classification/
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include poligrapher/extra-data/ *
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ dependencies:
- spacy-legacy=3.0.12=pyhd8ed1ab_0
- spacy-loggers=1.0.1=pyhd3eb1b0_0
- spacy-model-en_core_web_lg=3.5.0=pyhd8ed1ab_0
- spacy-model-en_core_web_md=3.5.0=pyhd8ed1ab_0
- spacy-model-en_core_web_sm=3.5.0=pyhd8ed1ab_0
- spacy-model-en_core_web_trf=3.5.0=pyh55bf090_0
- spacy-transformers=1.2.4=py310hfb6f7a9_0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from spacy.tokens import Token
from privacy_policy_analyzer import utils
from . import utils

Token.set_extension("src", getter=utils.token_to_source)
Token.set_extension("ent", getter=utils.token_to_ent)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import yaml
from spacy.tokens import Token

import privacy_policy_analyzer
import poligrapher

from .base import BaseAnnotator

Expand Down Expand Up @@ -341,7 +341,7 @@ class CollectionAnnotator(BaseAnnotator):
def __init__(self, nlp):
super().__init__(nlp)

with pkg_resources.open_text(privacy_policy_analyzer, "verb_patterns.yml") as fin:
with pkg_resources.open_text(poligrapher, "verb_patterns.yml") as fin:
config = yaml.safe_load(fin)

token_map = config["token_map"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import regex

from privacy_policy_analyzer.utils import TRIVIAL_WORDS
from .utils import TRIVIAL_WORDS


TRIM_TRANSITIONS = {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env python3

import argparse
from collections import defaultdict, deque
import importlib.resources as pkg_resources
import itertools
import logging
import os
from collections import defaultdict, deque

import networkx as nx
import yaml

from privacy_policy_analyzer.annotators import CollectionAnnotator
from privacy_policy_analyzer.document import PolicyDocument, SegmentType
from privacy_policy_analyzer.graph_utils import yaml_dump_graph, contracted_nodes
from privacy_policy_analyzer.phrase_normalization import EntityMatcher, RuleBasedPhraseNormalizer
from privacy_policy_analyzer.purpose_classification import PurposeClassifier
from privacy_policy_analyzer.utils import setup_nlp_pipeline
import poligrapher
from poligrapher.annotators import CollectionAnnotator
from poligrapher.document import PolicyDocument, SegmentType
from poligrapher.graph_utils import contracted_nodes, yaml_dump_graph
from poligrapher.phrase_normalization import EntityMatcher, RuleBasedPhraseNormalizer
from poligrapher.purpose_classification import PurposeClassifier
from poligrapher.utils import setup_nlp_pipeline


def dag_add_edge(G, n1, n2, *args, **kwargs):
Expand Down Expand Up @@ -447,14 +449,21 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("--nlp", required=True, help="NLP model directory")
parser.add_argument("--purpose-classification", required=True, help="Purpose classification model directory")
parser.add_argument("-p", "--phrase-map", required=True, help="Path to phrase_map.yml")
parser.add_argument("-e", "--entity-info", required=True, help="Path to entity_info.json")
parser.add_argument("-p", "--phrase-map", default="", help="Path to phrase_map.yml")
parser.add_argument("-e", "--entity-info", default="", help="Path to entity_info.json")
parser.add_argument("-v", "--variant", choices=["default", "original", "policylint", "per_section"],
default="default", help="Variant of the graph")
parser.add_argument("--pretty", action="store_true", help="Generate pretty GraphML graph for visualization")
parser.add_argument("workdirs", nargs="+", help="Input directories")
args = parser.parse_args()

with pkg_resources.path(poligrapher, "extra-data") as extra_data:
if not args.phrase_map:
args.phrase_map = extra_data / "phrase_map.yml"

if not args.entity_info:
args.entity_info = extra_data / "entity_info.json"

nlp = setup_nlp_pipeline(args.nlp)
graph_builder = GraphBuilder(args.phrase_map, args.entity_info, args.purpose_classification, args.variant)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import spacy
import torch

from privacy_policy_analyzer.document import PolicyDocument
from privacy_policy_analyzer.utils import setup_nlp_pipeline
from poligrapher.document import PolicyDocument
from poligrapher.utils import setup_nlp_pipeline


def main():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import argparse
import logging

from privacy_policy_analyzer.annotators import (
from poligrapher.annotators import (
CollectionAnnotator,
CoreferenceAnnotator,
ListAnnotator,
PurposeAnnotator,
SubsumptionAnnotator,
SubjectAnnotator,
)
from privacy_policy_analyzer.document import PolicyDocument
from privacy_policy_analyzer.utils import setup_nlp_pipeline
from poligrapher.document import PolicyDocument
from poligrapher.utils import setup_nlp_pipeline


def main():
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from setuptools import setup

setup(
name='Privacy Policy Analyzer',
name='poligrapher',
author='UCI Networking Group',
packages=['privacy_policy_analyzer'],
include_package_data=True,
packages=['poligrapher', 'poligrapher.annotators', 'poligrapher.scripts'],
)

0 comments on commit bcce4b8

Please sign in to comment.