<commit_before>swc-service
===========

### Intro
The REST web service generates visual represenations of [SWC files](http://research.mssm.edu/cnic/swc.html)    


### Installation

1. Install Maven [download](http://maven.apache.org/download.cgi)
2. Install Tomcat [download](http://maven.apache.org/download.cgi)
3. `git clone https://github.com/MPDL/swc-service`
4. Compile the service: go into `swc-service directory`, run `mvn clean install`
5. Copy `swc.war` in Tomcat `webapp` directory
6. Create file `swc-service.properties`, add following property in it

> `screenshot.service.url = base_url_to_screenshot_service/html-screenshot`

 and put the file into Tomcat `conf` directory

7. Start Tomcat
8. Service runs under `http://localhost:8080/swc`

### Usage

Following REST commands are implemented:

##### **Path**: /api/view
- **Method**: POST
- **Media type**: multipart/form-data
- **Input fields**: 
  - field 1:
    - **name**: file1
    - **type**: file
    - **value**: locally selected SWC file
  - field 2:
    - **name**: portable
    - **type**: text
    - **value**: true|false(default)
- **Response**:
Delivers HTML view representation of the SWC file. 
 
##### **Path**: /api/view
- **Method**: POST
- **Media type**: application/x-www-form-urlencoded
- **Input fields**: 
  - field 1:
    - **name**: swc
    - **type**: text/texarea
    - **value**: SWC text
  - field 2:
    - **name**: portable
    - **type**: text
    - **value**: true|false(default)
- **Response**:
Delivers HTML view representation of the SWC text. 

##### **Path**: /api/view
- **Method**: GET
- **Media type**: application/x-www-form-urlencoded
- **Input fields**: 
  - field 1:
    - **name**: url
    - **type**: text
    - **value**: link to the SWC URL
  - field 2:
    - **name**: portable
    - **type**: text
    - **value**: true|false(default)
- **Response**:
returns HTML view representation of the SWC text referenced by the URL. 

**Note:** Setting of `portable="true"` generates html which can be used offline.

##### **Path**: /api/thumb
- **Method**: POST
- **Media type**: multipart/form-data
- **Input fields**: 
  - field:
    - **name**: file1
    - **type**: file
    - **value**: locally selected SWC file
- **Response**:<commit_msg>Add analyze help<commit_after>swc-service
===========

### Intro
The REST web service generates visual represenations of [SWC files](http://research.mssm.edu/cnic/swc.html)    


### Installation

1. Install Maven [download](http://maven.apache.org/download.cgi)
2. Install Tomcat [download](http://maven.apache.org/download.cgi)
3. Install L-Measure [download](http://cng.gmu.edu/Lm/)
4. `git clone https://github.com/MPDL/swc-service`
5. Compile the service: go into `swc-service directory`, run `mvn clean install`
6. Copy `swc.war` in Tomcat `webapp` directory
7. Create file `swc-service.properties`, add following property in it

> `screenshot.service.url = base_url_to_screenshot_service/html-screenshot`

 and put the file into Tomcat `conf` directory

8. Start Tomcat
9. Service runs under `http://localhost:8080/swc`

### Usage

Following REST commands are implemented:

##### **Path**: /api/view
- **Method**: POST
- **Media type**: multipart/form-data
- **Input fields**: 
  - field 1:
    - **name**: file1
    - **type**: file
    - **value**: locally selected SWC file
  - field 2:
    - **name**: portable
    - **type**: text
    - **value**: true|false(default)
- **Response**:
Delivers HTML view representation of the SWC file. 
 
##### **Path**: /api/view
- **Method**: POST
- **Media type**: application/x-www-form-urlencoded
- **Input fields**: 
  - field 1:
    - **name**: swc
    - **type**: text/texarea
    - **value**: SWC text
  - field 2:
    - **name**: portable
    - **type**: text
    - **value**: true|false(default)
- **Response**:
Delivers HTML view representation of the SWC text. 

##### **Path**: /api/view
- **Method**: GET
- **Media type**: application/x-www-form-urlencoded
- **Input fields**: 
  - field 1:
    - **name**: url
    - **type**: text
    - **value**: link to the SWC URL
  - field 2:
    - **name**: portable
    - **type**: text
    - **value**: true|false(default)
- **Response**:
returns HTML view representation of the SWC text referenced by the URL. 

**Note:** Setting of `portable="true"` generates html which can be used offline.

##### **Path**: /api/analyze
- **Method**: POST
- **Media type**: multipart/form-data
- **Input fields**: 
  - field 1:
    - **name**: file1
    - **type**: file
    - **value**: locally selected SWC file
  - field 2:
    - **name**: numberOfBins
    - **type**: number
    - **value**: [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
  - field 3:
    - **name**: typeOfBins
    - **type**: text
    - **value**: number|width [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
  - field 3:
    - **name**: query
    - **type**: text
    - **value**: The L-Measure functions (for instance -f0,0,0,10.0 ) [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
- **Response**:
Delivers JSON File with the L-Measure result. 
 
##### **Path**: /api/analyze
- **Method**: POST
- **Media type**: application/x-www-form-urlencoded
- **Input fields**: 
  - field 1:
    - **name**: swc
    - **type**: text/texarea
    - **value**: SWC text
   - field 2:
    - **name**: numberOfBins
    - **type**: number
    - **value**: [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
  - field 3:
    - **name**: typeOfBins
    - **type**: text
    - **value**: number|width [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
  - field 3:
    - **name**: query
    - **type**: text
    - **value**: The L-Measure functions (for instance -f0,0,0,10.0 ) [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
- **Response**:
Delivers JSON File with the L-Measure result. 

##### **Path**: /api/analyze
- **Method**: GET
- **Media type**: application/x-www-form-urlencoded
- **Input fields**: 
  - field 1:
    - **name**: url
    - **type**: text
    - **value**: link to the SWC URL
   - field 2:
    - **name**: numberOfBins
    - **type**: number
    - **value**: [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
  - field 3:
    - **name**: typeOfBins
    - **type**: text
    - **value**: number|width [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
  - field 3:
    - **name**: query
    - **type**: text
    - **value**: The L-Measure functions (for instance -f0,0,0,10.0 ) [see L-Measure help](http://cng.gmu.edu/Lm/help/index.htm)
- **Response**:
Delivers JSON File with the L-Measure result. 

##### **Path**: /api/thumb
- **Method**: POST
- **Media type**: multipart/form-data
- **Input fields**: 
  - field:
    - **name**: file1
    - **type**: file
    - **value**: locally selected SWC file
- **Response**:
{'fraction_non_alphanumeric': 0.2040187738339689, 'fraction_numerical': 0.010560281607509533, 'mean_word_length': 3.1177536231884058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1127753', 'n_tokens_mistral': 2370, 'n_tokens_neox': 2257, 'n_words': 643}