-
Notifications
You must be signed in to change notification settings - Fork 6
Release v1.0 #60
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
Open
harisalam
wants to merge
26
commits into
master
Choose a base branch
from
release-v1.0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Release v1.0 #60
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2acac88
KWIC2
jackzhenguo 418b3fb
KWIC2
jackzhenguo ee40b0c
show all sentences labled after clustering
jackzhenguo 16d2355
KWIC-finish
jackzhenguo 01ebaf9
Merge branch 'KWIC' into cluster-show-update
jackzhenguo 0d0b122
app.py
jackzhenguo 88a2f6c
cluster show
jackzhenguo 694faec
sprint of new features
jackzhenguo 0dab771
update gitignore
jackzhenguo 91891fc
fix a score bug
jackzhenguo cce031d
merge bert cluster model and corresponding update
jackzhenguo e346d02
cluster count and sentence count
jackzhenguo b10b19a
merge from dev and fix some conflicts
jackzhenguo bf54b9a
cluster condition
jackzhenguo 42a6440
new feature:flash message prompt
jackzhenguo 6e2c20b
Merge branch 'f-flash-html' into dev
jackzhenguo feb2e6c
KIWC integration to js and html
jackzhenguo d421800
KWIC-highlight all selected word
jackzhenguo a9d64b5
KWIC for selected word when appearing mulitple times
jackzhenguo 789d4b6
KWIC3
jackzhenguo 164a6ec
udp-kwic2
jackzhenguo 4e9618d
Add or update the Azure App Service build and deployment workflow config
hvkone c6eb2d2
Remove the Azure App Service build and deployment workflow config
hvkone e0d354c
Add or update the Azure App Service build and deployment workflow config
hvkone b5b959f
Remove the Azure App Service build and deployment workflow config
hvkone b0cd260
Add or update the App Service deployment workflow configuration from …
hvkone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | ||
| # More GitHub Actions for Azure: https://github.com/Azure/actions | ||
| # More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions | ||
|
|
||
| name: Build and deploy Python app to Azure Web App - psdwordfinder | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - release-v1.0 | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Python version | ||
| uses: actions/setup-python@v1 | ||
| with: | ||
| python-version: '3.8' | ||
|
|
||
| - name: Create and start virtual environment | ||
| run: | | ||
| python -m venv venv | ||
| source venv/bin/activate | ||
|
|
||
| - name: Install dependencies | ||
| run: pip install -r requirements.txt | ||
|
|
||
| # Optional: Add step to run tests here (PyTest, Django test suites, etc.) | ||
|
|
||
| - name: Upload artifact for deployment jobs | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: python-app | ||
| path: | | ||
| . | ||
| !venv/ | ||
|
|
||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| environment: | ||
| name: 'production' | ||
| url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
|
|
||
| steps: | ||
| - name: Download artifact from build job | ||
| uses: actions/download-artifact@v2 | ||
| with: | ||
| name: python-app | ||
| path: . | ||
|
|
||
| - name: 'Deploy to Azure Web App' | ||
| uses: azure/webapps-deploy@v2 | ||
| with: | ||
| app-name: 'psdwordfinder' | ||
| slot-name: 'production' | ||
| publish-profile: ${{ secrets.AzureAppService_PublishProfile_fba125a4de7c454cbe8f4c98c4017480 }} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,5 @@ | |
| .idea | ||
| input | ||
| __pycache__ | ||
| psd_project.sql | ||
| log/ | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,10 +13,19 @@ | |
|
|
||
| from src.train.result_model import TResult | ||
| from src.train.store import StoreData | ||
| from src.util import * | ||
| from src.util import (language_dict, | ||
| language_list, | ||
| db_config, | ||
| corpus_language, | ||
| udpipe_language, | ||
| get_keyword_window) | ||
| from src.train.train_cluster import load_model | ||
| from src.train.train_model import UdpipeTrain | ||
| from src.train.cluster import Evaluator | ||
| import re | ||
| from src.train.KWIC import keywords_in_context, find_and_replace | ||
| from src.util import get_keyword_window, kwic_show | ||
|
|
||
|
|
||
| try: | ||
| store_data = StoreData(db_config['user'], | ||
|
|
@@ -110,14 +119,14 @@ def cluster_sentences(self, language_name: str, save_path: str, sentences: List[ | |
| n_clusters = int(n_clusters) | ||
| if n_clusters <= 0: | ||
| print("Parameter is Invalid") | ||
| return | ||
| return [None]*4 | ||
| if n_clusters > len(sentences): | ||
| # TODO add log | ||
| print('number of cluster bigger than sentences count') | ||
| return | ||
| return [None]*4 | ||
| if len(self.sel_result) <= 0: | ||
| print('no sentence') | ||
| return | ||
| return [None]*4 | ||
| # first loading model | ||
| word2vec_model = load_model(save_path) | ||
| # second geting vectors for one sentence | ||
|
|
@@ -176,7 +185,36 @@ def cluster_sentences(self, language_name: str, save_path: str, sentences: List[ | |
| if no_n_input: | ||
| examples = recommend_sentences | ||
|
|
||
| return examples, recommend_sentences | ||
| return examples, recommend_sentences, sentences, best_labels | ||
|
|
||
| def kwic(self, selword: str, sentence_with_pos: list): | ||
| """ | ||
| :param: selword | ||
| :param: sentenceWithPOS | ||
|
|
||
| sentence_with_pos examples: | ||
| [("NOUN", "bank", ["I go to the bank", "The house lies the right of the river bank"]), | ||
| ("VERB", "bank", ["I banked in a slot"]) | ||
| """ | ||
| # This is similar to sentenceWithPOS but processed after KWIC | ||
| result = [] | ||
| for sentTuple in sentence_with_pos: | ||
| sents_kwic = [] | ||
| result.append((sentTuple[0], sentTuple[1], sentTuple[2], sents_kwic)) | ||
|
|
||
| sents_origin = sentTuple[2] | ||
| for sent in sents_origin: | ||
| # result_text = keywords_in_context(sent, [selword]) | ||
| # Highlight Keywords | ||
| # result_text = find_and_replace(result_text, selword, "\x1b[34m" + selword + "\x1b[0m") | ||
| # sents_kwic.append(result_text) | ||
| window_words = get_keyword_window(selword, sent.split(" ")) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can merge these two functions in a single function which I uploaded in my last pull request for more efficiency. |
||
| result_text = kwic_show(window_words, selword) | ||
| if result_text: | ||
| print(result_text) | ||
| sents_kwic.append(result_text) | ||
|
|
||
| return result | ||
|
|
||
| def _get_examples(self, sentences: List[str], best_labels, n_clusters: int): | ||
| tmp_labels, examples = [], [] | ||
|
|
@@ -196,6 +234,12 @@ def _get_examples(self, sentences: List[str], best_labels, n_clusters: int): | |
| return examples | ||
|
|
||
|
|
||
| class AppContext(object): | ||
| sel_language = None | ||
| sel_word = None | ||
| sel_result_kwic = None | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # get word vector for one sentence | ||
| language_name = 'English' | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code inside this function is the same as the function above. How about if we can make it generic and make it work using a single function.