# Path: beancount_import/matching.py
# def is_unknown_account(account: str):
#     return account == FIXME_ACCOUNT or account.startswith(
#         MERGEABLE_FIXME_ACCOUNT_PREFIX)
# 
# FIXME_ACCOUNT = 'Expenses:FIXME'
# 
# Path: beancount_import/posting_date.py
# def get_posting_date(entry, posting):
#     """Returns the date associated with a posting."""
#     return ((posting.meta and (posting.meta.get(POSTING_DATE_KEY) or
#                                posting.meta.get(POSTING_TRANSACTION_DATE_KEY))) or entry.date)


import collections
import datetime
import functools
import itertools
import re
from typing import Callable, Any, Dict, Iterable, List, NamedTuple, Sequence, Union, Optional, Tuple, Set
from beancount.core.data import Directive, Entries, Transaction, Posting
from beancount.core.amount import Amount
from .matching import is_unknown_account, FIXME_ACCOUNT
from .posting_date import get_posting_date
    from .source import Source  # For typing only.
    def add(self, example: PredictionInput, target_account: str):
        self.training_examples.append((get_features(example), target_account))


class MockTrainingExamples(object):
    def __init__(self):
        self.examples = []  # type: List[Tuple[PredictionInput, str]]

    def add(self, prediction_input: PredictionInput,
            target_account: str) -> None:
        self.examples.append((prediction_input, target_account))


TrainingExamplesInterface = Union[TrainingExamples, MockTrainingExamples]


def get_unknown_account_postings(transaction: Transaction) -> List[Posting]:
    return [
        posting for posting in transaction.postings
        if is_unknown_account(posting.account)
    ]


def get_unknown_account_group_numbers(transaction: Transaction) -> List[int]:
    num_groups = 0
    group_numbers = []
    existing_groups = {}  # type: Dict[str, int]
    for posting in transaction.postings:
        if not is_unknown_account(posting.account):
            continue

# Path: beancount_import/matching.py
# def is_unknown_account(account: str):
#     return account == FIXME_ACCOUNT or account.startswith(
#         MERGEABLE_FIXME_ACCOUNT_PREFIX)
# 
# FIXME_ACCOUNT = 'Expenses:FIXME'
# 
# Path: beancount_import/posting_date.py
# def get_posting_date(entry, posting):
#     """Returns the date associated with a posting."""
#     return ((posting.meta and (posting.meta.get(POSTING_DATE_KEY) or
#                                posting.meta.get(POSTING_TRANSACTION_DATE_KEY))) or entry.date)


# Path: beancount_import/training.py
import collections
import datetime
import functools
import itertools
import re
from typing import Callable, Any, Dict, Iterable, List, NamedTuple, Sequence, Union, Optional, Tuple, Set
from beancount.core.data import Directive, Entries, Transaction, Posting
from beancount.core.amount import Amount
from .matching import is_unknown_account, FIXME_ACCOUNT
from .posting_date import get_posting_date
    from .source import Source  # For typing only.

    def add(self, example: PredictionInput, target_account: str):
        self.training_examples.append((get_features(example), target_account))


class MockTrainingExamples(object):
    def __init__(self):
        self.examples = []  # type: List[Tuple[PredictionInput, str]]

    def add(self, prediction_input: PredictionInput,
            target_account: str) -> None:
        self.examples.append((prediction_input, target_account))


TrainingExamplesInterface = Union[TrainingExamples, MockTrainingExamples]


def get_unknown_account_postings(transaction: Transaction) -> List[Posting]:
    return [
        posting for posting in transaction.postings
        if is_unknown_account(posting.account)
    ]


def get_unknown_account_group_numbers(transaction: Transaction) -> List[int]:
    num_groups = 0
    group_numbers = []
    existing_groups = {}  # type: Dict[str, int]
    for posting in transaction.postings:
        if not is_unknown_account(posting.account):
            continue

        if posting.account == FIXME_ACCOUNT: