Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added add_keywords_from_file_dict function #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rudrashisgorai
Copy link

To add keywords from a file in the form key-value map.
The idea was to read a list from the file in the form of key and value (in the form of list).

    Args:
        keyword_file : path to keywords file
        sep : unique separator for each line of the the keyword_file
        encoding : specify the encoding of the file

    Examples:
        keywords file format can be like: 
        Each line contains a new key value pair and has a single separator . 
        Separator should be unique in lines. 
        Value is in form of a list.
        Quotation marks only required for values in the value list.

        >>> # Option 1: config.txt content 
        >>> # key inv single = ['invoice'] 
        >>> # key_inv_number = ['invoice number', 'invoice no', 'invoice #', 'invoice#'] 
        >>> # key inv_date = ['invoice date', 'invoice dt', 'issue date', 'date of invoice', 'date of issue', 'issue dt', 'dt of issue'] 


        >>> keyword_processor.add_keywords_from_file_dict('config.txt' ,sep='=')

    Raises:
        IOError: If `keyword_file` path is not valid.
        AttributeError: No separator provided in the line. Value of key should be a list.
        AttributeError: Multiple separators present or choose a unique for the lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant